Commit Graph

245 Commits

Author SHA1 Message Date
Steve Karg a755a8db4d Feature/octetstring value and length api (#1264)
* feat: add octetstring_length_value_same function for length and content comparison

* feat: add tests for characterstring UTF-8 validation

* feat: add tests for octetstring_init_ascii_epics validation

* feat: add test for bacnet_strdup string duplication validation

* feat: add utf8_isvalid test cases

* feat: add octet string value API for present-value octet-string value and length, and out-of-service properties
2026-03-16 17:04:23 -05:00
Steve Karg 07cf52384b Fixed duplicate name in RPM unit test. (#1260) 2026-03-12 18:13:06 -05:00
Steve Karg 4499f17135 fix: Add input validation to Schedule_Recalculate_PV and Schedule_Timer functions to prevent segmentation fault occurring in Schedule_Recalculate_PV() during application startup (#1259) 2026-03-12 10:21:29 -05:00
Steve Karg f525e7c484 Bugfix/read-range-address-list-encode (#1149)
* Fix: Corrected `rr_address_list_encode` to properly handle the end of the address cache and added a new test case to validate ReadRange operations near the cache limit.
2026-03-12 09:05:04 -05:00
Steve Karg 07bfc7c61c Fix Trend Log ReadRangeACK BY_SEQUENCE where an incorrect FirstSequence is sometimes returned. (#1150) 2026-03-12 08:13:04 -05:00
Steve Karg a5f2b2b125 Add property_list_read_only_member function to check for READ-ONLY properties (#1258) 2026-03-11 07:17:30 -05:00
Steve Karg 926bc17801 Feature/writable structured view object lists (#1256)
* Added WriteProperty handler in the Structured View object with handling for object-name, description, node-subtype, node-type, default-subordinate-relationship, represents, subordinate-list, subordinate-annotations, subordinate-node-types, and subordinate-relationships in the basic Structured View object.

* Changed Structured View character strings for object-name, description, and node-subtype to use dynamic strings to support WriteProperty.

* Added characterstring_utf8_valid(), characterstring_utf8_strdup() and write_property_characterstring_utf8_strdup() for UTF-8 string duplication.

* Added write property tests for array handling and validation of array index values
2026-03-06 10:23:42 -06:00
Steve Karg 1437a68ce1 Add CreateObject and DeleteObject for Octet String and Positive Integer Values (#1246)
* Added CreateObject and DeleteObject for basic Octet String Value and Positive Integer Value objects.

* Changed PositiveInteger present-value datatype to BACNET_UNSIGNED_INTEGER.
2026-02-26 16:25:03 -06:00
Steve Karg 24587dfc27 Add PROP_TIMER_RUNNING to writable properties and implement Timer_Running_Set functionality (#1245) 2026-02-26 11:26:42 -06:00
Steve Karg a70ce07507 Secure BACnet decoders and service requests (#1244)
* Secured BACnetAssignedAccessRights decoder.

* Secured BACnetPropertyState decoder.

* Secured BACnetCredentialAuthenticationFactor decoder.

* Secured BACnetEventState change-of-state [1] SEQUENCE decoder.

* Secured I-Have-Request service decoder.

* Secured Add/Remove ListElement service request decoder.

* Secured ConfirmedPrivateTransfer-Request and UnconfirmedPrivateTransfer-Request decoders.

* Secured ReadPropertyMultiple-Request and -Ack decoders.

* Secured TimeSynchronization-Request decoder.

* Secured WritePropertyMultiple service decoders

* Secured Trend Log object TL_fetch_property() function.

* Secured ReadProperty-Ack decider,

* Refactor BACnet time sync recipient handling by moving timesync linked list structure into bacdest where the recipient encoder and decoder already existed.

* Secured decoding of BACnetPropertyState.

* Secured decoding in the LifeSafetyOperation-Request service.

* Secured BACnetAuthenticationFactor decoding in the Credential Data Input object.

* Fixed WriteProperty decoder to avoid read buffer overrun.  Improved WriteProperty error reporting by adding specific reject codes during decoding similar to WritePropertyMultiple. Deduplicated the WriteProperty handling of abort, reject and error codes.

* Added BACNET_STACK_DEPRECATED_DISABLE guards around all of the deprecated decoding functions to ensure they are not used except intentionally for legacy code bases.

* Changed version to 1.5.0.rc5 for security fix tracking in branch.
2026-02-26 10:48:25 -06:00
Steve Karg cf4f62f7e0 Added Who-Is-Router process for Notification Class recipient unknown router addresses. (#1243)
* Added Who-Is-Router-To-Network process in basic Notification Class when recipient address is missing the router MAC address.

* Added buffer_length parameter to octet string buffer decode functions

* Fixed BACnet address handling for I-Am-Router address updating the recipient list address for the next hop router.

* Changed VMAC encoding and decoding to use octet string buffer API to reduce stack RAM.
2026-02-25 09:58:38 -06:00
Steve Karg e11cd319da Add initialization and unpacking functions for BACnet Character String buffer decoder. (#1242) 2026-02-24 21:15:29 -06:00
Steve Karg 578f507125 Secure the BVLC decoders by replacing deprecated primitive and complex data decoders. (#1241) 2026-02-20 10:30:46 -06:00
Steve Karg 8209673c43 Add Host-N-Port minimal encode and decode (#1239)
* Added Host-N-Port minimal encode and decode which utilizes the octet string buffer and character string buffer encode and decode API.
2026-02-20 08:55:40 -06:00
Steve Karg 4597dfe7ef Added API for extending the basic Device object and children with proprietary properties for ReadProperty and WriteProperty services. (#1238)
* Added callback API for extending the basic Device object and children with proprietary properties for ReadProperty and WriteProperty services. The callback API includes a function to get the specific proprietary property list for any specific object instance in the device, functions to handle the ReadProperty or WriteProperty of the proprietary property.

* Added a new property_list_function typedef to proplist.h for proprietary property list callbacks

* Removed the object-specific proprietary property implementation from the Loop object

* Added test coverage in the Device test validating the proprietary property API usage
2026-02-20 06:57:05 -06:00
GauiStori f9a0386614 Schedule sets the correct value but only in the schedule object. References are not set yet. (#1236)
Add device_moc.c to tests cmake. Thanks Steve
2026-02-19 15:03:52 -06:00
Steve Karg 2874dcea5e Add octet and character string buffer codecs to used with fixed size buffers that are not declared as BACNET_OCTET_STRING or BACNET_CHARACTER_STRING. (#1237) 2026-02-19 13:52:23 -06:00
Steve Karg 6bd2b42334 Add Create & Delete to Accumulator object (#1234)
* Added CreateObject and DeleteObject for basic Accumulator objects.
 
* Added WriteProperty handling for object-name, scale, out-of-service, units, and max-pres-value.
2026-02-17 08:31:00 -06:00
Steve Karg c9f2836025 Add BACnet reinitialized state names and parser (#1228) 2026-02-13 10:23:25 -06:00
Steve Karg 9330c47a34 Remove BACFILE dependency in RAM file systems and add mock file object functions for testing (#1227) 2026-02-12 17:15:31 -06:00
Steve Karg 5724959132 Removed ifdef BACFILE where no longer needed. (#1225) 2026-02-12 08:42:35 -06:00
Steve Karg a4ba359fde Add writable properties test for CreateObject service when used as backup-restore file format. 2026-02-10 07:49:31 -06:00
Steve Karg 59218819c1 Added end-of-blink callback for warn-off and warn-relinquish lighting commands (#1214)
* Added Blink.Callback and Blink.Priority to support end-of-blink actions for WARN_OFF/WARN_RELINQUISH. The Blink.Callback is invoked when a blink sequence ends or when a new command interrupts a WARN_OFF/WARN_RELINQUISH in progress.

* Added Lighting Output (LO) WARN_OFF/WARN_RELINQUISH post-egress priority array handling using the Blink.Callback
2026-01-29 16:03:55 -06:00
Steve Karg 4924a57ccc Add enumeration text lookup for BACnet types (#1209)
* Added enumeration text lookup for BACnetAuthenticationStatus, BACnetAuthorizationMode, BACnetAccessCredentialDisable, BACnetAccessCredentialDisableReason, BACnetAccessUserType, BACnetAccessZoneOccupancyState, BACnetWriteStatus, BACnetIPMode, BACnetDoorValue, BACnetMaintenance, BACnetEscalatorFault, BACnetEscalatorMode, BACnetEscalatorOperationDirection, BACnetBackupState, BACnetSecurityLevel, BACnetLiftCarDirection, BACnetLiftCarDoorCommand, BACnetLiftCarDriveStatus, BACnetLiftCarMode, BACnetLiftFault, BACnetLiftGroupMode, BACnetAuditLevel, BACnetAuditOperation, BACnetSCHubConnectorState, BACnetSCConnectionState, BACnetNodeRelationship, BACnetAction, BACnetFileAccessMethod, BACnetLockStatus, BACnetDoorAlarmState, BACnetDoorStatus, BACnetDoorSecuredStatus, and BACnetAccessEvent.

* Created BINARY_PV_MAX with the same semantic meaning as one more than the last valid enumeration, and deprecated MAX_BINARY_PV usage in the examples.

* Reduced code size by using bactext_property_states_strtoul() instead of individual API for each enumations.
2026-01-24 16:11:25 -06:00
Steve Karg 1dead40afa Increase unit test coverage for device object (#1208) 2026-01-21 12:02:34 -06:00
Steve Karg 3a0878a254 Add API for writable object property lists (#1206)
Added a new API for writable property lists across all the basic example object types, preparing for the introduction of a Writable_Property_List property in every object in a future BACnet standard revision.

The lists can be used by backup and restore feature to automatically choose the object property values in the backup that can be restored via internal WriteProperty directly from BACnet CreateObject services with  List of Initial Values. 

Updated existing device object examples to include these writable property lists.
2026-01-21 10:02:21 -06:00
Steve Karg c408cc555b Update Last_On_Value logic for Present_Value property (#1205)
* Fixed lighting output object lighting-command last-on-value to only
  be updated with the last value of the Present_Value property that
  was greater than or equal to 1.0%, keeping in mind that the Present_Value
  shall indicate the target level of the operation and not the current
  value.
2026-01-20 15:44:04 -06:00
Steve Karg 89cf25c2b2 Added post-write notifications for channel, timer, and loop objects. (#1204) 2026-01-20 13:13:45 -06:00
Steve Karg 5802bd0ecc Fixed CreateObject service list-of-initial-values encoding and decoding. (#1199)
Fixes the CreateObject service list-of-initial-values encoding and decoding by refactoring the data structure to be similar to WriteProperty. The implementation changes from using a linked list of property values to using a flat buffer approach with delayed decoding.

Changes:

* Refactored BACNET_CREATE_OBJECT_DATA structure to use an application_data buffer instead of a linked list for initial values
* Added a new create_object_process() and create_object_initializer_list_process() functions to centralize object creation logic and error reporting
* Updated all device implementations to use the new centralized creation functions
* Enhanced the create-object example application to support command-line specification of initial property values
* Added comprehensive test coverage for the new encoding/decoding and processing functions
2026-01-15 14:50:59 -06:00
Steve Karg c5dc00a77b Bugfix/validate-user-provided-file-object-paths (#1197)
* Fixed BACnet file object path name unintended path traversals by optionally restricting path name content with BACNET_FILE_PATH_RESTRICTED define.

* Added POSIX file path name checking for AtomicReadFile and AtomicWriteFile example applications. Prohibits use of relative and absolute file paths when BACNET_FILE_PATH_RESTRICTED is non-zero.
2026-01-05 11:19:52 -06:00
Steve Karg 4e1176394a Bugfix/ubasic-string-tokenizer-null-termination (#1196)
* Fixed tokenizer_string() off-by-one buffer overflow when processing string literals longer than the buffer limit.

* Fixed ubasic potential string buffer overflows by using snprintf instead of sprintf.

* Fixed ubasic label strings to use UBASIC_LABEL_LEN_MAX as buffer limit.

* Fixed ubasic string variables to initialize with zeros.

* Fixed compile errors when UBASIC_DEBUG_STRINGVARIABLES is defined.

* Added ubasic string variables user accessor API and unit testing for ubasic string variables.

* Fixed tokenizer_label() off-by-one buffer overflow when processing string literals longer than the buffer limit.
2026-01-03 15:11:34 -06:00
Steve Karg 88abd3a488 Fixed lighting-output object blink warn relinquish. (#1192)
* Fixed lighting-output object blink warn to honor blink-warn-enable.

* Fixed the blink warn logic for a non-zero percent value blink inhibit.

* Fixed the warn relinquish to actually relinquish.
2025-12-18 16:25:52 -06:00
Steve Karg 5a9abde528 Fixed channel-value encoding in the channel object when no-coercian is required for lighting-command, color-command, and xy-color. (#1190) 2025-12-18 11:08:28 -06:00
Steve Karg 390711a604 Changed the load control object AbleToMeetShed to only check immediate, and added CanNowComplyWithShed function to attempt to meet the shed request while in the non-compliant state. (#1191) 2025-12-18 11:08:03 -06:00
Steve Karg df335343f3 Added test for shed type amount. 2025-12-15 16:16:51 -06:00
Steve Karg 37e45bbb6a Added test for shed type percent. 2025-12-15 15:59:56 -06:00
Steve Karg e7371b16a3 Extended load-control object unit test validation code coverage. 2025-12-15 14:35:08 -06:00
Steve Karg 380540635c Refactored BACnetShedLevel encoding, decoding, and printing into separate file. Added unit testing. (#1187)
* Refactored BACnetShedLevel encoding, decoding, and printing into separate file.  Added unit testing.

* Added API to load control object for shed-level, start-time, duty-window, full-duty-baseline, and enable.

* Fixed bacapp sprintf for shed level and host-n-port found in scan build.
2025-12-12 08:32:42 -06:00
Steve Karg 4b9cd061e7 Added API and properties to basic lighting output object example for power and feedback value. (#1185) 2025-12-11 13:33:50 -06:00
Steve Karg 7f2690fd96 Fixed a regression in the rpm_ack_object_property_process() function that prevented proper parsing of multi-object ReadPropertyMultiple ACK responses. The bug was introduced in PR #765 and caused the function to incorrectly return ERROR_CODE_INVALID_TAG after processing the first object, even when additional valid objects were present in the response. Added tests that use rpm_ack_object_property_process() with a multi-object RPM ACK to verify the fix and prevent regression. (#1183) 2025-12-09 13:18:52 -06:00
Steve Karg 2b328266c8 Fixed Channel object coercion encoding of non-primitive data. (#1181)
* Refactored the object-id to and from 32-bit value so channel-value could re-use the same API.

* Expanded the BACnetChannelValue coercion function to include all the coercions, no coercions, and invalid datatypes described in Table 12-63 of the Channel object.  Expanded unit testing code coverage for BACnetChannelValue.
2025-12-09 11:02:58 -06:00
Steve Karg 95cdec459e Fix warnings during unit testing of BACnet secure connect node. (#1182) 2025-12-09 09:34:28 -06:00
Steve Karg b1c6a0e74b Fixed writing to the Channel object when no member value coercion was required. (#1176)
* Updated documentation for encode functions to accurately describe return values (0 on error instead of BACNET_STATUS_ERROR)

* Expanded property support, removed INPUT object types, added fallback encoding for non-coerced data types, and updated error handling in ReadProperty of present-value to check for 0 instead of BACNET_STATUS_ERROR.

* Expanded the validation tests and increased test code coverage.
2025-12-04 20:28:43 -06:00
Steve Karg 9378f7d1e7 Secured npdu_is_expected_reply() function where the MS/TP reply matcher could have an out-of-bounds read. (#1178) 2025-12-04 09:34:20 -06:00
Steve Karg 6993a7c0fd Bugfix/indtext-find-string-among-similar (#1173)
* Enhanced string comparison functions and update indtext API usage

- Added library specific case-sensitive and case-insensitive string comparison functions that mimic strcmp.
- Updated indtext_by_string and indtext_by_istring to use the new comparison functions.
- Improved documentation for return values in indtext functions.
- Expanded test data in main.c for comprehensive testing when beginning of string matches another string.
2025-12-03 11:08:32 -06:00
Steve Karg 73fbb400cb Fixed bacnet_snprintf() to be able to return the full length of a string when the size is zero. (#1164) 2025-12-01 13:45:30 -06:00
Steve Karg ca9836b099 Added BACnetRecipient and BACnetAddressBinding codecs for EPICS application (#1163)
* Added BACnetRecipient and BACnetAddressBinding encoding, decoding, ASCII conversion, comparison, and copy functions.

*  Added library specific string manipulation utilities including strcmp, strncmp, stptok, and snprintf with offset functions.

* Added test/README about verification and validation testing.
2025-11-27 23:12:39 -06:00
Steve Karg 004aaf702d Fixed unit test stack corruption from using stack based message text characterstring pointer in multiple functions and setting the value in the global event and test event data structures. (#1154) 2025-11-20 06:56:04 -06:00
Steve Karg 8f0fe8c48e Fix timesync recipient encoding to check for OBJECT_DEVICE type before encoding. (#1153) 2025-11-20 05:14:52 -06:00
Steve Karg e9dd910b55 Convert the property list values into int32_t to support the larger property values when an int is 8-bit or 16-bit. (#1145) 2025-11-16 08:34:45 -06:00