Skip to content

Commit 27032e9

Browse files
SeppoTakalotrantanen
authored andcommitted
app: Block pipe from URC messages while long AT command is executing
The idle timer is not necessary enough to detect whether AT command is still progressing, so add an extra flag for that. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
1 parent 5d44b7c commit 27032e9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

app/src/sm_at_host.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ struct sm_at_host_ctx {
149149

150150
/* AT command reception state (for cmd_rx_handler) */
151151
bool inside_quotes;
152+
bool executing;
152153
size_t at_cmd_len;
153154
size_t echo_len;
154155
uint8_t prev_character;
@@ -1128,16 +1129,20 @@ static void cmd_send(struct sm_at_host_ctx *ctx, uint8_t *buf, size_t cmd_length
11281129
return;
11291130
}
11301131

1132+
/* Block URCs while command is executing, even if idle timer triggers */
1133+
ctx->executing = true;
11311134
/* Send to modem.
11321135
* Reserve space for CRLF in the response buffer.
11331136
*/
11341137
err = nrf_modem_at_cmd(sm_response_buf + strlen(CRLF_STR),
11351138
sizeof(sm_response_buf) - strlen(CRLF_STR), "%s", at_cmd);
11361139
if (err == -SILENT_AT_COMMAND_RET) {
1140+
ctx->executing = false;
11371141
return;
11381142
} else if (err < 0) {
11391143
LOG_ERR("AT command failed: %d", err);
11401144
rsp_send_error();
1145+
ctx->executing = false;
11411146
return;
11421147
} else if (err > 0) {
11431148
LOG_ERR("AT command error (%d), type: %d: value: %d", err,
@@ -1158,6 +1163,7 @@ static void cmd_send(struct sm_at_host_ctx *ctx, uint8_t *buf, size_t cmd_length
11581163
LOG_ERR("AT command response failed: %d", err);
11591164
}
11601165
}
1166+
ctx->executing = false;
11611167
}
11621168

11631169
static size_t cmd_rx_handler(struct sm_at_host_ctx *ctx, uint8_t c)
@@ -1523,7 +1529,7 @@ bool in_at_mode_pipe(struct modem_pipe *pipe)
15231529
bool is_idle_ctx(struct sm_at_host_ctx *ctx)
15241530
{
15251531
return (sm_at_ctx_check(ctx) && in_at_mode_ctx(ctx) &&
1526-
k_timer_remaining_ticks(&ctx->idle_timer) == 0);
1532+
ctx->executing == false && k_timer_remaining_ticks(&ctx->idle_timer) == 0);
15271533
}
15281534

15291535
bool is_idle_pipe(struct modem_pipe *pipe)

0 commit comments

Comments
 (0)