Commit Graph

27 Commits

Author SHA1 Message Date
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
Steve Karg 4dd13cf199 Added basic timer object, internal state machine, and unit tests (#1123)
* 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.
2025-11-05 15:11:45 -06:00
Steve Karg 8a9c808b76 Fixed test code headers to be consistent and accurate having been derived from original C files. (#1087) 2025-09-04 11:44:24 -05:00
Steve Karg 6f7f3649a5 Bugfix/read range trend log buffer (#947)
* Fixed ReadRange app to read and pretty-print a Trend Log log-buffer
2025-03-25 10:32:11 -05:00
Steve Karg cf77abac9b Feature/bacnet secure connect hub (#818)
* Added BACnet Secure Connect datalink.

* Added BACnet/SC hub application
---------

Co-authored-by: Kirill Neznamov <kirill.neznamov@dsr-corporation.com>
Co-authored-by: Mikhail Antropov <michail.antropov@dsr-corporation.com>
Co-authored-by: Ondřej Hruška <ondra@ondrovo.com>
Co-authored-by: Patrick Grimm <patrick@lunatiki.de>
2024-11-04 07:05:26 -06:00
Steve Karg 3329dff337 Added WriteGroup service and Channel object interfaces (#829) 2024-10-25 10:43:29 -05:00
Steve Karg c18768ba61 Fixed BACnetAccessRule application integration into Access Rights object. Improved unit testing and code coverage. (#790) 2024-09-30 14:04:30 -05:00
Kari Argillander f806c5829b Run clang-format and enable CI check for it (#755)
* 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>
2024-08-30 11:20:58 -05:00
Steve Karg 3d3e192ae9 Added object-name c-string getter function to basic objects so they can be referenced to free if dynamically created. (#754)
* 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.
2024-08-28 16:21:58 -05:00
Kari Argillander 369da70f2a Strip tabs and trailing white spaces, and fix end of files (#748)
* 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>
2024-08-25 14:13:57 -05:00
Steve Karg 61730e3d87 Fixed load control object and unit test. Added recipe to Makefile for Zephyr OS twister unit testing. (#710) 2024-08-06 08:28:01 -05:00
Steve Karg 4326128e72 Secure ReadProperty decoding and BACnetActionCommand (#702)
* 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.
2024-07-25 17:12:08 -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 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
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 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
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
Steve Karg ced9dff0f2 Added AddListElement and RemoveListElement services (#418)
* 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>
2023-04-16 14:12:11 -05:00
Greg Shue eb36033fd8 [OSCBS-41] Update to Zephyr v3.2.0 (#382)
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>
2023-01-18 08:50:31 -08:00
Ondřej Hruška 7cdab61d72 Schedule encoding/decoding (#319)
* 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
2022-09-05 09:27:15 -05:00
Mikhail Antropov 4b742effe1 Fix tests: (#314)
- misprint in ports/zephyr/bip-init.c
- error processing PROP_TRACKING_VALUE for the Color Temperature object in
  src/bacnet/bacapp.c
- misprint MSV test
- add hostnport.c for each zephyr tests
- fix colors and ms-input tests - remove mocking Device_Inc_Database_Revision()
  for zephyr tests
- debug the color temperature test
2022-07-30 03:31:38 -05:00
Steve Karg 38d213b47c Feature/color objects color command (#302)
* 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>
2022-07-13 09:54:36 -05:00
Steve Karg f147283293 Feature/apdu null length returned (#285)
* 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>
2022-06-01 15:42:50 -05:00
Greg Shue 8b8ef8f338 Issue 187 enable skipped ztest suites (#189)
* Fix some ztests that were skipped

* Expose bacapp_same_value()

* Fix bacapp, ptransfer tests

* Fix bugs in Load_Control object & tests

* refactor days functions from datetime module

* fix legacy ctests

* Add bacnet/basic/sys/days.[ch] to Zephyr build

* Update ztest to match from Zephyr v2.6.0; update ringbuf, datetime to build

* Fixup ztest test for object/acc

* Fix bvlc_address_from_ascii; enable/fix bvlc test

* Comment cleanup

* test/bacnet/basic/object/lc partially enabled

* Fix bacapp_decode_data_len return status on erroneous input

* fix ztest include fatal error

* fix ztest strsignal reference fatal error

* fix zassert_mem_equal reference syntax error

* fix zassert_mem_equal reference syntax error

Co-authored-by: Gregory Shue <gregory.shue@legrand.us>
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2021-08-16 17:29:40 -05:00
Steve Karg 810a2f93de Feature/write property type check refactor (#182)
* refactor write-property tag check

* modify ports objects to use write-property tag check API

* modify example objects to use write-property tag check API

* Fix object unit test builds

* Fix and run unit ztests via CMake

* Enable unit testing on Travis CI

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2021-06-23 10:10:12 -05:00
Greg Shue 5c2f198fd8 Issue 121 zephyr module cleanup west 0 8 0a1 (#122)
* Rm top-level west.yml; Cleanup manifests; Fix unit testing

* Cleanup sample

* Cleanup test CMakeLists

Co-authored-by: Gregory Shue <gregory.shue@legrand.us>
2020-09-17 09:58:06 -05:00
Greg Shue 19869dccdb Feature/zephyr ztest (#118)
* 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>
2020-09-16 07:33:34 -05:00