* clang-format: Ignore javascript files
Ignore javascript files. Clang-format is not very good formatter for
javascript files anyway. If we ever need javascript formatter we should
use Prettier.
* clang-format: Ignore some lines in sources
Couple things get formatted really funky if we let clang-format format
those. Just ignore those locally.
* zephyr/tescase.yaml: Fix yaml syntax
pre-commit hook check-yaml did found out that there are two skips.
Remove another as this is not right syntax.
* Fix repo contains unicode replacement chars
When running pre-commit text-unicode-replacement-char it founds that
there is couple unicode replacemnt chars. Remove and replace these.
* Convert some tabs to spaces manually
We will soon auto format tabs to spaces. How ever it could not do couple
thing so fix those by hand first.
* Make files with shebang executables
It is good habit that if file has shebang then it is marked executable.
These where found with pre-commit check-shebang-scripts-are-executable
checker.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
* ci: Fix compile warning as errors was not correct
We want to enable warning as errors both Windows and Linux. This is
easiest to do with cmake option as -Werror does not work with MSVC. Also
it is self explaining what it does so no comment needed.
* dlmstp_linux: Fix -Wdeclaration-after-statement compiler warnings
Make dlmstp_linux C89/C90 combatible
```
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘Timer_Silence’:
/bacnet-stack/ports/linux/dlmstp_linux.c:56:5: warning:
ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
56 | int32_t res;
| ^~~~~~~
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘dlmstp_init’:
/bacnet-stack/ports/linux/dlmstp_linux.c:795:5: warning:
ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
795 | struct termios newtio;
| ^~~~~~
```
* Fix warnings produces by MSVC
Now that we have enabled /Wall for MSVC we get some warnings with it
which can be easily fixed.
We get following warnings:
```
src\bacnet\bacstr.c(223,39): warning C4127: conditional expression is constant
apps\router-mstp\main.c(1123,1): warning C4702: unreachable code
apps\epics\main.c(885,53): warning C4459: declaration of 'myState' hides global declaration
```
* cmake: Use /Wall with MSVC
Make MSVC to build cleanly with Wall. This might matter for some Windows
developers. And you never know if MSVC will find more bugs.
* cmake: Improve router build
Router build gives some warnings as it is not C90 compatible. It is ok
that example is not following C90 rules. Also it is annoing to new user
to build this cmake as first error usually is that libconfig is not
found. Let's just give warning about this so first build will usually go
smoother.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
* bacint: Do not use ULL suffix
For sake of be more compatible with C89/C90 let's not use ULL at all.
Overall conversion functions are lot cleaner now. Only idiotic thing is
in bacnet_unsigned_length() where we need to do shift. There is probably
better way to do that but could not come up any at resonable time.
* Force C89/C90 and for tests C99
bacnet-stack seems to be all compatible with C89/C90. This is probably
design choice. Let's force this in CMake so no one will break that by
accident.
In tests we are using some C99 features already. Let's not be to strict
about those as those are "just tests".
* Fix -Wdeclaration-after-statement warnings
To make code C89/C90 compatible fix -Wdeclaration-after-statement
warnings.
We got like following warning without this change.
```C
bacnet-stack/apps/epics/main.c:293:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement
293 | uint32_t Object_Instance;
| ^~~~~~~~
```
* cmake: Add -Wno-c99-extensions compiler option
Clang does not like _Bool which is used in stdbool.h files. For now
let's just ignore this. We could define that differently but let's think
that another time. Now goal is to get warning free CI with more code to
be builded in there.
* cmake: Add -Wno-long-long compiler option for apple
Apple seems to do stupid things with their system header. There is
UINT64_MAX with ULL suffix and not like in Linux and Windows
__UINT64_C(18446744073709551615)
For this reason we need to ignore Wlong-long for it.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
* 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>
* 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.
* Improved GCC compiler flags in ARM, OS, and test builds. Removed redundant flags, and made them consistent across various builds.
* Fixed redundant redeclaration of various functions detected by change in compiler flags.
* Fixed string truncation warning in bip-init detected by change in compiler flags.
* Fixed some set-but-not-used variables by creating dummy functions instead of using macros.
* 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
* 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
* 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.
* 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.
* 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
* 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>
* 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>
Fixed CMakeLists.txt: to exclude h_routed_npdu.c when BAC_ROUTING=OFF
When calling cmake with -DBAC_ROUTING=OFF,
basic/object/gateway/gw_device.c is correctly excluded from the build.
It does contain however the definition for the functions
Routed_Device_GetNext and Routed_Device_Is_Valid_Network, both of which
are called in the routed_apdu_handler function of basic/npdu/h_routed_npdu.c.
This is fine during compilation since these functions' prototypes are
declared in basic/object/device.h but linking will fail.
Thus, make the compilation of h_routed_npdu.c conditional depending on
the value of BAC_ROUTING.
Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr>
Co-authored-by: Sebastian Weyer <sebastian.weyer@smile.fr>
* 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
* 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>
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>
* 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>
* 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
* Fix code to be able to compile with older C89 ANSI compilers
* Convert C++ comments to C89 comments.
* default to std=gnu89
* Fix to enable CMake 3.1 to build on Centos7
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* Fix warnings found by splint
* Ignore Win32 Builder warnings about possible data loss for integers.
* Fix Windows build warnings
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* 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>
* 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>
* 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>
* 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>
* added COBS encode and decode from BACnet standard
* Add unit tests for COBS encoding and decoding
* Improve COBS unit test and API.
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* 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>
* Added alarm-ack application
* fix error and simple ack handling for event notification
* Added ack-alarm application
* Update CMake for ack-alarm
* update example objects for alarm and events
* Allow repeated ack-alarm for same transition
* add event state API. Fix COV event state.
* add event state API to AV. Fix COV event state.
* Use event time for ack notification
* Enable notifications for all transitions by default. For testing.
* Use unconfirmed device notification to 4194303 for testing.
* initialize local vars
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>