* Refactored the BACnet/SC datalink initialization order by moving certificate file checks and hub connection registration to occur after datalink initialization
* Replaced stdlib rand() with platform-specific cryptographically secure random functions (RtlGenRandom for Windows, getrandom for Linux, arc4random_buf for BSD) to generate UUID and VMAC addresses, preventing duplicates that broke connections
* Enabled conditional debug output in BACnet/SC components when BUILD=debug is specified
* Added a new getter API function Timer_State_Change_Value_Get() to the timer object that returns state-change values by copying them to a caller-provided buffer, providing a safer alternative to the existing Timer_State_Change_Value() function which returns a direct pointer to internal data.
* Added ListElement service callback for storing data.
* Added Audit Log and Time Value objects to basic device.
* Added Audit Log object to Makefile and CMake builds.
* Added basic timer object, internal state machine, and unit tests
* Added BACnetTimerStateChangeValue encode, decode, parse, print, and diff with unit tests
* Changed handler of add/remove list element to check if the property is a BACnetLIST
* Added BACnetLIST utility for handling WriteProperty to a list.
* Fixed outlier ReadProperty object handlers to return zero when the RP parameter is NULL.
* Converted device object test to use common read-write property test. Extended the basic BACnet device object example API.
* Created BACnet/IP and COV test mocks to enable device object testing with less dependencies.
* Fixed Lighting_Command to ignore write priority and use its own.
* Fixed BACnetLightingOperation reserved range.
* Refactor overridden into the lighting command module. Added Overridden status flags API. Added Lighting Output API to implement a momentary override to the output that is cleared at the next lighting command. Integrated lighting command overridden behavior into the lighting output object.
* Added Trim_Fade_Time, High_End_Trim, Low_End_Trim, Last_On_Value and Default_On_Value properties to lighting output.
Added TRIM_ACTIVE flag to lighting command. Added Last_On_Value and Default_On_Value to lighting command for restore and toggle.
* Fixed AddListElement and RemoveListElement which were checking the wrong return value from Device object.
* Fixed decoding of ListElement Tag 0: Object ID instance.
* Fixed Notification_Class_Add_List_Element() and Notification_Class_Remove_List_Element() element counter index, and empty slot detection.
* Added bacnet_recipient_device_set() and bacnet_recipient_address_set() API
* Added unit test coverage for Notification Class object.
* Added dynamic RAM file system to use with basic bacnet file object.
* Added static RAM file system to use with basic bacnet file object.
* Added check for read-only during AtomicWriteFile service API for BACnet File object.
* Change stm32f4xx example to use static RAM file system.
* Fixed bacfile_count() function return type
* Fixed WriteProperty error code for PROP_FD_BBMD_ADDRESS and PROP_FD_SUBSCRIPTION_LIFETIME properties.
* Fixed dead-code warning after enabling all datalinks for basic network port object using the property list as the R/W checking for the port type.
* Fixed IPv6 handler to ignore original-broadcast when registered as a foreign-device
* Fixed IPv6 to leave multicast when registering as foreign device.
* Added unit test while reading all object properties to flag properties not in the property-list.
* Added enumeration for last-property used in unit testing.
* Added missing reliability property in the basic multistate output object example.
* Removed polarity property in binary value object as it is not standard.
* Changed BACnetARRAY index validation into ReadProperty, ReadPropertyMultiple, WriteProperty, and WritePropertyMultiple handlers.
* Changed the basic and example objects after refactoring BACnetARRAY index validation into ReadProperty, ReadPropertyMultiple, WriteProperty, and WritePropertyMultiple handlers.
* Added BACnet application decoder that understands that an array element of zero is an unsigned integer tagged value. Fixes RP and RPM apps when reading the array element zero of arrays.
* Added reject in all confirmed service handlers, except GetEventInformation, when confirmed services with zero length occur which rejects with required parameters are missing message.
* Refactored errno use in service using debug_perror. Changed debug_perror usage to debug_fprintf.
* Updated file and function headers in basic/service modules.
* Changed NDPU priority on confirmed messages to use requested NDPU priority.
* Renamed debug_aprintf to debug_printf_stdout for clarity.
* Convert most debug_fprintf usage to debug_print to reduce text bloat in AVR build
* Added ringbuf API for testing.
* Fixed basic ms/tp datalink packet ringbuffer initialization buffer overrun.
* Added basic ms/tp datalink unit test
* Added Ringbuf_Initialize() API with buffer size checking.
* Changed examples to use Ringbuf_Initialize() API for buffer size checking.
* Added daylight savings time calculation module with unit testing.
* Added datetime daylight savings time and clock API
* Added basic datetime_local() clock using mstimer as basis and time-sync option. Integrated clock with ports/stm32f4xx example.
* Added Time-Of-Device-Restart property to example device.
* Added BACnetTimeStamp bacapp support for encode, decode, and parse.
* Added specific addresses handling to apps/writeprop bacwp command line.
* Refactored lighting command operations from the lighting output object, and added unit testing. Integrated the result back into lighting-output object.
* 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>
* Added basic object-name get for ASCII names to enable free if they were dynamically created. Added unit testing to validate the basic object ASCII object-name API.
* Removed static scope on character array used for name since the array gets copied into characterstring array and static is not needed.