Commit Graph

115 Commits

Author SHA1 Message Date
Steve Karg 309964e929 Added existing BBMD unit test by converting to cmake (#657) 2024-05-30 09:02:49 -05:00
Steve Karg 4cd7acebcd Secure ReadPropertyMultiple code, and improve unit test coverage. (#650) 2024-05-21 08:28:50 -05:00
Steve Karg 4cd5e2be97 Secured BACnetTimeValue codec, and improved unit test coverage. (#648)
* Secured BACnetTimeValue codec, and improved unit test coverage.
2024-05-20 12:06:28 -05:00
Steve Karg 53fd7a2e1f Secured the WhoHas codec and improved unit test coverage. (#649) 2024-05-20 11:39:10 -05:00
Steve Karg cf00e9e094 Bugfix/secure alarm ack codec (#647)
* Secured BACnetAcknowledgeAlarmInfo codec and improved unit testing code coverage.
2024-05-20 11:18:07 -05:00
Steve Karg cbd9b3f04f added secure BACnet primitive datatype encode functions. (#643)
* added secure BACnet primitive datatype encode functions.
2024-05-17 08:56:24 -05:00
Steve Karg 8eab077ebf Added function to determine if an object property is a BACnetARRAY. (#642)
* Added function to determine if an object property is a BACnetARRAY.  Added property test for BACnetARRAY members.
2024-05-15 13:25:44 -05:00
Steve Karg affb358139 Feature/add basic structured view object (#641)
* Added basic structured view object and unit test. Added example structured view into server example.

* Removed creation of objects from basic device object into the server example
2024-05-14 14:51:45 -05:00
Steve Karg 96222574f8 Bugfix/router mstp builds (#630)
* Fixed example app router-ipv6 to build under ports/win32

* Fixed example app router-mstp to build under ports/win32 with MinGW

* Added win32 builds of router-ipv6 and router-mstp to the Github pipeline
2024-04-30 13:52:00 -05:00
Steve Karg 70c54817fd Added AlignAfterOpenBracket: AlwaysBreak and BinPackArguments: true to clang-format. Updated test/bacnet c/h files with updated format. 2024-04-24 09:38:12 -05:00
Steve Karg 1aaebe9414 Added host_n_port_context_decode function. 2024-04-23 11:26:20 -05:00
Steve Karg de6287bedb Added datetime to ASCII function. 2024-04-23 10:26:30 -05:00
Steve Karg e73520a974 Add timestamp snprintf. Fix bacapp snprintf to account for string size zero behavior of snprintf. 2024-04-23 10:04:46 -05:00
Steve Karg 770be70688 Chore/bacnet-sc-unrelated-cleanup (#620)
* Added required linux Ethernet library for ethernet build

* Added .obj to gitignore

* Fixed BACnet port for APPLE to use BSD in CMake

* Changed format in CMake to enable cleaner SC merge

* Added create-object and delete-object recipes in GCC Makefile

* Added datalink timer to all example OS apps

* Changed most microcontroller ports to use BACAPP_MINIMAL to specify which datatypes can be written.

* Fixed zephyr OS for BACnet/IP warning

* Fixed zephyr OS log to not require log_strdup

* Added writefile API to file object example

* Added API to device-client to make it more robust.

* Added API in network-port object for getting the ASCII object-name

* Added debug print with a timestamp option

* Added debug print with hex dump print

* Added API to network port object for activate and discard

* Added default define for debug with timestamp

* Added prototype in header for disabled debug printf.

* Added fifo peek ahead function to peek at more than one byte.

* Added get-mac value for network port that uses buffer rather than octetstring
2024-04-19 12:54:56 -05:00
Steve Karg b8201dad26 Fixed unit test checking for unknown property. Added reliability property to binary-value ReadProperty. 2024-04-04 12:26:14 -05:00
Steve Karg 76d3680b5e Feature - added create/delete/COV services for analog, binary, and multistate objects (#612)
* Added Create/Delete object services to Analog Input, Analog Value, Binary Input, Binary Value, Multistate Input, Multistate Value object examples, and updated their units tests.
2024-04-03 13:27:03 -05:00
Steve Karg 6bd1942635 Refactor/property lists member function (#609)
* Refactor property lists member function for WriteProperty default case.

* Refactor time-value object unit testing

* Added test for unsupported property to common property test
2024-03-27 09:52:01 -05:00
Steve Karg 31ffc8024e Bugfix/double float promotion warnings (#605)
* Fixed compile warnings from double-float promotions.

* Changed zephyr compile to suppress deprecation warnings

* Fixed CreateObject API return value in many objects header files

* Changed zephyr build defines as strdup is no longer required for log print of strings
2024-03-26 09:45:01 -05:00
Steve Karg 1520f2c612 Add core stack headers into bacdef.h and cleanup includes. (#602)
* Added dependent BACnet stack headers into bacdef.h file.

* Changed bacdef.h and other stack includes in c/h files to have a common pattern.

* Moved bits.h, bytes.h, and bacnet_stack_exports.h under bacnet/basic/sys/ folder.
2024-03-15 16:58:52 -05:00
Greg Shue 78f7340266 Issues/issue 593 update to zephyr v3 6 0 (#601)
* [WIP] update manifest to zephyr v3.6.0

* [WIP] Deprecated ZTEST_NEW_API adjustments

Zephyr v3.6.0 removed Kconfig ZTEST_NEW_API.
The old ZTEST API is still used by non-Zephyr builds,
so the config setting is moved from `prj.conf` to
the test's CMakeLists.txt as `add_compile_definitions()`.

Verified by:

1. make clean all test

2. ./zephyr/scripts/twister -p unit_testing \
        -T bacnet-stack/zephyr/tests/

---------

Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
2024-03-15 08:29:05 -07:00
Steve Karg f0760e2b96 Require bacdef.h as first bacnet header to include (#598) (#600)
* Require bacdeps.h as first bacnet header to include

BACnet headers need to pull in optional configuration and
optional ecosystem overrides to allow integrators to control
builds.  This commit changes bacnet header files to first
include bacnet/bacdep.h to consistently introduce integrator
header files.

Verified by:

1. make clean all test

2. ./zephyr/scripts/twister -p unit_testing \
        -T bacnet-stack/zephyr/tests/



* Migrate BACNET_UNSIGNED_INTEGER defn to bacdef.h

Verified by:

1. make clean all test

2. ./zephyr/scripts/twister -p unit_testing \
        -T bacnet-stack/zephyr/tests/



---------

Signed-off-by: Gregory Shue <gregory.shue@legrand.com>
Co-authored-by: Greg Shue <32416235+gregshue@users.noreply.github.com>
Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
2024-03-13 16:27:56 -05:00
Steve Karg a5f4ab3c88 Feature/life safety zone object example (#595)
* Added Keylist_Data_Free function to free all nodes and data in a list

* Added basic Life Safety Zone object type in the apps/server example, with unit testing.
2024-03-07 16:15:46 -06:00
Steve Karg 2ecb1a2bc8 Bugfix/mstp extended frames client (#592)
* Fix routing to a remote network in the router-mstp example.

The net, len and adr fields of remote_dest are not initialized
although they are used by the npdu_encode_pdu function in
case of "Routing to another Router". Thank you, Eugene!

* Fixed handling of received MS/TP extended frames.

mstp_port->DataLength should be set to the actual length of decoded data.

* Fix MSTP_Master_Node_FSM and MSTP_Slave_Node_FSM for extended frames.

BACNET_EXTENDED_DATA frames should be treated the same as
their corresponding BACNET_DATA frames.

* Fixed MSTP COBS frame encoding

cobs_frame_encode writes the encoded data to the
beginning of the buffer, overwriting the frame header.

The frame header is constructed before COBS frame encoding,
so it contains the wrong Frame Type and Data Length.

* Added extended frame client unit test

* Fix router-ipv6 application for remote networks
2024-03-06 18:32:00 -06:00
Steve Karg dfef5208d1 Bugfix/bacapp deprecation fixes (#578)
* Secured bacapp_decode_application_data_safe(), bacapp_decode_application_data_len(), bacapp_decode_context_data(), bacapp_decode_known_property() for timestamp, bacapp_decode_context_data_len(), and bacapp_data_len() functions.

* Fixed Command, Credential Data Input, and Schedule objects unit test
2024-02-27 14:03:14 -06:00
Steve Karg 190183966c update keylist to use bool and stdint value for key not found. (#572)
* Updated keylist to use bool and stdint value for key not found.

* Added Keylist_Index_Key to deprecate Keylist_Key function

* Changed the deprecated Keylist_Key API to Keylist_Index_Key

* Added unit test for Keylist_Index_Key API
2024-02-12 17:35:15 -06:00
Steve Karg 7eedaa406d Bugfix/bacaddr dnet only init (#570)
* Fixed bacnet_address_init() when setting only the dnet value.

* Fixed MSVC snprintf from C99
2024-02-08 16:39:49 -06:00
Steve Karg 1f591db6e7 Feature/mstp zero config option (#564)
* Added a MS/TP zero-config (automatically choose an unused MAC address) using an algorithm that starts with MAC=64 and waits for a random number of PFM (minimum of 8 plus modulo 64) before attempting to choose a MAC sequentially from 64..127. The confirmation uses a 128-bit UUID with the MSTP Test Request frame. The modifications are in src/bacnet/datalink/mstp.c and src/bacnet/datalink/dlmstp.c modules enabling any device to use zero-config if enabled. A working demonstration is in the ports/stm32f4xx for the NUCLEO board. Complete unit testing is included.  Options include lurking forever (wait for a router or another master node before joining) or lurking for a minimum time (enables self forming automatic MAC addressing device nodes).
2024-02-02 11:18:20 -06:00
Mikhail Antropov 8f576461a8 Feature/oscbs 29 calendar time object (#440)
* Added basic Calendar object, unit tests, and integration with example device object.

* Added basic Time Value object, unit tests, and integration with example device object.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2024-02-01 23:01:27 -06:00
Ondřej Hruška 340bd09561 Implement missing data types for calendar and schedule (#474)
* 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>
2024-02-01 10:57:46 -06:00
Steve Karg 6cb875aae6 Feature/add bacnet binary lighting object (#522)
* Added Binary Lighting Output object example.

* Changed piface example app to support binary-lighting-output object type and blink warn

* Changed example device object to not create objects when device object-table is overridden

* Fixed unit testing for device object
2024-01-29 09:41:40 -06:00
Steve Karg 587e3c5a11 Chore/refactor automac unit test (#557)
* move ports automac module into bacnet/datalink and add unit test.
2024-01-12 16:14:24 -06:00
Steve Karg c6dcab8f0a Change Life-Safety-Point object to use Create/Delete-Object (#555)
* Change Life-Safety-Point object to use Create/Delete-Object
2024-01-12 16:01:50 -06:00
Steve Karg ba4b0ca7c6 Changed BACnetPropertyStates to support more enumerations. Added apdu size checking on decode. Removed BACnetPropertyStates local enumeration. Increased BACnetPropertyStates codec unit test coverage. 2024-01-05 16:00:42 -06:00
Steve Karg bb081d28da Bugfix/service request refactor size check (#553)
* 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>
2024-01-05 08:59:45 -06:00
Steve Karg 73ee75635b Changed npdu_encode function to return length when given a NULL buffer. (#549)
* Changed npdu_encode function to return length when given a NULL buffer.

* reduce TSM dependency in NPDU handler and use local buffer

* add bacnet API with additional size of PDU argument.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-12-27 10:29:42 -06:00
Steve Karg b9a29d8093 add defines for each supported BACAPP_TYPES_EXTRA (#543)
* add defines for each supported BACAPP_TYPES_EXTRA

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-12-01 12:23:44 -06:00
Steve Karg 9780f52640 Fix bacdevobjpropref module decode buffer overflow reads (#541)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-11-29 15:44:58 -06:00
Steve Karg 0b5474d36e Ignore ReinitializeDevice and DeviceCommunicationControl service password (#518)
* Fix device object ReinitializeDevice service handling examples of no-password in the device. Add unit testing of device object ReinitializeDevice service.  Add API for setting ReinitializeDevice device object password.

* Fix DeviceCommunicationControl service handling example of no-password in the device.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-10-18 21:32:44 -05:00
Ondřej Hruška e143066b29 object/nc: Fix incorrect apdu_len calculation (#517)
* object/nc: Fix incorrect apdu_len calculation when encoding Recipient_List which had resulted in malformed APDU.

* enabled unit testing on notification-class object example

---------

Co-authored-by: Tomasz Kazimierz Motyl <butterfly_tm666@yahoo.com>
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-10-18 11:10:17 -05:00
Steve Karg c9a85a1282 Refactor/write property object name (#504)
* refactor WriteProperty of object-name property rules into device object.

* remove dependence on device object inside some dynamic objects

* improve device object unit test coverage

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-28 15:30:28 -05:00
Steve Karg da2dc9841a Feature/raspberry pi blinkt color objects (#503)
* fixed BACnetXYcolor and BACnetColorCommand encode and decoding and improved unit test coverage. Refactored BACnetXYcolor to/from ascii into lighting module.

* added to the color, color temperature, and lighting output objects a fade/ramp/step engine.  Added color and color command coercion into the channel object and enabled color temperature object coercion.  Added CreateObject and DeleteObject service handling to the color, color temperature, lighting output, and channel objects.

* added blinkt demo app for Raspberry Pi [WIP]

* updated gitignore to simplify handling of apps folder contents

* fixed piface demo build

* added RaspiOS to pipeline for piface and blinkt! demo builds

* added device object timer function for child object types into example Device object.  Refactored device object to increment database revision for create or delete object services.   Refactored example app/server to use mstimer library and device child object timers.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-28 10:50:32 -05:00
Steve Karg b0749572f6 Bugfix/fix write property decode deprecated (#499)
* fixed WriteProperty to use secure decode. Improve unit testing.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-16 10:23:08 -05:00
Steve Karg b14177672b Fixed datetime decode of invalid tag. (#495)
* Fixed datetime decode of invalid application tag.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-12 15:11:52 -05:00
bakmaria e4dd30ed89 Fix wrong calculation of frames in bacapp_data_len (#491)
* Fixed wrong calculation of data length.  In cases when 2 sets of opening & closing tags (first opening tag context tag is 3, second is 0) were sent, one of the frames wasn't added, and the resulted sum was wrong

* Added unit test for case with two sets of opening & closing tags
2023-09-11 09:41:06 -05:00
Steve Karg bd597082d2 Fix ReinitializeDevice service handling of optional password (#487)
* Fix ReinitializeDevice service handling of optional password

* Improve ReinitializeDevice service unit testing

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-08 14:58:04 -05:00
Steve Karg f641aacddb Bugfix/deprecate decode tag number and value (#481)
* added or updated secure the BACnet primitive value decoders - the core codecs - named bacnet_x_decode(), bacnet_x_application_decode() and bacnet_x_context_decode where x is one of the 13 BACnet primitive value names.  The updated API includes an APDU size to prevent over-reading of an APDU buffer while decoding.  Improved or added unit test code coverage for the BACnet primitive value decoders.

* marked the insecure decoding API as 'deprecated' which is defined in src/bacnet/basic/sys/platform.h and can be disabled during a build. 

* added secure decoders for BACnetTimeValue, BACnetHostNPort, BACnetTimeStamp, BACnetAddress, and Weekly_Schedule and improved unit test code coverage.

* improved test code coverage for BACnet objects and properties.

* secured AtomicReadFile and AtomicWriteFile service decoders and improved unit test code coverage.

* secured BACnet Error service decoder and improved unit test code coverage.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-08 11:39:27 -05:00
Steve Karg f61f4300be Feature/add create object service (#476)
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>
2023-08-28 13:02:35 -05:00
Steve Karg 8184afea12 Chore/make test parallel build limits (#480)
* re-enable parallel build for CMake unit tests, but limited to ncores on supported OSes. Using MAKEFLAGS in .bashrc to set the '-j' flag size causes problem for Makefile build of BACnet library which doesn't tolerate parallel builds.  Using "-j" without limits for CMake of unit tests overwhelms my lesser endowed build machines.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-08-25 15:15:32 -05:00
anthony-crystalpeak acb3b0f57d [libbacnet]: bacapp_data_len() + bacnet_tag_number_and_value_decode() (#453)
* Bugfix: bacapp_data_len() + bacnet_tag_number_and_value_decode()

* Fix bacnet_tag_number_and_value_decode function.
Add read buffer safe functions for opening, closing, context specific tags.
Fix bacapp_data_len function changes as indicated by unit testing.

* refactor bacapp_data_len
---------
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-07-31 16:50:14 -05:00
Greg Shue dad9e13485 Issues/issue 461 update to zephyr v3 4 0 in ci (#463)
* [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>
2023-07-26 14:47:01 -07:00