1173 Commits

Author SHA1 Message Date
Lukas Woodtli
e53d8b20f2 refactor: Clean up the code and make it more readable
Mainly introducing defines instead of using magic numbers.
2024-02-08 08:23:41 +01:00
Lukas Woodtli
ea4a1ca55b fix: Endianess poblem with writing extended options
There was a bug that was caused by casting a `size_t` (64 bit) to a
32 bit vlaue.
The fix also contains a small refactoring extracting code into a
function.
2024-02-08 08:23:41 +01:00
Lukas Woodtli
838dffb823 fix: undefined behavior with memmove
Passing a `NULL` pointer to `memmove` results in undefined behavior.
When serializing a message we check if a payload is available.
Otherwise we don't move the payload to the buffer.
2024-02-08 08:23:41 +01:00
Lukas Woodtli
ec4609e0d7 Adjust for renaming 'master' to 'main'
The 'master' branch was renamed to 'main' to reduce the use of harmful
language. Therefore, some scripts and descriptions were adjusted to the
new name of the default branch.
Words matter!
2024-01-30 17:46:14 +01:00
Marc Lasch
48af173787 ci: Fix SonarCloud Scan with outdated Java version
SonarCloud Scan does no longer support Java 11. Use
`sonarsource/sonarcloud-github-c-cpp` action to install sonarcloud and
the build-wrapper directly from the original vendor instead of a third
party.
2024-01-30 11:14:10 +01:00
Marc Lasch
4a49d40bc3 ci: Install build tools from apt package manager
Use apt to install cmake and ninja-build instead of using third party
Github actions.
2024-01-29 19:16:36 +01:00
Lukas Woodtli
b560c4924d testing: Fix functions with missing void argument
The `void` argument was present in the declaration but not in the
definition.
2024-01-25 14:38:11 +01:00
Marc Lasch
88f297fdbd data: Update CBOR floating-point serialization
Remove _Pragma directive responsible for silencing float-operation
warnings. Use standard library floating-point functions. Add tests to
test CBOR float conversions when float16 is disabled by
CBOR_NO_FLOAT16_ENCODING compile time switch.

Add CBOR_NO_FLOAT16_ENCODING to
"lwm2munittests_server_formats_no_float16" test variant.
2024-01-20 19:37:28 +01:00
Lukas Woodtli
f984970d14 ci: Fix SonarCloud
The output of the sonar build wrapper was
overwritten when the tests where ran with
the wrapper. The wrapper is needed during
the build. But not for running the tests.
2023-11-27 17:45:04 +01:00
Lukas Woodtli
2df38062d0 testing: Add test executables for different configurations
The same tests are compiled with different defines to make sure
that combinations of different configurations work properly.
2023-11-21 14:56:21 +01:00
Lukas Woodtli
dd586168cf testing: Fix undefined behavior with logging
In some cases a random byte pattern was interpreted as a
boolean type. This happend when the conversion to a bool
was not successful but its value was logged anyway.
2023-11-21 14:56:21 +01:00
Lukas Woodtli
33ecee2fe2 testing: Exclude registration tests if not testing server
The registration code is disabled at compile time if we do
not set the define for building a server.
2023-11-21 14:56:21 +01:00
Lukas Woodtli
2d5ac1366c ci: Fix building and running with sanitizers
The sanitizers need to be activated at configuration time
of the CMake project. Not when executing the build command.
2023-11-21 10:24:50 +01:00
Lukas Woodtli
f3d931d73f Fix sanitizer issues
For some standard library functions (memcpy, memcmp ...) it's not
allowed to pass NULL-pointers as arguments. Therefore the pointers
are now checked before passing.
2023-11-21 10:24:50 +01:00
Lukas Woodtli
44582f0cfb ci: Pin version of gitlint
Older versions of `gitlint` don't know the configuration
option `regex-style-search` that we require.
2023-11-21 10:24:30 +01:00
Lukas Woodtli
6d5ef40129 ci: Fail if cmake-format finds problem
If cmake-format found an error it was silently
dropped in CI. Now the `run_ci.sh` scripts returns
an error in case of failure.
2023-11-21 10:24:06 +01:00
Nathanaël Semhoun
4a85dde1ff Fix query queue mode len test
When the query is QUERY_QUEUE_MODE test of the len is compared with
QUERY_BINDING_LEN and not QUERY_QUEUE_MODE_LEN.

