Skip to content

Commit

Permalink
cmake: Make max retransmit configurable with CMake
Browse files Browse the repository at this point in the history
The CMake variable `WAKAAMA_COAP_DEFAULT_MAX_RETRANSMIT` can be used to
configure the max number of retransmissions.
  • Loading branch information
LukasWoodtli committed Mar 3, 2025
1 parent 57f3cc7 commit aae2467
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The following data formats are configurable for Wakaama:
- WAKAAMA_COAP_RAW_BLOCK1_REQUESTS For low memory client devices where it is not possible to keep a large post or put request in memory to be parsed (typically a firmware write).
This option enable each unprocessed block 1 payload to be passed to the application, typically to be stored to a flash memory.
- WAKAAMA_COAP_DEFAULT_BLOCK_SIZE CoAP block size used by CoAP layer when performing block-wise transfers. Possible values: 16, 32, 64, 128, 256, 512 and 1024. Defaults to 1024.
- WAKAAMA_COAP_DEFAULT_MAX_RETRANSMIT The maximum number of retransmissions used for confirmable messages.


### Logging
Expand Down
27 changes: 10 additions & 17 deletions wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ set_property(
1024
)

# The maximum number of retransmissions used for confirmable messages.
set(WAKAAMA_COAP_DEFAULT_MAX_RETRANSMIT
4
CACHE STRING "Default CoAP max retransmissions"
)

# Logging
set(WAKAAMA_LOG_LEVEL
LOG_DISABLED
Expand Down Expand Up @@ -144,6 +150,10 @@ function(set_coap_defines)
endif()

target_compile_definitions(${target} PUBLIC LWM2M_COAP_DEFAULT_BLOCK_SIZE=${WAKAAMA_COAP_DEFAULT_BLOCK_SIZE})

target_compile_definitions(
${target} PUBLIC LWM2M_COAP_DEFAULT_MAX_RETRANSMIT=${WAKAAMA_COAP_DEFAULT_MAX_RETRANSMIT}
)
endfunction()

# Set the defines for logging configuration
Expand Down Expand Up @@ -239,17 +249,6 @@ function(target_sources_wakaama target)
message(STATUS "${target}: Default CoAP block size not set, using ${LWM2M_COAP_DEFAULT_BLOCK_SIZE}")
endif()

# LWM2M_COAP_DEFAULT_MAX_RETRANSMIT is needed by source files -> always set it
if(NOT CURRENT_TARGET_COMPILE_DEFINITIONS MATCHES "LWM2M_COAP_DEFAULT_MAX_RETRANSMIT=")
target_compile_definitions(
${target} PRIVATE "LWM2M_COAP_DEFAULT_MAX_RETRANSMIT=${LWM2M_COAP_DEFAULT_MAX_RETRANSMIT}"
)
message(
STATUS
"${target}: Default CoAP max retransmission count not set, using ${LWM2M_COAP_DEFAULT_MAX_RETRANSMIT}"
)
endif()

# Detect invalid configuration already during CMake run
if(NOT CURRENT_TARGET_COMPILE_DEFINITIONS MATCHES "LWM2M_SERVER_MODE|LWM2M_BOOTSTRAP_SERVER_MODE|LWM2M_CLIENT_MODE")
message(FATAL_ERROR "${target}: At least one mode (client, server, bootstrap server) must be enabled!")
Expand Down Expand Up @@ -350,9 +349,3 @@ set(LWM2M_COAP_DEFAULT_BLOCK_SIZE
1024
CACHE STRING "Default CoAP block size; Used if not set on a per-target basis"
)

# The maximum number of retransmissions used for confirmable messages.
set(LWM2M_COAP_DEFAULT_MAX_RETRANSMIT
4
CACHE STRING "Default CoAP max retransmissions; Used if not set on a per-target basis"
)

0 comments on commit aae2467

Please sign in to comment.