1173 Commits

Author SHA1 Message Date
Lukas Woodtli
47d9f73e60 Extract small function to set up resources in client example
This removes a small duplication of the code.
2024-09-23 16:56:08 +02:00
Lukas Woodtli
6c5d5820a6 Extract loop for getting all resource values
The loop is put in an own function for maintainability reasons.
2024-09-23 16:56:08 +02:00
Lukas Woodtli
8feb7be20d Reduce code duplication in client example
Some parts of the code were copy-and-pasted several times.
2024-09-23 16:56:08 +02:00
Lukas Woodtli
3f54642dba Remove code duplication in client example
A lot of code was copy-and-pasted several times.
2024-09-23 16:56:08 +02:00
Lukas Woodtli
29677349d8 tests: Add test for lists
The test is checking that counting the length of a list is done
properly.
2024-09-23 13:11:11 +02:00
Lukas Woodtli
7d3a1e767a lwm2mserver: Clean up list functions
Each function for list manipulations is wrapped in a macro. This makes
the code more consistent.
2024-09-23 13:11:11 +02:00
Lukas Woodtli
6f7c77a3e7 Add function for counting length of list
The function returns the number of node in the list.
2024-09-23 13:11:11 +02:00
Lukas Woodtli
c8d76edf8a cmake: Allow setting CLI library from CMake
Wakaama provides a simple command-line interface library that can be
used together with the library. It is used in the examples.
2024-09-03 10:53:36 +02:00
Lukas Woodtli
b15e2f81e0 cmake: Allow setting platform abstraction layer from CMake
Wakaama provides a layer for the POSIX platform. If it is not suitable a
custom layer needs to be provided by the user of the library.
2024-09-03 10:53:36 +02:00
Lukas Woodtli
96ac07b24a cmake: Require version 3.21
CMake 3.21 does not remove a normal variable if a cache variable of the
same name is set. This is the CMake policy CMP0126.
2024-09-03 10:53:36 +02:00
Lukas Woodtli
0c811ae3ed cmake: Extract connection for testing in library
The testing implementation of the transport layer is extracted in an own
object library and linked directly to the unit tests.
Also other needed libraries (CLI and platform) are directly linked to
the testing executable.
The possibility to select the testing transport layer from CMake is
removed. This special transport layer implementation is meant to be used
only in the unit tests internally.:X
2024-08-28 15:16:01 +02:00
Lukas Woodtli
03e2a63fb8 tests: Clean up test variants
We use now CMake presets for testing different configurations. Therefore
the CMake code for test variants is not needed anymore.
2024-08-28 15:16:01 +02:00
Lukas Woodtli
1d6dfdebb0 tests: Add more CMake presets to test multiple configuration
To enable the tests for different combinations of configuration options
we rely on CMake presets. Previously these combinations were handled in
the CMake project.
2024-08-28 15:16:01 +02:00
Lukas Woodtli
c997c59ea2 ci: Improve running tests and collecting coverage in CI script
We set the default mode for Wakaama to server. This way we can build a
library without any hacks in CMake.