It's like an erronous copy/paste.
2023-11-17 13:03:25 +01:00
Marc Lasch
36974fc83e cmake: Remove git submodule custom commands from build system
This change prevents cmake to modify the tinydtls submodule. This also
prevents that the tinydtls sources are marked with the GENERATED source
file propery. This had the consequence that the source were deleted when
cleaning the build directory.
2023-11-13 09:28:38 +01:00
Lukas Woodtli
676c520509 Improve logging in CBOR code
Add capability to log data types to improve logging in CBOR code.
2023-11-09 16:25:37 +01:00
Marc Lasch
27ab8059ff Fix signed integer comparison warnings
This will silence -Wsign-compare warnings.
2023-11-09 16:25:37 +01:00
Marc Lasch
c70c6a90d4 Refactor CBOR value parsing
Convert endianness to also support big-endian systems.
2023-11-09 16:25:37 +01:00
Marc Lasch
d0e3e6fff6 Enforce strict aliasing with type punning in SenML-CBOR
With -Wstrict-aliasing enforced, simple type casting between different
lvalue is not allowed.
2023-11-09 16:25:37 +01:00
Marc Lasch
0d2507fb19 Silence -Wfloat-equal warnings
Silence the existing, benign looking code, but ensure we get a warning
for new code with such issues.
2023-11-09 16:25:37 +01:00
Pascal Brogle
aa1269cbc3 feat: add support to disable cbor float16 encoding
because zephyr does not support float16
2023-11-09 16:25:37 +01:00
Marc Lasch
1c6197d55a refactor: Enforce prototypes on functions
With -Wstrict-prototypes enforced, all functions need a prototype.
2023-11-09 16:25:37 +01:00
Marc Lasch
38fe6868aa Modifiy the SenML-CBOR contribution to comply with project formatting
This change only contains cosmetic changes to comply with the current
code format style for the SenML-CBOR contribution enforced by
clang-format and cmake-format.
2023-11-09 16:25:37 +01:00
Scott Bertin
d962a1c919 Add support for SenML-CBOR
This commit contains the contribution from Scott Bertin to support
SenML-CBOR with only changes resolving conflicts.

Signed-off-by: Scott Bertin <sbertin@telular.com>
Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2023-11-09 16:25:37 +01:00
Lukas Woodtli
33a7f2d032 tests: Adjustments for macOS
CMake: find and use the CUnit library also on macOS.
Also document development requirements for macOS.
2023-11-03 07:51:08 +01:00
Lukas Woodtli
bebde1d133 Allow registration message without Resource Type
Registration messages without `rt="oma.lwm2m"` should be
accepted as valid request.
2023-11-02 11:51:25 +01:00
Parminder Singh
4fcb0b55dc Fix memory leak when registration fails
registration_data_t is not freed if the server does not respond to the
connection message or the user decides to quit the (Wakaama) client
before the server respond.

