Commit Graph

78 Commits

Author SHA1 Message Date
Steve Karg ad5a43042c Added MS/TP datalink option to BACnet basic server example. (#1077) 2025-08-25 11:02:43 -05:00
Steve Karg 3f89981b29 Created simple project for GTK BACnet Discovery Application. (#1064) 2025-08-07 17:16:34 -05:00
Steve Karg f88f5a3424 Fixed the Linux DLMSTP standalone test application Makefile. (#1055) 2025-07-31 09:40:18 -05:00
Steve Karg 5072fb5913 Feature/add who am i and you are services (#1024)
* Added Who-Am-I-Request encoding, decoding, unit tests, and command line application bacwhoami.

* Added You-Are-Request encoding, decoding, unit tests, and command line application bacyouare.

* Added Who-Am-I with Who-Is and You-Are handling into the example server application when run as device 4194303.
2025-06-23 10:49:59 -05:00
Steve Karg 80875add0a Fixed BACnet/IP initialization on a network interface where the system reports the interface's unicast IP address as being the same. (#1011) 2025-06-03 19:49:03 -05:00
Steve Karg 442f408c1a Bugfix/dlmstp api missing in ports os (#1003)
* Added missing API defined in header into ports/win32/dlmstp.c module, added a PDU queue and refactored receive thread, and refactored MS/TP timing parameters.

* Added missing API defined in header into ports/linux/dlmstp.c module, and refactored MS/TP timing parameters.

* Added missing API defined in header into ports/bsd/dlmstp.c module, and refactored MS/TP timing parameters.

* Reduce default MS/TP APDU to 480 to avoid extended frames by default.
2025-05-27 10:14:15 -05:00
Steve Karg 31af2507fb Bugfix/secure read range codec (#957)
* Secured ReadRange service codecs. Added ReadRange unit testing. Secured ReadRange-ACK handler to enable APDU size checking.
2025-04-03 09:14:08 -05:00
Steve Karg f1ea03647f Bugfix/bacmini-updates-with-program-object-and-cmake (#941)
* Added bacmini example app with minimal analog and binary objects  (#934)

* Fixed bacmini app build for Makefile and CMake

* Changed the folder for bacmini application to server-mini

---------

Co-authored-by: Ben Bartling <ben.bartling@gmail.com>
2025-03-13 17:18:47 -05:00
Steve Karg 5cd453c925 Fixed WriteProperty error code for FD_BBMD_ADDRESS and FD_SUBSCRIPTION_LIFETIME (#925)
* 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.
2025-03-03 08:04:07 -06:00
Steve Karg 3e480f41e2 Ported bacnet-basic from zephyr project to create basis for mini example. (#933) 2025-02-27 15:49:29 -06:00
Steve Karg c5b129e9ab Fixed legacy make build recipe for library. 2025-02-03 09:28:51 -06:00
Steve Karg cfe257fe69 Fixed spelling errors detected by code-spell utility. (#895)
* Fixed spelling errors detected by code-spell utility.

* Fixed cppcheck preprocessorErrorDirective. Suppressed new cppcheck warnings until fixed.
2025-01-21 13:31:43 -06:00
Steve Karg 6b6be4a434 Added check for zero length buffer size in primitive decoders that returns zero to enable simpler complex value optional element decoding. (#876) 2024-12-18 15:29:27 -06:00
Steve Karg d4cbec91e2 Enabled style and CERT-C addon for CPPCHECK (#869)
* Enabled style and CERT-C addon for CPPCHECK with some suppressions and fixed the defects found..
2024-12-10 07:56:24 -06:00
Steve Karg e31350f6e9 Chore/doxygen update build (#845)
* Updated doxygen header, footer, and stylesheet files, and Makefile recipes

* Updated the bacnet.sourceforge.net website.

* Updated wording in README
2024-11-06 05:53:04 -06: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 d47bb67c21 Added WriteGroup service to blinkt app demo. (#843) 2024-11-01 10:40:53 -05:00
Steve Karg 6d9cff2312 Fixed device object compile errors and added IPv6 recipes for blinkt and piface (#841) 2024-10-31 14:16:47 -05:00
Steve Karg 3329dff337 Added WriteGroup service and Channel object interfaces (#829) 2024-10-25 10:43:29 -05:00
Steve Karg 4781582204 Changed ATmega168 port to ATmega328 on Uno R3 with DFR0259 RS485 shield (#784)
* Changed ATmega168 example for ATmega328 on Arduino Uno R3 with DFR0259 RS485 shield. Added ADC interface from BDK port and mapped to some AV objects. Removed MS/TP MAC address DIP switch GPIO and moved MS/TP configuration to AV objects. Added AV units property. Added some Uno R3 Digital Inputs and outputs mapped to some BV. Added AVR EEPROM from BDK port and mapped some non-volatile data including MAC address and max manager and baud rate, device ID and names and description and location.
2024-09-27 14:42:47 -05:00
Kari Argillander 0177c59f4a Use pre-commit and editorconfig (#753)
* Add editorconfig and pre-commit config

Editorconfig is widly used and supported file. It says basic things how
files should be formatted.

pre-commit is tool which can automatically check some basic checks like
code formatting everytime someone makes commit. This can also be used in
CI to run these things. Then it is very easy to do same things locally
as in CI. This also makes easy to select clang-format version so
everyone is using same one.

* clang-format: Ignore folders where are external code

We should not format external code. Add clang-format files to exclude
those. We should move external code always to example external/ folder
so we can exclude those more easily.

* clang-format: Remove custom zephyr/.clang-gormat

This clang-format file where introduces before our root clang-format. It
does not make sense anymore as we have root clang-format. Removing this
will unifie formatting in whole repo.

* clang-format: Add couple new rules

Add couple new formatting rules.

Always align const to left side. We did have only one place where it was
right side so this make sense as it is already rule for us.

I choose also insertbraces becuase when I run this I notice that we have
lot of multiline code without braces. So very error prone places. This
will take error possibility away. Repo also always use braces even with
single line statments so this does not matter much.

* ci: Add pre-commit validation

Validate pre-commit in CI.

* format: Convert spaces to tabs in Makefiles

Makefile normally use tabs. We enforce that with editorconfig. Fix
couple places where spaces where still in use.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-28 17:04:00 -05:00
Steve Karg 81e83b19c1 Fixed Lighting Output unit test builds after recent fixes added debug printing and implicit float to double promotion. 2024-08-07 11:27:51 -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 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 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 1176b0d966 Feature/bacnet discover dnet devices (#583)
* Added an example application to discover devices and their objects and properties on a specific destination network. The application uses a BACnet Discovery FSM module along with the BACnet R/W FSM.  The BACnet Discovery module stores the binary property data in Keylists and includes device object property queries and iterators.

* Added callback from BACnet R/W FSM module for I-Am messages.

* Removed dependency in BACnet R/W FSM module on rpm_ack_decode_service_request() which uses calloc/free value lists.  Created an alternate RPM-ACK to RP-ACK processing function.

* Changed RPM handler to skip over unknown property values
2024-02-28 12:56:09 -06:00
Steve Karg 33c7df249a Feature/arbitrary apdu application (#580)
* Added application to send an arbitrary APDU string of hex-ASCII
2024-02-23 09:24:05 -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
Steve Karg 34b1d24bb7 Build/add cmake to ports at91sam7 (#560)
* added CMake to AT91SAM7S port example

* Add ports AT91SAM7S and STM32F4xx CMake builds into pipeline
2024-01-27 16:00:22 -06:00
Steve Karg 7f3b82db9a Fixed compilation with BACNET_SVC_SERVER=1 for apps. (#552)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2024-01-03 10:35:03 -06:00
Steve Karg 7bcaa61f36 Updated SLOC count doc. Added McCabe complexity to Makefile. 2023-12-11 10:01:35 -06:00
Steve Karg 2536d5a350 Fix BACnet/IP builds for BBMD clients without BBMD tables. (#523)
* Fix BACnet/IP builds for BBMD clients without BBMD tables.

* added BBMD=client to pipeline build

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-10-31 10:57:44 -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 0001f85f29 Bugfix/network port object link speeds (#488)
* fix ports/xplained build under Linux

* fix network port object link-speeds property

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-08 17:41:56 -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
anthony-crystalpeak fcc9647983 AFL + Libfuzzer harnesses (#455)
* Package fuzzers

* Provide ability to remove main

* Don't build fuzzers by default
2023-07-17 10:06:32 -05: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
Steve Karg 64d1461549 fix spelling errors 2022-10-29 12:28:21 -05:00
Steve Karg 1f41341c09 Feature/what is network number handling (#304)
* Add What-Is-Network-Number handling.

Add What-Is-Network-Number and Network-Number-Is network layer handling.
Refactor npdu_encode_npdu_network() from router specific code.
Add unit test for NDPU network message
Add app for What-Is-Network-Number
Add app for Network-Number-Is
Add send helper for What-Is-Network-Number
Add send helper for Network-Number-Is

* added sys/debug.c to ports builds for use of debug_printf() in npdu handler.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-07-14 15:34:45 -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
Steve Karg 85d3b72b36 Update Makefile to fix scan-build race condition 2022-04-25 20:37:35 -05:00
Steve Karg c9d42d268e Bugfix/fix splint warnings (#250)
* Fix SPLINT to perform static defect analysis

Fix the SPLINT invocation in Makefile
Fix C files where SPLINT detected problems.
Remove UCIX check from SPLINT
Use SPLINT friendly parsing code disable for bacsec

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-04-12 13:00:29 -05:00
Steve Karg 12a5e48b3e Bugfix/btl mstp local broadcast discard (#248)
* Discard Confirmed PDU DNER on local broadcast. Discard DER on local broacast.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-04-02 08:44:04 -05:00
Steve Karg 14e6ba3619 add splint Makefile target 2022-03-30 08:25:12 -05:00
Steve Karg 902949a192 update LwIP BACnet/IP abstraction (#246)
* update LwIP BACnet/IP abstraction. Integrate LwIP build with continuous integration.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-03-29 17:47:44 -05:00
Steve Karg 5b07b484d4 Bugfix/cppcheck error code fixes (#244)
* Add flawfinder. Add error code for exit status.

* fix errors found by cppcheck

* fix initialization warning in unit test compile

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-03-28 10:29:52 -05:00
Steve Karg c3a4c229fe Issue 87 execute tests with GitHub ci (#234)
* Enable lcov coverage in unit testing via cmake.

* fix pipeline build error

* add compile options for unit test to silence some warnings

* remove all BAC_TEST unit tests in src/bacnet/ folder. They are now in test/bacnet/ folders using ztest.

* removed key.c - only used for unit test.

* produce XML test result output for parsing

* produce junit XML test result output

* change lint workflow to quality

* update readme badge for quality results

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-02-28 20:09:46 -06:00