Skip to content

Commit 3973aaa

Browse files
JordanYatesjhedberg
authored andcommitted
modem: modem_cellular: comms check result callback
Add a callback for the periodic script result so that applications have a way of detecting dead links. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 91d3d95 commit 3973aaa

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

doc/releases/release-notes-4.3.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ New APIs and options
146146

147147
* :kconfig:option:`CONFIG_CPU_FREQ`
148148

149+
* Cellular
150+
151+
* :c:enumerator:`CELLULAR_EVENT_MODEM_COMMS_CHECK_RESULT`
152+
149153
* Crypto
150154

151155
* :kconfig:option:`CONFIG_MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS`

drivers/modem/modem_cellular.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,15 @@ static void modem_cellular_carrier_on_event_handler(struct modem_cellular_data *
13911391
{
13921392
const struct modem_cellular_config *config =
13931393
(const struct modem_cellular_config *)data->dev->config;
1394+
struct cellular_evt_modem_comms_check_result result;
13941395

13951396
switch (evt) {
13961397
case MODEM_CELLULAR_EVENT_SCRIPT_SUCCESS:
13971398
case MODEM_CELLULAR_EVENT_SCRIPT_FAILED:
1399+
result.success = evt == MODEM_CELLULAR_EVENT_SCRIPT_SUCCESS;
1400+
13981401
modem_cellular_start_timer(data, MODEM_CELLULAR_PERIODIC_SCRIPT_TIMEOUT);
1402+
modem_cellular_emit_event(data, CELLULAR_EVENT_MODEM_COMMS_CHECK_RESULT, &result);
13991403
break;
14001404

14011405
case MODEM_CELLULAR_EVENT_TIMEOUT:

include/zephyr/drivers/cellular.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ enum cellular_event {
139139
CELLULAR_EVENT_MODEM_INFO_CHANGED = BIT(0),
140140
/** Cellular network registration status changed */
141141
CELLULAR_EVENT_REGISTRATION_STATUS_CHANGED = BIT(1),
142+
/** Result of a communications link check to the modem */
143+
CELLULAR_EVENT_MODEM_COMMS_CHECK_RESULT = BIT(2),
142144
};
143145

144146
/* Opaque bit-mask large enough for all current & future events */
@@ -154,6 +156,11 @@ struct cellular_evt_registration_status {
154156
enum cellular_registration_status status; /**< New registration status */
155157
};
156158

159+
/** Payload for @ref CELLULAR_EVENT_MODEM_COMMS_CHECK_RESULT */
160+
struct cellular_evt_modem_comms_check_result {
161+
bool success; /**< Communications to modem checked successfully */
162+
};
163+
157164
/**
158165
* @brief Prototype for cellular event callbacks.
159166
*

0 commit comments

Comments
 (0)