Commit Graph

160 Commits

Author SHA1 Message Date
Steve Karg 62bf8274f7 Fixed missing exports in bacnet/basic header files. (#996)
* Fixed missing exports in bacnet/basic header files.

* Refactor uBASIC for unique namespace and project define overrides.
2025-05-19 13:44:52 -05:00
Steve Karg 1a7d823959 Added the weekly-schedule property write in basic schedule object. (#990) 2025-05-08 08:15:16 -05:00
Steve Karg 0f3cbe3ec5 Fixed WriteProperty bypass which is only for present-value property of commandable objects. (#984) 2025-05-05 21:48:29 -05:00
Steve Karg 54bf9b79c6 Added uBASIC-Plus program object example to STM32F4xx. (#967) 2025-04-16 12:03:42 -05:00
Steve Karg d7c86af05a Added Program object task state transitions from request and callbacks (#960) 2025-04-09 10:41:27 -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 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 4df896b820 Feature/basic-program-object (#940)
* Added basic Program object and unit test.

* Integrate the basic Program object with example applications.
2025-03-13 15:51:37 -05:00
Steve Karg 4ee129e249 Added bypass in basic WriteProperty handler to accept writes of NULL to non-commandable properties (#919) 2025-03-10 07:30:55 -05:00
Steve Karg 7e725ce028 Bugfix/win32 build warnings (#936)
* Changed win32 port of localtime to use secure OS API functions when compiled with MSVC

* Changed all the sprintf to use snprintf instead in BSC tests to ensure null string endings.
2025-03-03 10:32:28 -06: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 aa87bd8051 Bugfix/ipv6 leave multicast on foreign device registration (#899)
* Fixed IPv6 handler to ignore original-broadcast when registered as a foreign-device

* Fixed IPv6 to leave multicast when registering as foreign device.
2025-02-17 09:07:27 -06:00
Steve Karg ae135cd368 Bugfix/property list consistency testing (#910)
* 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.
2025-02-12 12:14:01 -06:00
Steve Karg bc2438f85b Fixed structured view object subtype get and set. (#909) 2025-02-10 09:56:52 -06:00
Steve Karg 66329a05a0 Bugfix/property array element zero size (#908)
* 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.
2025-02-10 09:44:53 -06:00
Steve Karg 77bdaaf853 Fixed usage of 8-bit modulo operator off-by-one maximum. (#901) 2025-02-04 13:56:53 -06:00
Steve Karg 19ef7f74cd Added MS/TP automatic baudrate detection option into the core MS/TP state machine. (#900) 2025-02-03 15:10:31 -06:00
Steve Karg 44c2bccdeb Added linked list of lighting-command notification callbacks, (#893) 2025-01-21 14:30:38 -06:00
Steve Karg ece31443b6 Secured SubscribeCOVProperty decoder. (#892)
* Secured SubscribeCOVProperty decoder.

* Changed datatype of monitoredProperty in struct BACnet_Subscribe_COV_Data
2025-01-09 14:27:39 -06:00
Steve Karg 6806cc3bb7 Fixed CharacterString Value object name default and reverted API chan… (#888) 2025-01-06 11:40:03 -06:00
Tomasz Kazimierz Motyl 2ba59abbf8 Added DeleteObject and Cleanup support to basic CharacterString object (#886) 2025-01-06 08:20:49 -06:00
Steve Karg 94b3809a58 Bugfix/confirmed handlers empty service request (#885)
* 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
2025-01-05 10:09:39 -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 11682ca484 Removed use of 'class' keyword as a variable in BACnet/SC (#872) 2024-12-10 13:46:03 -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 001b69cbd8 Fixed dlmstp ringbuffer initialization corruption (#865)
* 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.
2024-12-02 07:32:57 -06:00
Steve Karg fd3be47d86 Feature/date time mstimer clock (#861)
* 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.
2024-11-24 11:20:25 -06:00
Steve Karg cdda524afc Added Time-Of-Device-Restart property to example device. (#860)
* 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.
2024-11-22 19:14:09 -06:00
Steve Karg 1375347ab6 Added bacnet_strnlen and bacnet_stricmp to avoid libc compiler problems (#857)
* Added bacnet_strnlen and bacnet_stricmp to avoid libc compiler problems

* FIxed compiler warnings in printf conversions.
2024-11-21 06:43:37 -06:00
Steve Karg 51c915a5da Bugfix/lighting output dimming refactor (#855)
* Refactored lighting command operations from the lighting output object, and added unit testing. Integrated the result back into lighting-output object.
2024-11-13 15:24:25 -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 6bc74a8967 Added unit testing for FIFO peek feature. (#839) 2024-10-29 19:50:41 -05:00
Steve Karg a38cc531d2 Added WriteProperty setter for BACnet Unsigned Integer values. (#834) 2024-10-29 13:17:39 -05:00
Steve Karg 3329dff337 Added WriteGroup service and Channel object interfaces (#829) 2024-10-25 10:43:29 -05:00
Steve Karg 3eab5490c5 Added common property test for BACnetARRAY (#828) 2024-10-24 15:48:00 -05:00
Steve Karg dcf79b038f Enabled BACnetARRAY checking when using proplist.c and added to apps/epics (#823) 2024-10-23 13:54:48 -05:00
Steve Karg c3cb72bc41 Fixed BACNET_APPLICATION_DATA_VALUE declarations to be initialized so that the next pointer is NULL by default. (#814) 2024-10-18 07:43:39 -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
Steve Karg 7b18add6d3 Issues/issue 787 app bacepics misses optional parameters for the device object (#789)
* Added some optional properties into the object property lists up to protocol-revision 22

* Added serial-number property to basic device object example.
2024-09-27 16:22:58 -05:00
Steve Karg b7d03fd415 Added unit test for BACnetAccessRule 2024-09-02 09:18:47 -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
Kari Argillander a2f1d6959d Make most of functions const correct (#714)
* 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>
2024-08-29 14:08:02 -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 c1195dd8a0 Added CreateObject, DeleteObject, and COV to Integer Value object (#719)
Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-08-14 08:54:03 -05:00
Kari Argillander 6271632944 Add and fix compiler warnings (#718)
* Add and remove compiler warning compile options

Add some new compiler warnings. Some of those does not build clean so
ignore them for now. This also helps if some user use those options so
we ignore those for them also.

Also remove following ignores as they do not produce any warnings:

  - Wno-attributes
  - Wno-long-long
  - Wno-implicit-fallthrough

* Fix -Wmissing-declarations compiler warnings

Fix new -Wmissing-declarations compiler warnings. I tried to look which
should be in headers and which should be static. Might be that some
statics should be in header as it is not easy to choose if something
should be exported or not.

* Fix -Wmissing-field-initializers compiler warnings

If we use { { 0 } } compiler thinks we might have mean that we only
meant initialize first member of struct or have forgotton to add second
one. We could do { { 0 }, 0 } but we can just do { 0 } which tells
compiler that hey just intialize this whole thing to zero.

* tests: Fix couple -Wfloat-conversion warnings

Add f prefix to floating point numbers to get some double to float
warnings away.

* ci: Make warnings as errors with cmake main build

To keep repo more clean from warnings use Werror flag when building main
project.

Windows should need -DCMAKE_C_FLAGS="/WX" but we have not ignore errors
for that yet so let's not yet take it in use.

* ci: Build also tests in matrix build

Enable also tests to be builded in our main matrix build. This way tests
will be builded also with clang and in future also with MSVC. We also
keep build very clean now as all warnings as catched.

With this we can also take out -Werror from compile_options as we add
that in CI. It is not good practice to keep that option always on. It
makes development lot harder. See example this blog post [1].

[1]: https://embeddedartistry.com/blog/2017/05/22/werror-is-not-your-friend/

* getevent: Deprecate getevent_encode_apdu()

Steve suggested that we should deprecate getevent_encode_apdu() [1].

Suggested-by: Steve Karg

[1]: https://github.com/bacnet-stack/bacnet-stack/pull/718#discussion_r1715821735

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-13 16:32:44 -05:00
Kari Argillander cb243c36a8 Improve SPDX identifier coverage (#716)
* Change MIT license texts to SPDX-License-Identifier

SPDX-License-Identifier is much easier to understand and grep than
license text so use that instead.

* Change GPL exception license texts to SPDX-License-Identifier

SPDX-License-Identifier is much easier to understand and grep than
license text so use that instead.

* Change misc license texts to SPDX-License-Identifier

There are some external code in repo which are not licenses as most of
the stuff in this repo. We still want every file to have SPDX identifier
to easily grep licenses.

* Add currently used license files

Even though Bacnet-Stack is using SPDX identifiers we still need to give
those license files with source. For this reason add all license files
to license/ folder.

SPDX has also files which would make same thing but this is style which
example Linux kernel is using and it is quite clear so I choose that one
for now.

I choosed not yet bring CC-PDDC as that is not right license for those
files.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-12 15:33:02 -05:00
Steve Karg e5307e280c Added CreateObject and DeleteObject to Load Control object. (#713) 2024-08-11 19:14:27 -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 350bbe3331 Fixed implicit conversion from float to double in lighting output and color. 2024-08-06 17:22:27 -05:00