Skip to content

Commit 95b3c78

Browse files
author
Łukasz Kwinta
committed
Anjay Lite 1.0.0-beta.2
1 parent 40ac7cc commit 95b3c78

File tree

273 files changed

+10995
-2872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+10995
-2872
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ CMakeFiles/
2323
CMakeDoxyfile.in
2424
*.cmake
2525
!cmake/*.cmake
26+
!tests/init_header_check/run_check.cmake
2627
CMakeCache.txt
2728
Makefile
2829
__pycache__/
@@ -44,6 +45,7 @@ libanj.a
4445
/dm_without_composite_tests
4546
/exchange_tests
4647
/core_tests
48+
/downloader_tests
4749
/net_tests
4850
/anj_config
4951
/cxx_header_check

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# Changelog
22

3+
## Anjay Lite 1.0.0-beta.2 (Aughust 27th, 2025)
4+
5+
### BREAKING CHANGES
6+
7+
- Changed error codes defined in the `anj_net_api.h` to positive values. Returning any positive values from the
8+
user Network API implementation, other than `ANJ_NET_E*`, is prohibited.
9+
10+
### Features
11+
12+
- CoAP Downloader module for large file transfers from CoAP servers, supporting FOTA Pull scenarios.
13+
- Added support for Write-Composite operation.
14+
15+
### Improvements
16+
17+
- Added `anj/init.h` header to make config includes and option dependency checks
18+
more consistent.
19+
- Removed unnecessary usages of `ANJ_CONTAINER_OF()` in object implementation
20+
examples.
21+
- Introduce Python tools for downloading object XMLs from OMA registry - `tools/lwm2m_object_registry.py` and generating
22+
object stubs - `tools/anjay_codegen.py`
23+
- Implemented responses caching
24+
- If no confirmable notification is sent for 24 hours, the next notification sent will be confirmable.
25+
- The library now follows the include pattern recommendations from Include What You Use (IWYU) version 0.24
26+
compatible with clang 20.
27+
28+
### Bugfixes
29+
30+
- Fixed improper handling of LwM2M Server responses in Separate Response mode.
31+
- Updated default value in description of `ANJ_COAP_MAX_OPTIONS_NUMBER` option.
32+
- Fixed an issue with calling the observation module API during message exchange handling.
33+
- Corrected the timing for setting the last sent notification timestamp.
34+
- Fixed an issue that allowed server both bootstrap and management to freely read
35+
the Security and OSCORE objects.
36+
337
## Anjay Lite 1.0.0-beta.1 (June 9th, 2025)
438

539
Initial release.

CMakeLists.txt

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
# Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
66
# See the attached LICENSE file for details.
77

8-
cmake_minimum_required(VERSION 3.6.0)
8+
cmake_minimum_required(VERSION 3.16.0)
9+
10+
project(anjay_lite C)
911

1012
# Core CMake code is located in cmake/anjay_lite-config.cmake and the library is
1113
# supposed to be imported using find_package() mechanism - this file only meant
1214
# to be a convenience wrapper for all example and test targets.
1315

14-
project(anjay_lite C)
15-
1616
set(CMAKE_C_STANDARD 99)
1717
set(CMAKE_C_EXTENSIONS OFF)
1818

@@ -24,6 +24,17 @@ find_program(VALGRIND_EXECUTABLE valgrind)
2424

2525
add_custom_target(run_tests)
2626

27+
# determine list of -D variables set by users, they need to be prefixed with CLI_
28+
get_cmake_property(_cache_vars CACHE_VARIABLES)
29+
set(COMMAND_LINE_FLAGS "")
30+
foreach(_var ${_cache_vars})
31+
if(_var MATCHES "CLI_")
32+
list(APPEND COMMAND_LINE_FLAGS "-D${_var}=${${_var}}")
33+
endif()
34+
endforeach()
35+
36+
message(STATUS "Command line flags: ${COMMAND_LINE_FLAGS}")
37+
2738
function(add_standalone_target NAME PATH WITH_VALGRIND)
2839
set(workdir "${CMAKE_BINARY_DIR}/${NAME}")
2940

@@ -32,16 +43,18 @@ function(add_standalone_target NAME PATH WITH_VALGRIND)
3243

3344
add_custom_target(${NAME} ALL)
3445
add_custom_command(TARGET ${NAME} COMMAND ${CMAKE_COMMAND} -E make_directory
35-
"${workdir}")
46+
"${workdir}" PRE_BUILD)
3647
add_custom_command(
3748
TARGET ${NAME}
3849
COMMAND
3950
${CMAKE_COMMAND} -S "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}" -B .
4051
-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}"
4152
-DCMAKE_C_FLAGS="${unescaped_c_flags}"
4253
-DCMAKE_EXE_LINKER_FLAGS="${unescaped_exe_linker_flags}"
54+
${COMMAND_LINE_FLAGS}
4355
COMMAND ${CMAKE_COMMAND} --build . --target ${NAME} -- -j${NPROC}
44-
WORKING_DIRECTORY "${workdir}")
56+
WORKING_DIRECTORY "${workdir}"
57+
POST_BUILD)
4558

4659
if(WITH_VALGRIND AND VALGRIND_EXECUTABLE)
4760
add_custom_target(
@@ -53,7 +66,7 @@ function(add_standalone_target NAME PATH WITH_VALGRIND)
5366

5467
if(${NAME} MATCHES "_tests")
5568
add_dependencies(run_tests ${NAME})
56-
add_custom_command(TARGET run_tests COMMAND "${workdir}/${NAME}")
69+
add_custom_command(TARGET run_tests COMMAND "${workdir}/${NAME}" POST_BUILD)
5770
endif()
5871
endfunction()
5972

@@ -68,9 +81,11 @@ add_standalone_target(io_tests_without_extended tests/anj/io_without_extended ON
6881
add_standalone_target(coap_tests tests/anj/coap ON)
6982
add_standalone_target(net_tests tests/anj/net ON)
7083
add_standalone_target(core_tests tests/anj/core ON)
84+
add_standalone_target(downloader_tests tests/anj/downloader ON)
7185

7286
# examples
7387
add_standalone_target(anjay_lite_firmware_update examples/tutorial/firmware-update OFF)
88+
add_standalone_target(anjay_lite_firmware_update_pull examples/tutorial/firmware-update-coap-downloader OFF)
7489

7590
add_standalone_target(anjay_lite_bc_initialization examples/tutorial/BC-Initialization OFF)
7691
add_standalone_target(anjay_lite_bc_mandatory_objects examples/tutorial/BC-MandatoryObjects OFF)
@@ -88,8 +103,20 @@ add_standalone_target(anjay_lite_at_multi_instance_resource_dynamic examples/tut
88103
add_standalone_target(anjay_lite_minimal_network_api examples/custom-network/minimal OFF)
89104
add_standalone_target(anjay_lite_reuse_port examples/custom-network/reuse-port OFF)
90105

106+
add_standalone_target(anjay_lite_mbedtls_build examples/tutorial/mbedtls-build OFF)
107+
91108
# Sphinx and doxygen documentation
92109
add_subdirectory(doc)
93110

94111
# C++ header compatibility check
95112
add_standalone_target(cxx_header_check tests/cxx_header_check OFF)
113+
114+
add_standalone_target(codegen_compilation_check tests/codegen/compilation OFF)
115+
add_standalone_target(codegen_object_registry_check tests/codegen/object_registry OFF)
116+
add_standalone_target(codegen_add_object_tests tests/codegen/add_object OFF)
117+
118+
# Check for correct inclusion of anj/init.h
119+
add_custom_target(init_header_check
120+
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/init_header_check/run_check.cmake"
121+
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
122+
)

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ PREDEFINED = ANJ_IN_MSG_BUFFER_SIZE \
23942394
ANJ_OUT_PAYLOAD_BUFFER_SIZE \
23952395
ANJ_DM_MAX_OBJECTS_NUMBER \
23962396
ANJ_WITH_COMPOSITE_OPERATIONS \
2397-
ANJ_DM_MAX_COMPOSITE_ENTRIES \
2397+
ANJ_DM_MAX_COMP_READ_ENTRIES \
23982398
ANJ_WITH_DEFAULT_DEVICE_OBJ \
23992399
ANJ_WITH_DEFAULT_SECURITY_OBJ \
24002400
ANJ_SEC_OBJ_MAX_PUBLIC_KEY_OR_IDENTITY_SIZE \

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Purposes, as defined below.
3636
1. use the Software for Non-Commercial Purposes;
3737
2. copy and modify the Software;
3838
3. distribute unmodified or modified versions of the Software, provided that:
39-
- Redistribution of source code must retain AVSystems copyright notice
40-
and include the list of usage conditions and AVSystems disclaimer;
39+
- Redistribution of source code must retain AVSystem's copyright notice
40+
and include the list of usage conditions and AVSystem's disclaimer;
4141
- Redistribution in binary form, except as embedded in a physical device,
4242
must include the following acknowledgment in accompanying documentation
4343
or user interface: "This product includes software developed by AVSystem

LICENSE.3RDPARTY

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The core Anjay Lite LwM2M Client Library is entirely developed and maintained by
44
AVSystem and is free of any third-party open-source code dependencies.
55

66
This file lists licenses of any third-party components that are used solely in
7-
the SDKs supporting infrastructure, such as documentation generation (e.g.
7+
the SDK's supporting infrastructure, such as documentation generation (e.g.
88
Doxygen) or development tooling. These components are not part of the runtime
99
library itself.
1010

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ issues via our GitHub repository.
4343
* [About OMA LwM2M](#about-oma-lwm2m)
4444
* [Quickstart Guide](#quickstart-guide)
4545
* [Building and Running a Single Anjay Lite Example](#building-and-running-a-single-anjay-lite-example)
46+
* [Configuring the MbedTLS](#configuring-the-mbedtls)
4647
* [Documentation](#documentation)
4748
* [License](#license)
4849
* [Commercial Support](#commercial-support)
@@ -120,6 +121,45 @@ make -j
120121

121122
Replace <endpoint_name> with your desired endpoint name.
122123

124+
### Configuring the MbedTLS
125+
126+
Anjay Lite uses Mbed TLS to implement DTLS for secure transport.
127+
The library automatically fetches and builds MbedTLS version 3.6.0 during the
128+
build process. You can override this default version or use a custom, pre-installed MbedTLS library if needed.
129+
130+
To override the default version fetched via FetchContent, set the MBEDTLS_VERSION variable:
131+
132+
``` sh
133+
cd examples/tutorial/mbedtls-build
134+
mkdir build
135+
cd build
136+
cmake .. -DMBEDTLS_VERSION=3.5.0
137+
make -j
138+
```
139+
140+
If you want to use your own prebuilt version of MbedTLS with custom configuration, follow these steps:
141+
142+
1. Build and install MbedTLS manually (in specified directory, without affecting global installed MbedTLS):
143+
144+
``` sh
145+
git clone https://github.com/ARMmbed/mbedtls.git
146+
cd mbedtls
147+
git checkout v3.4.0 # or another supported version
148+
# change configuration using scripts/config.py or modify mbedtls_config.h directly
149+
cmake . -DCMAKE_INSTALL_PREFIX=$PWD/install
150+
make install
151+
```
152+
153+
2. Build Anjay Lite with that installed version:
154+
155+
``` sh
156+
cd /path/to/anjay-lite/build
157+
cmake .. -DMBEDTLS_ROOT_DIR=mbedtls-path/mbedtls/install
158+
make -j
159+
```
160+
161+
Anjay Lite requires MbedTLS 3.x. Versions from the 2.x series are not supported.
162+
123163
<p align="right">(<a href="#readme-top">Back to top</a>)</p>
124164

125165
## Documentation

cmake/anjay_lite-config.cmake

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
66
# See the attached LICENSE file for details.
77

8-
cmake_minimum_required(VERSION 3.6.0)
8+
cmake_minimum_required(VERSION 3.16.0)
99

1010
project(anjay_lite)
1111

@@ -44,7 +44,7 @@ define_overridable_option(ANJ_OUT_PAYLOAD_BUFFER_SIZE STRING 1024 "Payload buffe
4444
# data model configuration
4545
define_overridable_option(ANJ_DM_MAX_OBJECTS_NUMBER STRING 10 "Max LwM2M Objects defined in data model")
4646
define_overridable_option(ANJ_WITH_COMPOSITE_OPERATIONS BOOL ON "Enable composite operations support")
47-
define_overridable_option(ANJ_DM_MAX_COMPOSITE_ENTRIES STRING 5 "Max entries (paths) in a composite operations")
47+
define_overridable_option(ANJ_DM_MAX_COMP_READ_ENTRIES STRING 5 "Max entries (paths) in a composite read operation")
4848

4949
# device object configuration
5050
define_overridable_option(ANJ_WITH_DEFAULT_DEVICE_OBJ BOOL ON "Enable default implementation of Device Object")
@@ -69,6 +69,11 @@ define_overridable_option(ANJ_FOTA_WITH_HTTPS BOOL OFF "Enable HTTPS support in
6969
define_overridable_option(ANJ_FOTA_WITH_COAP_TCP BOOL OFF "Enable TCP support in FW Update Object")
7070
define_overridable_option(ANJ_FOTA_WITH_COAPS_TCP BOOL OFF "Enable TLS support in FW Update Object")
7171

72+
# CoAP downloader configuration
73+
define_overridable_option(ANJ_WITH_COAP_DOWNLOADER BOOL OFF "Enable CoAP Downloader support")
74+
define_overridable_option(ANJ_COAP_DOWNLOADER_MAX_PATHS_NUMBER STRING 3 "Max CoAP Paths number in CoAP Downloader")
75+
define_overridable_option(ANJ_COAP_DOWNLOADER_MAX_MSG_SIZE STRING 1200 "Max CoAP message size used in CoAP Downloader")
76+
7277
# observe configuration
7378
define_overridable_option(ANJ_WITH_OBSERVE BOOL ON "Enable Observe-Notify mechanism")
7479
define_overridable_option(ANJ_WITH_OBSERVE_COMPOSITE BOOL OFF "Enable Observe-Composite support")
@@ -115,6 +120,8 @@ define_overridable_option(ANJ_COAP_MAX_OPTIONS_NUMBER STRING 15 "Max number of C
115120
define_overridable_option(ANJ_COAP_MAX_ATTR_OPTION_SIZE STRING 40 "Max Attribute-related CoAP option size")
116121
define_overridable_option(ANJ_COAP_MAX_LOCATION_PATHS_NUMBER STRING 2 "Max CoAP Location-Paths number in Registration Interface")
117122
define_overridable_option(ANJ_COAP_MAX_LOCATION_PATH_SIZE STRING 40 "Max size of a single CoAP Location-Path in Registration Interface")
123+
define_overridable_option(ANJ_WITH_CACHE BOOL ON "Enable responses caching")
124+
define_overridable_option(ANJ_CACHE_ENTRIES_NUMBER STRING 10 "Non-recent cache entries number")
118125

119126
# logger configuration
120127
define_overridable_option(ANJ_LOG_FULL BOOL ON "Enable full logger: includes module, level, file, and line info")
@@ -133,6 +140,11 @@ define_overridable_option(ANJ_WITH_LWM2M12 BOOL ON "Enable LwM2M protocol versio
133140
define_overridable_option(ANJ_WITH_CUSTOM_CONVERSION_FUNCTIONS BOOL ON "Enable custom string<->number conversion function")
134141
define_overridable_option(ANJ_PLATFORM_BIG_ENDIAN BOOL OFF "Define platform endianess as big endian")
135142

143+
# MbedTLS configuration
144+
define_overridable_option(ANJ_WITH_MBEDTLS BOOL OFF "Enable MbedTLS support")
145+
define_overridable_option(MBEDTLS_VERSION STRING "" "MbedTLS version to use when MBEDTLS_ROOT_DIR is not set, default is 3.6.0")
146+
define_overridable_option(MBEDTLS_ROOT_DIR STRING "" "Path to MbedTLS root directory (if not set, MbedTLS will be fetched from GitHub)")
147+
136148
set(repo_root "${CMAKE_CURRENT_LIST_DIR}/..")
137149
set(config_root "${CMAKE_BINARY_DIR}/anj_config")
138150
set(config_base_path anj/anj_config.h)
@@ -156,14 +168,6 @@ if(NOT HAVE_MATH_LIBRARY)
156168
endif()
157169
endif()
158170

159-
function(use_iwyu_if_enabled TARGET)
160-
if (ANJ_IWYU_PATH)
161-
set_target_properties(${TARGET} PROPERTIES
162-
C_INCLUDE_WHAT_YOU_USE
163-
"${ANJ_IWYU_PATH};-Xiwyu;--keep=*/anj/anj_config.h")
164-
endif()
165-
endfunction()
166-
167171
add_library(anj STATIC ${anj_sources})
168172
target_include_directories(
169173
anj PUBLIC "${repo_root}/include_public" "${config_root}")
@@ -206,3 +210,8 @@ if(gcc_or_clang)
206210
target_compile_options(anj PUBLIC -Wno-pedantic -Wno-c++-compat)
207211
endif()
208212
endif()
213+
214+
if(ANJ_WITH_MBEDTLS)
215+
include("${repo_root}/cmake/anjay_lite_mbedtls.cmake")
216+
target_link_libraries(anj PUBLIC ${MBEDTLS_TARGETS})
217+
endif()

