Commit Graph

304 Commits

Author SHA1 Message Date
Tomasz Kazimierz Motyl 4add49b549 Setting logic behind valit transitions check straight (#623)
Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-04-22 08:18:16 -05:00
antocout 6e31a01086 fix build with readable objects (#622)
When building the stack with readable objects, the
My_Read_Property_Multiple_Ack_Handler function defined in
src/bacnet/basic/client/bac-rw.c calls rpm_ack_object_property_process
which is defined in src/bacnet/rpm.h but unreachable without
BACNET_STACK_EXPORT.

How to reproduce the bug:

$ mkdir build
$ cd build/
$ cmake -DCMAKE_C_FLAGS="-DMAX_ANALOG_INPUTS=100"  ..
$ make
...
[ 81%] Linking C executable bacpoll
/usr/bin/ld: CMakeFiles/bacpoll.dir/src/bacnet/basic/client/bac-rw.c.o: in function `My_Read_Property_Multiple_Ack_Handler':
bac-rw.c:(.text+0x188): undefined reference to `rpm_ack_object_property_process'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/bacpoll.dir/build.make:146: bacpoll] Error 1
make[1]: *** [CMakeFiles/Makefile2:523: CMakeFiles/bacpoll.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Signed-off-by: Antoine Coutant <antoine.coutant@smile.fr>
2024-04-22 08:17:19 -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
antocout 600508c357 Change first instance of an integer value from 1 to 0 (#619)
Integer_Values instances start at 1 while other object instances
start at 0. Change this to have the same start for all objects.

Signed-off-by: Antoine Coutant <antoine.coutant@smile.fr>
2024-04-17 08:53:12 -05:00
Steve Karg aca3a2bc82 Fixed basic network port object header dependency on readrange.h file. 2024-04-05 13:17:35 -05:00
Steve Karg e19cc0be1e Added API for multistate number-of-states 2024-04-04 17:09:51 -05:00
Steve Karg 5abdaf0916 Fixed binary object active and inactive text setting. 2024-04-04 13:04:02 -05:00
Steve Karg f3b1ea0ab9 Added reliability, active-text, inactive-text to binary-input object ReadProperty. 2024-04-04 12:35:52 -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 d1f92cbb8f Change time-value object present-value to not report current time. Added out-of-service property to WriteProperty. 2024-04-04 11:33:54 -05:00
Steve Karg 41c11b23d3 Bugfix/basic object features cleanup (#614)
* Fixed compile warnings in basic objects

* Added API for setting multi state text with null-terminated name lists in basic objects
2024-04-03 16:57:36 -05:00
Steve Karg 7520930dc1 fixed life safety zone default object name (#613) 2024-04-03 16:47:46 -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 8a0a01c0fa Release/version 1.3.5 rc1 (#611)
* Updated to version 1.3.5 for release on 2024-04-01 April Fool's Day!
2024-04-01 16:39:10 -05:00
Steve Karg adf6b5f1fb Bugfix/zephyr defines kconfig (#610)
* Added COV features to time-value object

* Added zephyr config names with BACNET prefix
2024-04-01 13:58:37 -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 4e0a37fd75 Fix double promotion in format specifier %f by casting floats to double. (#608) 2024-03-26 15:23:49 -05:00
Steve Karg f6c6fe87c5 Completed the implementation of object-instance and object index differentiation object/basic/ai.c module. Thanks, GauiStori! (#607) 2024-03-26 14:51:39 -05:00
Steve Karg a4910d4117 Bugfix/zephyr build for minimal ram (#606)
* Removed BACnet objects from ports/zephyr. There should only be datalink and OS related interfaces in OS ports.

* Added Kconfig and bacnet-config.h options in ports/zephyr to keep small footprint for MCUs having less RAM

* Changed ports/zephry for BACnet/IP and date-time with latest zephyr OS
2024-03-26 14:21:30 -05:00
Steve Karg 80c51a06e3 Secured the WPM and RPM service encoders (#604)
* Secured the WPM and RPM client service encoders.

* Fixed RPM and WPM apps when fail to encode request. 

* Fixed WPM app number of arguments checking.
2024-03-26 12:29:15 -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
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 4e94323619 Updated changelog and version for 1.3.4 release (#589) 2024-03-02 07:31:37 -06:00
Steve Karg 5c55683f86 Fixed makefile for building the Linux router application. (#585)
* Fixed Makefile for building the Linux router application.
2024-02-28 17:08:00 -06: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 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 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
Sebastian Weyer d43d818400 Add missing binary input functions (#574)
* bi.c: add possibility to set custom object names

Add an array of MAX_BINARY_INPUTS values containing the custom object
names.

When calling Binary_Input_Object_Name, if no custom name has been set,
return a string with the object type and the object instance number.
Otherwise, return the custom object name.

When setting the object name, first check that the string is not NULL,
then set the name in the new array.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* bi.c: add possibility to set custom description

Implement functions Binary_Input_Description and
Binary_Input_Description_Set. Binary_Input_Description will return an
empty string if no custom description has been set yet.

In order to store the custom descriptions, we declare a new array with
MAX_BINARY_INPUTS amount of values.

When setting a new description using Binary_Input_Description_Set, we
first check that the new description is not NULL and then store it in
array at the object_instance position.

In the Binary_Input_Read_Property function, we need to split
PROP_DESCRIPTION from PROP_OBJECT_NAME in the switch case as before the
object name would be returned when the description was being read by a
client. Now we properly call Binary_Input_Description.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

---------

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
Co-authored-by: Sebastian Weyer <sebastian.weyer@smile.fr>
2024-02-16 12:07:28 -06:00
Sebastian Weyer 20b969d26b ao.c: set proper bounds for Analog_Output_Present_Value_Set and Analog_Output_Present_Value_Write (#575)
* ao.c: set proper bounds for Analog_Output_Present_Value_Write

The lower and upper bounds to the value passed to this function were
hard-coded to 0 and 100 respectively. This meant that a client was not
able to write a value outside of these bounds, regardless of the values
of `Min_Pres_Value` and `Max_Pres_Value`.

Now properly compare the new value against `Min_Pres_Value` and
`Max_Pres_Value` and only return `ERROR_CODE_VALUE_OUT_OF_RANGE` when it
is outside of this range.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* ao.c: make Analog_Output_Present_Value_Set return 0 when out of range

Compare the new value passsed to `Analog_Output_Present_Value_Set`
against `Min_Pres_Value` and `Max_Pres_Value`. If the new value is
outside of these bounds, don't update the present value and return false.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

---------

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
Co-authored-by: Sebastian Weyer <sebastian.weyer@smile.fr>
2024-02-16 12:06:40 -06:00
Steve Karg 89fa3cea77 Fixed the Network Port object subnet mask for IP example. (#573) 2024-02-13 14:15:59 -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 58c19ebd2a fix function header comment 2024-02-08 14:55:33 -06:00
Steve Karg 851d10bc02 Move some platform compile fixes into platform.h file 2024-02-08 14:54:17 -06:00
Sebastian Weyer 46d686a8ab Add missing object functions to analog inputs and values (#568)
* ai.c: add possibility to set a custom object name

The Name_Set function is already declared in the header but not
implemented. With this implementation, one can set a custom object name
from a server application.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* av.c: add possibility to set a custom object name

The Name_Set function is already declared in the header but not
implemented. With this implementation, one can set a custom object name
from a server application.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* ai.c: implement function to set custom description

For now the hard-coded behaviour was to return the object name whenever
a client requested the value for the description.

Therefore implement the functions Description and Description_Set already
declared in the header and add a Description property to the data
structure used. We also need to properly implement PROP_DESCRIPTION in
the Read_Property function.

This way we can set and read a custom decsription from a server application
and send the appropriate response to a read-property request asking for
PROP_DESCRIPTION.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* av.c: implement function to set custom description

For now the hard-coded behaviour was to return the object name whenever
a client requested the value for the description.

Therefore implement the functions Description and Description_Set already
declared in the header and add a Description property to the data
structure used. We also need to properly implement PROP_DESCRIPTION in
the Read_Property function.

This way we can set and read a custom decsription from a server application
and send the appropriate response to a read-property request asking for
PROP_DESCRIPTION.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* ai.c: implement function to set custom units

Implement the object functions related to Units already declared in the
header.

By default Analog Inputs will have the Unit UNITS_PERCENT. Add
functionality to be able to set and read custom units from a server
application.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

* av.c: implement function to set custom units

Implement the object functions related to Units already declared in the
header.

By default Analog Values will have the Unit UNITS_NO_UNIT. Add
functionality to be able to set and read custom units from a server
application.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>

---------

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
Co-authored-by: Sebastian Weyer <sebastian.weyer@smile.fr>
2024-02-05 11:32:02 -06:00
Steve Karg f326b1347f fix compile warnings 2024-02-03 08:02:44 -06:00
Steve Karg d9fe85eee1 Updated version to 1.3.3 on 2024-02-02. Groundhog day! 2024-02-02 16:40:06 -06:00
Steve Karg 1fa0f2a766 Added bacapp decoding for accumulator SCALE property (#566) 2024-02-02 11:18:57 -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
Sebastian Weyer 5924c0c6ab ao.h: add BACNET_STACK_EXPORT macro to Analog_Output_Read_Property function (#561)
* Fixed BACNET_STACK_EXPORT macro to Analog_Output_Read_Property function

Added the call to this macro so that Analog_Output_Read_Property is
properly exported as a global symbol when the library is compiled with
-DBUILD_SHARED_LIBS=ON using cmake. This macro expands to
__declspec(dllexport) on Windows and __attribute__((visibility("default")))
on Linux. It is necessary when compiling with the -fvisibility-hidden flag.

Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
Co-authored-by: Sebastian Weyer <sebastian.weyer@smile.fr>
2024-01-29 10:43:16 -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 ef762118a6 Chore/refactor dlmstp core mstp (#559)
* Create common DLMSTP using core MSTP FSM in STM32F4xx example

* add openocd debug launcher under vscode in STM32F4xx example

* Add generic property list member checking for write property members of network port object in STM32F4xx example
2024-01-27 15:16:42 -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 c7c2e1c6ef Fix enumerations syntax 2024-01-05 17:12:59 -06:00