From 30c238e6d07c2c225dafc2a87a541e6e1a4517e1 Mon Sep 17 00:00:00 2001 From: Krzysztof Taborowski Date: Tue, 29 Oct 2024 16:23:06 +0100 Subject: [PATCH] samples: enable timeout for sidewalk msg put [KRKNWK-19515] --- Kconfig | 13 +------------ samples/sid_end_device/Kconfig | 1 - samples/sid_end_device/src/sidewalk.c | 7 ++++--- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Kconfig b/Kconfig index 12af18536e..d90e70d7e2 100644 --- a/Kconfig +++ b/Kconfig @@ -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 diff --git a/samples/sid_end_device/Kconfig b/samples/sid_end_device/Kconfig index 209d420c5f..5fcc3ce841 100644 --- a/samples/sid_end_device/Kconfig +++ b/samples/sid_end_device/Kconfig @@ -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. diff --git a/samples/sid_end_device/src/sidewalk.c b/samples/sid_end_device/src/sidewalk.c index 57cde93956..19cd36e00b 100644 --- a/samples/sid_end_device/src/sidewalk.c +++ b/samples/sid_end_device/src/sidewalk.c @@ -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);