This fixes #693.
2023-10-16 08:08:13 +02:00
Lukas Woodtli
f4bf6394fe ci: Fix the collection of coverage information
Informations from the source files were missing in the coverage
report. Therefore `gcovr` is started from the root directory
of the project.
2023-09-26 09:53:45 +02:00
Parminder Singh
54249b55cc Implement client side send operation
Implemented send operation for client side, send operation was
introduced with the LwM2M 1.1 standard.
This PR is based on work from @sbertin-telular, specifically on
send branch: https://github.com/sbertin-telular/wakaama/tree/send
In this PR a bug that caused a memory leak has been fixed:
https://github.com/sbertin-telular/wakaama/pull/1
2023-09-01 20:51:38 +02:00
Marc Lasch
4bad452a39 license: Update license files for Github to detect it
Rename EPL-2 license file and replace EDL-1 with BSD-3-Clause.
2023-08-17 11:39:06 +02:00
Parminder Singh
9433484c24 Use lwm2m_seed() to get the seed
The lwm2m_seed() function is used to obtain a seed for random number
generation.
The implementation of the lwm2m_seed() function is up to the user.
2023-08-16 08:23:12 +02:00
raiden00pl
bf81d0827b examples: use getline() to read commands
The previous approach works only if the terminal is operating in cannonical mode
(input available line-by-line), which is not always true.
getline() ensures that commands are always read correctly.
2023-08-08 08:36:21 +02:00
Marc Lasch
d45b4e3085 ci: Replace outdated codeql actions
Replaces the version v1 of the CodeQL Action which was deprecated on
January 18th, 2023, and is no longer updated or supported. More information:
https://github.blog/changelog/2023-01-18-code-scanning-codeql-action-v1-is-now-deprecated/

gitlint-ignore: all
2023-07-27 13:08:20 +02:00
Parminder Singh
08530a7265 Made uri_toString(...) public
Made the uri_toString(...) function public and renamed it to
lwm2m_uriToString(...)
2023-07-27 08:45:59 +02:00
607qwq
514659414c avoid mac make error 2023-05-31 15:34:05 +02:00
Marc Lasch
8d1a7139f1 Make cmake projects in sub-directories directly buildable
With this change, cmake projects in sub-directories can be built
individually from their CMakeLists.txt.
2023-05-31 11:35:22 +02:00
Lukas Woodtli
94506859ad Add tests for lwm2m_list
Added some basic unit tests for the linked list implementation.
2023-04-21 11:14:12 +02:00
Reto Schneider
1166233821 Make clang-format happy
Adapting changed lines:

```
git clang-format-14 --style=file master
```
snapshots/2023-03-31
2023-03-31 16:12:13 +02:00
Reto Schneider
6b3b347bc5 Break compilation on warning
Turn (almost) all warnings into errors to ensure no new warnings enter
the code base.

-Wcast-align is not an error because fixing the findings requires a bit
more work than what I am willing to do right now and the tinydtls yields
some findings.
2023-03-31 16:12:13 +02:00
Reto Schneider
f2ff386d0e Work around -Wsign-compare
Using difftime() might be more clean, but uses doubles instead of
integers.
2023-03-31 16:12:13 +02:00
Reto Schneider
893f814d53 Disable -Wcast-align for tinydtls
This is code not (directly) under our control.
2023-03-31 16:12:13 +02:00
Reto Schneider
d3ed35390a Avoid fase positives by -Wmaybe-uninitialized
2 out of 2 cases are false positives.
2023-03-31 16:12:13 +02:00
Reto Schneider
4607aafcd4 Silence -Wunused-parameter
-Wunused-parameter yields the majority of the warnings. Ignoring it (for now)
makes other, more relevant warnings better visible.
2023-03-31 16:12:13 +02:00
Reto Schneider
89f8801777 Silence -Wfloat-equal
Silence the existing, benign looking code, but ensure we get a warning
for new code with such issues.
2023-03-31 16:12:13 +02:00
Reto Schneider
182c5825ca Fix format strings
No longer rely on unportable formatting strings.
2023-03-31 16:12:13 +02:00
Reto Schneider
7d468002e0 Fix -Wsign-compare
Fix and enforce absence of such issues.
2023-03-31 16:12:13 +02:00
Reto Schneider
6d268c804a Fix -Wswitch-default
Fix and enforce absence of such issues.
2023-03-31 16:12:13 +02:00