* linux/bip6: Use function over PRINTF macro
Our repo should be C89 compatibale. C89 does not support variac macros.
For this reason use variac functions. This also enables to print
different streams than just stderr.
Also now if something is changed in debug_fprintf it also affect here
which is good.
* Use __inline__ over inline in library
Use __inline__ over inline as that is C89/C90 combatible. With MSVC we
need to use __inline so just define __inline__ to it if not already.
* h_get_alarm_sum: Fix -Wself-assign compiler warning
We get Wself-assign if PRINT_ENABLED is 0
```
src/bacnet/basic/service/h_get_alarm_sum.c:129:16:
warning: explicitly assigning value of variable of type 'int' to itself
[-Wself-assign]
[build] 129 | bytes_sent = bytes_sent;
[build] | ~~~~~~~~~~ ^ ~~~~~~~~~~
```
---------
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>
* 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>
* 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 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 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).
* Added MSTP extended frame transmit to bacnet/datalink/mstp.c and ports/stm32f4xx/dlmstp.c modules.
* Changed RS485_Send_Frame to MSTP_Send_Frame in mstp.c
---------
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* Fixes#346 by binding the broadcast socket to the port specific broadcast address rather than INADDR_ANY or INADDR_BROADCAST. Added additional compile and environment options for those who might need them.
* Changed the define USE_CLASSADDR to BACNET_IP_BROADCAST_USE_CLASSADDR to help manage namespaces.
* Added BACNET_IP_BROADCAST_BIND_ADDR environment variable to override the default broadcast binding address.
---------
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* Enable extra GCC warnings to discover subtle bugs
* convert c++ comments to c comments
* cleanup pedantic compiler warnings
* Compile apps with GNU89 GNU99 GNU11 and GNU17
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* Added IPv6 Foreign Device Registration for apps
* Fix debug message in BACnet/IPv6 Linux port
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>
* BIP: add socket to listen to broadcast packets for Linux/Windows/BSD/Zephyr
* BIP: added BVLC broadcast handler to drop a packet when confirmed broadcast request is sent.
* https://sourceforge.net/p/bacnet/bugs/65/
* Added zeroing rx buffer remain
* Added zeroing rx buffer remain
* Added safety margin for the rx-buffer in the different ports.
* Added safety margin for the receive buffer.
* Added DoxyGen comments.
* Fixed checking return value when calculating distance between opening and closing tag on multiple properties.
* Added pretty-apps and pretty-ports make targets
* pretty-fied apps folder C files
* Pretty-fied ports folder C and H files
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* refactor BACnet/IPv4 BVLC into encode-decode library with unit tests
Added Read-Broadcast-Distribution-Table encoding and unit test.
Added Read-Broadcast-Distribution-Table-Ack encoding and unit test.
Added Read-Foreign-Device-Table-Ack encoding and unit test.
Added some BDT/FDT diff copy functions with unit tests
Added some FDT add and delete entry functions with unit tests
Added some BDT set append and clear entry functions with unit tests
Added some BIPv4 address conversion functions with unit tests
Added non-BBMD handling unit test
Added basic unit test for BBMD handler
Added BBMD broadcast mask get set and unit tests
Added IPv6 maintenance timer.
Added ReadFDT app
Fixed ReadBDT app
Added Who-Is to Makefile for individual app build
Fixed debugging code blocks projects by swapping bip.c for h_bbmd.c module.
Ported BACnet/IPv4 to refactored BVLC for Linux, BSD, Windows
Fix datalink debug for DLENV module
Improve BIPv4 linux driver debug info
Added BDT mask functions
Reduce debug info clutter in Who-Is app by using environment option
Fix TTL seconds upper bounds addition
Fix CIDR prefix calculation on Linux BIPv4.
Convert BSD BIPv4 to BVLCv4
Fix CMake build for BIPv4 (Linux, BSD, Windows)
Added [U]nsigned to 0xBAC0 constants
Cleanup POSIX and Win32 API sockets
Remove unnecessary file scope variable initialization
Fix routed NPDU to depend on datalink; fix warning
Remove OS dependent network code from gateway
Enable BBMD client in library by default
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
Co-authored-by: Steve Karg <steve.karg@legrand.us>
* fix BVLC6 Delete-Foreign-Device-Table-Entry
* Add unit test failure detection to Makefile report target
* Fix the IPv6 layers for sending PDU
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
* Add BAC_ROUTING compile definition
* Reorder cmake
* Fix OpenSSL support: support both 1.0 and 1.1t pus
* Explicitly export symbols, hidden by default
* Build shared libraries on travis using cmake
* Learn Makefile about static library
* Fix build using mingw with cmake
* Do not cleanup twice or after potential free
* feat: remove openssl dependency functions and add missing file to cmake
* chore: also build shared lib
* chore: also build shared for github ci
* chore: do not test shared libs in ci for the moment
* build: install cmake config files to enable cmake find_package
fix: destination for header files
build: clean up build system
build: also install port directory header files
build: fix name of header files
ci: add github actions
build: add bsd port
chore: fix typos
build: remove not deeded mstpsnap
ci: disable ctests as not corrently
ci: disable macos for the moment
build: print compiler versions in cmake
* build: do not build apps by default
* build: add missing slash
* build: add more options to cmake (#3)
* build: add more options to cmake
* chore: disable ipv6
* build: guard around apps for options
* build: fix link lib on windows