Skip to content

Commit 83375a8

Browse files
JordanYateshenrikbrixandersen
authored andcommitted
modem: chat: add modem_chat_is_running
Add a helper function to query if the chat instance is currently running a script. Signed-off-by: Jordan Yates <[email protected]>
1 parent 9d5f94f commit 83375a8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/zephyr/modem/chat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ int modem_chat_init(struct modem_chat *chat, const struct modem_chat_config *con
337337
*/
338338
int modem_chat_attach(struct modem_chat *chat, struct modem_pipe *pipe);
339339

340+
/**
341+
* @brief Check if a script is running
342+
* @param chat Chat instance
343+
* @returns true if a script is currently running
344+
* @returns false if a script is not currently running
345+
*/
346+
bool modem_chat_is_running(struct modem_chat *chat);
347+
340348
/**
341349
* @brief Run script asynchronously
342350
* @param chat Chat instance

subsys/modem/modem_chat.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,11 @@ int modem_chat_attach(struct modem_chat *chat, struct modem_pipe *pipe)
845845
return 0;
846846
}
847847

848+
bool modem_chat_is_running(struct modem_chat *chat)
849+
{
850+
return atomic_test_bit(&chat->script_state, MODEM_CHAT_SCRIPT_STATE_RUNNING_BIT);
851+
}
852+
848853
int modem_chat_run_script_async(struct modem_chat *chat, const struct modem_chat_script *script)
849854
{
850855
bool script_is_running;

0 commit comments

Comments
 (0)