Skip to content

Commit

Permalink
make timeouts changeable
Browse files Browse the repository at this point in the history
  • Loading branch information
tothero committed Jul 4, 2023
1 parent 88add2f commit 358da3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ if (DEFINED __INIT_LOBARO_BUILD)
include(${CPATH}/src/github.com/lobaro/c-build/build.cmake)

add_definitions(
# this must be an array, e.g. {5,10,15} or {20}
# no quotes
# if there are more retries than entries, last entry of array will be used
-DCOAP_EXPLICIT_TIMEOUTS={20}
-DCOAP_MAX_RETRANSMIT=2
-DCOAP_MAX_RETRANSMIT=2 # need +1 timeout values
-DCOAP_EXPLICIT_TIMEOUT0=20
-DCOAP_EXPLICIT_TIMEOUT1=20
-DCOAP_EXPLICIT_TIMEOUT2=20
)

cbuild_module("lobaro/lobaro-coap/test")
Expand Down
6 changes: 3 additions & 3 deletions src/coap_interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ CoAP_Result_t _rom CoAP_SetSleepInteraction(CoAP_Interaction_t* pIA, uint32_t se
return COAP_OK;
}

#ifdef COAP_EXPLICIT_TIMEOUTS
const uint8_t TIMEOUTS[] = COAP_EXPLICIT_TIMEOUTS;
#ifdef COAP_EXPLICIT_TIMEOUT0
const uint8_t TIMEOUTS[] = {COAP_EXPLICIT_TIMEOUT0,COAP_EXPLICIT_TIMEOUT1,COAP_EXPLICIT_TIMEOUT2};
#endif

CoAP_Result_t _rom CoAP_EnableAckTimeout(CoAP_Interaction_t* pIA, uint8_t retryNum) {
#ifdef COAP_EXPLICIT_TIMEOUTS
#ifdef COAP_EXPLICIT_TIMEOUT0
uint32_t waitTime;
if (retryNum < sizeof(TIMEOUTS)) {
waitTime = TIMEOUTS[retryNum];
Expand Down

0 comments on commit 358da3d

Please sign in to comment.