Skip to content

Commit 3e615c9

Browse files
SeppoTakalotrantanen
authored andcommitted
app: util.h: Add a helper function to check if pipe is open
Cherry-pick a usefull helper function from my modem_pipe branch. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no> (cherry picked from commit 4d0f629)
1 parent fa48f22 commit 3e615c9

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

app/src/sm_util.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <zephyr/net/socket.h>
2020
#include <stdbool.h>
2121
#include <hal/nrf_gpio.h>
22+
#include <zephyr/modem/pipe.h>
2223

2324
extern struct k_work_q sm_work_q; /* Serial Modem's work queue. */
2425

@@ -206,6 +207,22 @@ struct sm_pdn_dynamic_info {
206207
* @return Zero on success or an error code on failure.
207208
*/
208209
int sm_util_pdn_dynamic_info_get(uint8_t cid, struct sm_pdn_dynamic_info *pdn_info);
210+
211+
#define Z_MODEM_PIPE_EVENT_OPENED_BIT BIT(0)
212+
213+
/**
214+
* @brief Check whether a modem pipe is open
215+
*
216+
* @param pipe Modem pipe to check.
217+
* @return true if pipe is open
218+
* @return false if pipe is not open
219+
*/
220+
static inline bool sm_pipe_is_open(struct modem_pipe *pipe)
221+
{
222+
return k_event_test(&pipe->event, Z_MODEM_PIPE_EVENT_OPENED_BIT) ==
223+
Z_MODEM_PIPE_EVENT_OPENED_BIT;
224+
}
225+
209226
/** @} */
210227

211228
#endif /* SM_UTIL_ */

0 commit comments

Comments
 (0)