Skip to content

Commit fe3a3db

Browse files
committed
app: Retry pipe_transmit before timeout
Sometimes, the k_event might be lost, if its set just before we start listening. Add a simple retry mechanism. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent 1ca70e7 commit fe3a3db

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

app/src/sm_at_host.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ static int sm_at_host_pipe_tx_blocking(struct sm_at_host_ctx *ctx, const uint8_t
478478
{
479479
struct modem_pipe *pipe = ctx ? atomic_ptr_get(&ctx->pipe) : NULL;
480480
int ret;
481+
int retries = 5;
481482

482483
if (!pipe) {
483484
LOG_WRN("No pipe assigned for transmission (ctx: %p)", (void *)ctx);
@@ -493,9 +494,11 @@ static int sm_at_host_pipe_tx_blocking(struct sm_at_host_ctx *ctx, const uint8_t
493494
} else if (ret == 0) {
494495
/* No data transmitted, wait for transmit idle event */
495496
if (k_event_wait(&ctx->pipe_event, BIT(MODEM_PIPE_EVENT_TRANSMIT_IDLE),
496-
true, K_SECONDS(1)) == 0) {
497-
LOG_ERR("Failed to wait for transmit idle event");
498-
return -EIO;
497+
true, K_MSEC(100)) == 0) {
498+
if (--retries == 0) {
499+
LOG_ERR("Pipe blocked, dropping %d bytes", len);
500+
return -EIO;
501+
}
499502
}
500503
} else {
501504
buf += ret;

0 commit comments

Comments
 (0)