diff --git a/subsys/modem/modem_chat.c b/subsys/modem/modem_chat.c index f0c580f11ec..088a2bc038d 100644 --- a/subsys/modem/modem_chat.c +++ b/subsys/modem/modem_chat.c @@ -877,6 +877,8 @@ int modem_chat_run_script_async(struct modem_chat *chat, const struct modem_chat return -EBUSY; } + k_sem_reset(&chat->script_stopped_sem); + chat->pending_script = script; k_work_submit(&chat->script_run_work); return 0; @@ -886,8 +888,6 @@ int modem_chat_run_script(struct modem_chat *chat, const struct modem_chat_scrip { int ret; - k_sem_reset(&chat->script_stopped_sem); - ret = modem_chat_run_script_async(chat, script); if (ret < 0) { return ret;