Skip to content

Commit

Permalink
cmake: Make max retransmit configurable at build time
Browse files Browse the repository at this point in the history
Make CoAP max retransmit setting configurable at build time.
  • Loading branch information
mlasch authored and LukasWoodtli committed Mar 3, 2025
1 parent 9f7ec5b commit 57f3cc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion coap/er-coap-13/er-coap-13.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#define COAP_DEFAULT_MAX_AGE 60
#define COAP_RESPONSE_TIMEOUT 2
#define COAP_MAX_RETRANSMIT 4
#define COAP_MAX_RETRANSMIT LWM2M_COAP_DEFAULT_MAX_RETRANSMIT
#define COAP_ACK_RANDOM_FACTOR 1.5
#define COAP_MAX_LATENCY 100
#define COAP_PROCESSING_DELAY COAP_RESPONSE_TIMEOUT
Expand Down
17 changes: 17 additions & 0 deletions wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ 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 @@ -339,3 +350,9 @@ 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 57f3cc7

Please sign in to comment.