* pre-commit: Update and enable clang-format check
There is newer version from clang-format so use that. We do not yet want
18 as that is little bit too new.
* Format some thing by hand which clang-format "breaks"
Clang-format will format some things little bit off in some cases.
Format some things by hand so we get cleaner end result.
* Run clang-format with
```
pre-commit run --all-files clang-format
```
We have already in previously checked places where clang-format does not
make good format and ignored those (hopefully most of the things).
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
* Make most of the functions const correct
Used clang-tidy and sonarlint to help find places where const could
pretty easily applied. Also lot of hand work.
This commit does not yet touch handlers and typedefs of those.
* Fix Arduino uno handler_who_is() has extra parenthesis
For some reason there is extra parenthesis. Remove it this is more
likely buildable.
* Bugfix/bacapp: Fix uninitilized array_index
We have changed bacapp_snprintf_value() to be const correct. After that
we got
```
/home/runner/work/bacnet-stack/bacnet-stack/src/bacnet/bacapp.c:3183:27: warning: 4th function call argument is an uninitialized value [core.CallAndMessage]
ret_val = bacapp_snprintf_weeklyschedule(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```
So analyzer could now spot that we do not actually initilize array_index
at all. Fix this by setting array_index to zero. Note that I actually do
not know if zeroing is right thing to do here. I choose zero as if this
has worked before it is most likely that it will work with zero value.
* cmake: Add and ignore Wwrite-strings compiler option
Wwrite-strings helps find places where const correctness is broken.
Example it will warn about these
```C
void func1(char* str);
func("test") /* "test" is const so we should not pass it to func1().
char* func2()
{
return "test"; /* func2() should return const char*.
}
```
We still need to ignore it as not all are fixed but let's add it already
so we remember that it should be opened at some point.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
* format: Strip trailing whitespaces
We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.
Commit was generated with:
pre-commit run --all-files trailing-whitespace
* format: Files should have exactly one new line end of them
It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.
Commit was generated with:
pre-commit run --all-files end-of-file-fixer
* format: Convert tabs to spaces
Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.
Commit was generated with:
pre-commit run --all-files remove-tabs
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
* Refactored and secured BACnetActionCommand codec into bacaction.c module for command object and added to bacapp module encode/decode with define for enabling and pseudo application tag for internal use.
* Simplified bacapp_data_len() and moved into bacdcode module as bacnet_enclosed_data_len() function.
* Secured ReadProperty-REQUEST and -ACK decoding.
* Removed deprecated Keylist_Key() functions from usage.
* Removed pseudo application datatypes from bacapp_data_decode() which only uses primitive application tag encoded values.
* Defined INT_MAX when it is not already defined by compiler or libc.
* Deprecated bacapp_decode_application_data_len() and bacapp_decode_context_data_len() as they are no longer used in any code in the library.
* Added BACnetScale to bacapp module. Improved complex property value decoding. Refactored bacapp_decode_known_property() function.
* Refactored and improved the bacapp_snprintf() function for printing EPICS.
* Fixed Lighting Output WriteProperty to handle known property decoding.
* Added the SpecialEvent struct for the Exception_Schedule property of Schedule, encode/decode/same functions, unit tests, and integrated into bacapp functions.
* Added the CalendarEntry struct for the Date_List property of Calendar and the SpecialEvent struct, encode/decode functions, unit tests, and integrated into bacapp functions.
* Added the DateRange struct for the Effective_Period property of Schedule, encode/decode functions, unit tests, and integrated into bacapp functions.
---------
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* refactor service requests from service header
* add APDU size checking and length feature
* add unit tests to check for length when passing NULL buffer
---------
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
Added BACnet CreateObject and DeleteObject services
* refactored codec for BACnetPropertyValue into bacapp module
* added unit tests for BACnetPropertyValue
* refactored COV and Events to use BACnetPropertyValue codec API
* added unit tests for COV
* added overrun safe decoders for tag numbers and boolean context
* added unit tests and codecs for CreateObject and DeleteObject services
* added APDU service handers and senders for CreateObject and DeleteObject services
* added command line apps bacco and bacdo for CreateObject and DeleteObject services
* added CreateObject and DeleteObject service handling in example server app and device object
* added new BACnetRejectReason, Error Class, and BACnetAbortReason enumerations and conversions
---------
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* [WIP] Remove unit testcases duplicated under non-unit tree
* [WIP] Update west.yml to Zephyr v3.3.0 (twister verified)
* Update CI to Zephyr v3.4.0 w/ reduced module set
- Update zephyr/module.yml to use Zephyr v3.4.0 + cmsis;
- Update tests to use ZTEST_NEW_API for zephyr builds
Verified by:
1. make clean test
2. ./zephyr/scripts/twister -p unit_testing -T bacnet/zephyr/tests/bacnet
---------
Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
* Added AddListElement and RemoveListElement services
Added list-element codec and unit tests.
Added BACnetDestination codec and unit tests.
Added RecipientList handling to NotificationClass object.
Added AddListElement and RemoveListElement client example app.
* Fix defects found by scan-build and CPPCHECK
* Update ports errors found during CI builds
* Update zephy os test build missing files in CMakeLists
---------
Co-authored-by: Ondřej Hruška <ondra@ondrovo.com>
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
Updating to integrate with Zephyr v3.2.0 required:
- Update `west.yml` to import Zephyr v3.2.0 manifest
- Prefix include pathname of ztest.h with `zephyr/`
- Prefix every Zephyr header included pathname with `zephyr/`
- Change all Zephyr tests/samples to use `find_package`
- For unit_testing, use a distinct prj.conf which only references
Kconfigs defined in the Zephyr repo. (Zephyr constraint.)
- Move ztest headers into a zephyr-prefixed pathname
Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
* schedule: add decode_daily_schedule() and encode_daily_schedule()
* schedule: encode/decode implemented + add to bacapp
* add safe encode/decode functions for timevalue, schedule function renaming
* fix unit tests build failing
* add IDEA and test temporary files to .gitignore
* try to make "deprecated" work in MSVC
* add WeeklySchedule compare function
* add bacnet_weeklyschedule_context_decode()
* Add basic test for WeeklySchedule
* Fix WeeklySchedule parsing and snprintf, decoder verified with real hardware
* try to fix windows build
* improve boolean parsing in 'bacapp_parse_application_data'
* add parse function for weekly schedule
* allow types > 16 in bacwp, show the decoded value before sending
* add bacapp binaries to gitignore
* remove bacwp logging
* Add error checking to bacapp_parse_application_data
* try to fix windows build
* fix avr build
* Fix error handling in RP Ack
* add singleDay flag
* show day name in single day weeklyschedule snprintf
* show weeklyschedule inner tag in snprintf
* improve weeklyschedule parsing and printing, supports type names now
* add weekly schedule to bacapp_decode_data
* move bacnet/bacnet_plat_compat.h to bacnet/basic/sys/platform.h
* disable tag limit also in bacwpm
* add ifdef's around strtoX helper functions in bacapp
* move strtox to BACAPP_PRINT_ENABLED ifdef in bacapp
* fix stm32 makefiles
* fix at91sam7s build
* use BACNET_UNSIGNED_INTEGER in BACnet_Short_Application_Data_Value
* fix capitalization in BACnet_Daily_Schedule
* add name to BACNET_TIME_VALUE struct
* change bacwp bacwpm to use bacapp_known_property_tag()
* fix some macros in bacdcode missing parentheses
* Remove dummy fields from BACNET_SHORT_APPLICATION_DATA_VALUE, replace remaining uses of upcasting (adds extra overhead but is maybe safer), rename short DV to Primitive
* fix new ci warnings
* more fixes for ancient C
* fix tests no longer building
* primitive value renamed to shorter name
* added BACnetColorCommand and BACnetxyColor encoding and unit testing
* Added Color object and unit testing.
* Added Color Temperature object and Unit test
* Fix BVLC unit test warning.
* add port Makefile for extra types
* added RGB to and from CIE xy utility in sys folder, and add unit tests.
* added cmake-win32 target
* Change RP and RPM to use known property decoder.
Add color object RP and RPM decoding and printing
Fix RPM print for new reserved range above 4194303
Change default protocol-revision to 24 for Color object
* Integrate Color and Color Temperature objects into demo apps
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* Add APDU as NULL to get BACnet type lengths.
* Fix bacapp copy test to succeed
* fix BACnet REAL and DOUBLE decode
* Add unit test for NULL APDU encoding for length
* Add unit tests for bacapp context
* refactor host-n-port to hostnport.c module
* fix BVLC decoder
* additional unit testing for bacapp
* include bacdevobjpropref module in builds
* simplify bacapp snprintf to be able to return length
* adjust compiler for variable-length arrays
* fix bug found by scan-build
Authored-by: Steve Karg <skarg@users.sourceforge.net>
* Leverage (older) embedded unit tests into external unit tests build upon copy of Zephyr's ztest library and CMake.
* Expand top-level CMake build to run external unit tests.
* Expand Zephyr module extension to run external unit tests via west or sanitycheck.
Co-authored-by: Gregory Shue <gregory.shue@legrand.us>