After creating the coverage report we clean up the intermediate files.
2024-08-28 15:16:01 +02:00
Lukas Woodtli
a4e3f2726c tests: Build and run tests dependent on configuration
Some tests can only be compiled when the corresponding configuration is
enabled. Other test don't give a compilation error but they need the
correct configuration at runtime.
Therefore tests are disabled if the needed configuration is not set.
2024-08-28 15:16:01 +02:00
Lukas Woodtli
f419ad278b tests: Improve setting defines for tests
The defines are now set in the same way as for other targets.
2024-08-28 15:16:01 +02:00
Lukas Woodtli
cc8ac858d8 cmake: Set endianess globally
The endianess needs to be the same for all parts of the project. So it
is set globally.
2024-08-28 15:16:01 +02:00
Lukas Woodtli
2175575bb0 Fix CMake variables for data types
The CMake cache variables had a typo. Moreover they weren't declared as
options. Therefore the correct defines were not set on the targets.
2024-08-21 20:57:08 +02:00
Lukas Woodtli
76f42e24c3 tests: Enable LwM2M 1.0 client test only if suitable
The test for client functionality with LwM2M 1.0 is only enabled, if the
corresponding configuration is selected.
2024-08-21 20:57:08 +02:00
Lukas Woodtli
d655f2b518 tests: Disable incompatible tests
Some tests are not compatible with certain defines. If these defines are
set the corresponding tests are disabled.
2024-08-21 20:57:08 +02:00
Lukas Woodtli
047f5dab5f Get rid of macro to specify LwM2M version 1.1
LwM2M version 1.1 is the default for Wakaama. We need only a macro for
the version 1.0 to handle special cases.
2024-08-21 20:57:08 +02:00
Lukas Woodtli
847ff35daa tests: Include unit test code in coverage report
This helps to make sure that all unit test are run.
2024-08-21 20:57:08 +02:00
Lukas Woodtli
d658d7311c cmake: Extract 'tinydtls' transport into a library
The DTLS transport layer implementation with 'tinydtls' is now
encapsulated into an object library in the CMake project. This makes the
project more modular.
2024-08-19 10:07:05 +02:00
Lukas Woodtli
4cdbd18bdd cmake: Extract UDP transport into a library
The UDP transport layer implementation for POSIX is now encapsulated
into an object library in the CMake project. This makes the project more
modular.
2024-08-19 10:07:05 +02:00
Lukas Woodtli
5de25aa11f cmake: Extract POSIX platform layer into a library
The platform layer for POSIX is now encapsulated into an object library
in the CMake project. This makes the project more modular.
2024-08-19 10:07:05 +02:00
Lukas Woodtli
949549a760 cmake: Extract command line functionality into library
The command line functionality is now encapsulated into an object library
in the CMake project. This makes the project more modular.
2024-08-19 10:07:05 +02:00
Lukas Woodtli
5d42449283 cmake: Allow transport layer selection from CMake
The implementation of the transport layer can now be selected with a
CMake cache variable.
2024-08-19 10:07:05 +02:00
Lukas Woodtli
206b688781 cmake: Fix linking CUnit
Link CUnit to target in modern CMake manner.
2024-08-19 10:07:05 +02:00
Lukas Woodtli
402a305afe Move declaration for 'logging' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
7ab798caad Move declaration for 'packet' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
17c9238628 Move declaration for 'uri' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
befa878121 Move declaration for 'objects' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
7c8e81c256 Move declaration for 'management' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
e82738d675 Move declaration for 'observe' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
ec91f25f2b Move declaration for 'registration' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
6383ce8671 Move declaration for 'bootstrap' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
7a4adf858a Move declaration for 'discover' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
b0061b92e0 Move declaration for 'utils' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
e59c2ce0b3 Move declaration for 'reporting' into own header
This is more C like and leads to a better modularized project.
2024-08-19 10:06:15 +02:00
Lukas Woodtli
5ec7c099ae refactor: Extract common code
Some code to extract an opaque value was duplicated. A function was
extracted in order to remove the duplication.
2024-08-14 10:35:46 +02:00
Lukas Woodtli
31238b1a2e refactor: Extract some small functions
This make the code better to maintain.
2024-08-14 10:35:46 +02:00
Lukas Woodtli
f6c0ddad7e ci: Disable some sonar hints
The issues in the code have been there before. Sonar doesn't recognize
moved files and assumes that these files are new.
2024-08-14 10:35:46 +02:00
Lukas Woodtli
f5e5d3a67f refactor: Prefix connection related code with lwm2m
This code is part of Wakaama and should therefore be prefixed with
`lwm2m`. The code can optionaly be use in another project that leverages
Wakaama code. Therefore all Wakaama code has to be prefixed to reduces
the posibility of naming clashes.  Moreover it improves readability of
the code.
2024-08-14 10:35:46 +02:00
Lukas Woodtli
104d8401d4 refactor: Move tinydtls connection implementation in own folder
This is a step to a more modular project setup.
2024-08-14 10:35:46 +02:00
Lukas Woodtli
88c53d7e43 refactor: Move plain connection code to own folder
This is a step to a more modular project setup.
2024-08-14 10:35:46 +02:00
Lukas Woodtli
56b60a45d5 ci: Provide more information on test failure
Tell CMake/CTest to print the output of failed tests.
2024-07-29 14:02:15 +02:00
Lukas Woodtli
7eb45ed9e4 testing: Test for invalid content type during registration
LwM2M registration is only valid with core link format.
2024-07-29 14:02:15 +02:00
Lukas Woodtli
7aa5e9e0dc fix: Media type for registration must be CoRE Link
According to 1.1.1 LwM2M specification section 6.2.1. Register Operation

"the payload Media-Type of that registration message MUST be the CoRE
Link Format (application/link-format) defined in [RFC6690]"

* don't allow registration messages with different media type
* ensure that registration messages are sent with CoRE Link Format
2024-07-29 14:02:15 +02:00
Lukas Woodtli
77d38b8257 fix: Free allocated memory for query params
When the query param is parsed we allocate memory. In case of an invalid
content type that memory is not freed anymore.
2024-07-29 14:02:15 +02:00
Lukas Woodtli
01489dbe07 testing: Refactor registration test
Extract some useful functionality that can be used in other tests.
2024-07-29 14:02:15 +02:00