Skip to content

Commit

Permalink
samples: enable timeout for sidewalk msg put
Browse files Browse the repository at this point in the history
  • Loading branch information
ktaborowski committed Oct 29, 2024
1 parent c210b0c commit 30c238e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
13 changes: 1 addition & 12 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,10 @@ config SIDEWALK_THREAD_QUEUE_SIZE
help
Set the message queue size for the Sidewalk thread.

config SIDEWALK_THREAD_QUEUE_TIMEOUT
bool "Message queue timeout for the Sidewalk thread [EXPERIMENTAL]"
select EXPERIMENTAL
help
Set the message queue put timeout for the Sidewalk thread.
The events form interrupt conetext are always put with no timeout.

if SIDEWALK_THREAD_QUEUE_TIMEOUT

config SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE
int "Message queue timeout value in ms [EXPERIMENTAL]"
int "Message queue timeout value in ms"
default 300

endif # SIDEWALK_THREAD_QUEUE_TIMEOUT

config SIDEWALK_THREAD_PRIORITY
int "Priority of the Sidewalk thread"
range -16 14
Expand Down
1 change: 0 additions & 1 deletion samples/sid_end_device/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ config SIDEWALK_FILE_TRANSFER_DFU
imply DFU_TARGET_MCUBOOT
imply STREAM_FLASH
imply STREAM_FLASH_ERASE
imply SIDEWALK_THREAD_QUEUE_TIMEOUT
help
Save recived data to flash. Expect CBOR manifest.
Autoatically reset device after file transfer.
Expand Down
7 changes: 4 additions & 3 deletions samples/sid_end_device/src/sidewalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ int sidewalk_event_send(event_handler_t event, void *ctx, ctx_free free)
};

k_timeout_t timeout = K_NO_WAIT;
int result = -EFAULT;

#ifdef CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT
#ifdef defined(CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE) && CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE > 0
if (!k_is_in_isr()) {
timeout = K_MSEC(CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE);
}
#endif /* CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT */
#endif /* CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE > 0 */

const int result = k_msgq_put(&sidewalk_thread_msgq, (void *)&ctx_event, timeout);
result = k_msgq_put(&sidewalk_thread_msgq, (void *)&ctx_event, timeout);
LOG_DBG("sidewalk_event_send event = %p, context = %p, k_msgq_put result %d", (void *)event,
ctx, result);

Expand Down

0 comments on commit 30c238e

Please sign in to comment.