cmake/anjay_lite_mbedtls.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2023-2025 AVSystem <avsystem@avsystem.com>
2+
# AVSystem Anjay Lite LwM2M SDK
3+
# All rights reserved.
4+
#
5+
# Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
6+
# See the attached LICENSE file for details.
7+
8+
if(NOT MBEDTLS_VERSION STREQUAL "" AND NOT MBEDTLS_ROOT_DIR STREQUAL "")
9+
message(FATAL_ERROR "MBEDTLS_VERSION and MBEDTLS_ROOT_DIR cannot be set at the same time!")
10+
endif()
11+
12+
if(MBEDTLS_VERSION STREQUAL "")
13+
set(MBEDTLS_VERSION "3.6.0")
14+
endif()
15+
16+
if(NOT MBEDTLS_ROOT_DIR)
17+
include(FetchContent)
18+
message(STATUS "No MBEDTLS_ROOT_DIR provided. Fetching MbedTLS ${MBEDTLS_VERSION} ...")
19+
FetchContent_Declare(
20+
mbedtls
21+
GIT_REPOSITORY https://github.com/Mbed-TLS/mbedtls.git
22+
GIT_TAG v${MBEDTLS_VERSION}
23+
)
24+
FetchContent_MakeAvailable(mbedtls)
25+
set(MBEDTLS_TARGETS MbedTLS::mbedtls MbedTLS::mbedx509 MbedTLS::mbedcrypto)
26+
27+
# Add aliases so that targets have consistent names with find_package(MbedTLS)
28+
add_library(MbedTLS::mbedtls ALIAS mbedtls)
29+
add_library(MbedTLS::mbedcrypto ALIAS mbedcrypto)
30+
add_library(MbedTLS::mbedx509 ALIAS mbedx509)
31+
else()
32+
message(STATUS "Using MbedTLS from: ${MBEDTLS_ROOT_DIR}")
33+
set(_MBEDTLS_SEARCH_ARGS PATHS "${MBEDTLS_ROOT_DIR}" NO_DEFAULT_PATH)
34+
find_package(MbedTLS CONFIG REQUIRED ${_MBEDTLS_SEARCH_ARGS})
35+
set(MBEDTLS_TARGETS MbedTLS::mbedtls MbedTLS::mbedx509 MbedTLS::mbedcrypto)
36+
endif()

doc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(SNIPPET_SOURCE_MD5FILE ${SPHINX_DIR})
2121
file(MAKE_DIRECTORY ${repo_root}/doc/build)
2222

2323
if(EXISTS "${SPHINX_SOURCE}/conf.py.in")
24-
set(DOC_VERSION "1.0.0-beta.1")
24+
set(DOC_VERSION "1.0.0-beta.2")
2525

2626
configure_file(${SPHINX_SOURCE}/conf.py.in
2727
${SPHINX_DIR}/conf.py

0 commit comments

Comments
 (0)