Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: enable timeout for sidewalk msg put #638

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
#if 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