Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
modem_cellular.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_CELLULAR_INTERNAL_H_
14#define ZEPHYR_INCLUDE_DRIVERS_CELLULAR_INTERNAL_H_
15
18#include <zephyr/drivers/uart.h>
19#include <zephyr/drivers/gpio.h>
20#include <zephyr/pm/device.h>
21#include <zephyr/modem/chat.h>
22#include <zephyr/modem/cmux.h>
23#include <zephyr/modem/pipe.h>
25#include <zephyr/modem/ppp.h>
27#include <zephyr/sys/atomic.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
40
42
43#define MODEM_CELLULAR_DATA_IMEI_LEN (16)
44#define MODEM_CELLULAR_DATA_SN_LEN (CONFIG_MODEM_CELLULAR_SERIAL_NUMBER_MAX_SIZE + 1)
45#define MODEM_CELLULAR_DATA_MODEL_ID_LEN (65)
46#define MODEM_CELLULAR_DATA_IMSI_LEN (23)
47#define MODEM_CELLULAR_DATA_ICCID_LEN (22)
48#define MODEM_CELLULAR_DATA_MANUFACTURER_LEN (65)
49#define MODEM_CELLULAR_DATA_FW_VERSION_LEN (65)
50#define MODEM_CELLULAR_DATA_APN_LEN (32)
51#define MODEM_CELLULAR_MAX_APN_CMDS (2)
52#define MODEM_CELLULAR_APN_BUF_SIZE (64)
53
54/* Zephyr networking interface states:
55 * NET_IF_LOWER_UP: Carrier is on in AWAIT_REGISTERED and REGISTERED
56 * NET_IF_DORMANT: Interface is dormant in every state except REGISTERED
57 */
58enum modem_cellular_state {
59 MODEM_CELLULAR_STATE_IDLE = 0,
60 MODEM_CELLULAR_STATE_RECOVERY,
61 MODEM_CELLULAR_STATE_RESET_PULSE,
62 MODEM_CELLULAR_STATE_AWAIT_RESET,
63 MODEM_CELLULAR_STATE_POWER_ON_PULSE,
64 MODEM_CELLULAR_STATE_AWAIT_POWER_ON,
65 MODEM_CELLULAR_STATE_SET_BAUDRATE,
66 MODEM_CELLULAR_STATE_RUN_INIT_SCRIPT,
67 MODEM_CELLULAR_STATE_CONNECT_CMUX,
68 MODEM_CELLULAR_STATE_OPEN_DLCI1,
69 MODEM_CELLULAR_STATE_OPEN_DLCI2,
70 MODEM_CELLULAR_STATE_RUN_BOARD_INIT_SCRIPT,
71 MODEM_CELLULAR_STATE_WAIT_FOR_APN,
72 MODEM_CELLULAR_STATE_RUN_APN_SCRIPT,
73 MODEM_CELLULAR_STATE_RUN_NETWORK_SCRIPT,
74 MODEM_CELLULAR_STATE_RUN_DIAL_SCRIPT,
75 MODEM_CELLULAR_STATE_AWAIT_REGISTERED,
76 MODEM_CELLULAR_STATE_REGISTERED,
77 MODEM_CELLULAR_STATE_AWAIT_PPP_DEAD,
78 MODEM_CELLULAR_STATE_INIT_POWER_OFF,
79 MODEM_CELLULAR_STATE_RUN_SHUTDOWN_SCRIPT,
80 MODEM_CELLULAR_STATE_POWER_OFF_PULSE,
81 MODEM_CELLULAR_STATE_AWAIT_POWER_OFF,
82 MODEM_CELLULAR_STATE_AWAIT_DIAL,
83};
84
85enum modem_cellular_event {
86 MODEM_CELLULAR_EVENT_RESUME = 0,
87 MODEM_CELLULAR_EVENT_SUSPEND,
88 MODEM_CELLULAR_EVENT_SCRIPT_SUCCESS,
89 MODEM_CELLULAR_EVENT_SCRIPT_FAILED,
90 MODEM_CELLULAR_EVENT_CMUX_CONNECTED,
91 MODEM_CELLULAR_EVENT_CMUX_DISCONNECTED,
92 MODEM_CELLULAR_EVENT_DLCI1_OPENED,
93 MODEM_CELLULAR_EVENT_DLCI2_OPENED,
94 MODEM_CELLULAR_EVENT_TIMEOUT,
95 MODEM_CELLULAR_EVENT_REGISTERED,
96 MODEM_CELLULAR_EVENT_DEREGISTERED,
97 MODEM_CELLULAR_EVENT_BUS_OPENED,
98 MODEM_CELLULAR_EVENT_BUS_CLOSED,
99 MODEM_CELLULAR_EVENT_PPP_DEAD,
100 MODEM_CELLULAR_EVENT_MODEM_READY,
101 MODEM_CELLULAR_EVENT_APN_SET,
102 MODEM_CELLULAR_EVENT_RING,
103 MODEM_CELLULAR_EVENT_PERIODIC_KICK,
104 MODEM_CELLULAR_EVENT_DIAL,
105 MODEM_CELLULAR_EVENT_HANGUP,
106} __packed;
107
108struct modem_cellular_event_cb {
111 void *user_data;
112};
113
114struct modem_cellular_event_pkg {
115 uint8_t event;
116 const void *ptr;
117};
118
120
131 /* UART backend */
132 struct modem_pipe *uart_pipe;
133 struct modem_backend_uart uart_backend;
134 uint8_t uart_backend_receive_buf[CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES];
135 uint8_t uart_backend_transmit_buf[CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES];
136 uint32_t original_baudrate;
137
138 /* CMUX */
139 struct modem_cmux cmux;
140 uint8_t cmux_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
141 uint8_t cmux_transmit_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
142
143 struct modem_cmux_dlci dlci1;
144 struct modem_cmux_dlci dlci2;
145 struct modem_pipe *dlci1_pipe;
146 struct modem_pipe *dlci2_pipe;
147 /* Points to dlci1_pipe or NULL. Used for shutdown script if not NULL */
148 struct modem_pipe *cmd_pipe;
149 uint8_t dlci1_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
150 /* DLCI 2 is only used for chat scripts. */
151 uint8_t dlci2_receive_buf[MODEM_CMUX_WORK_BUFFER_SIZE];
152
153 /* Modem chat */
154 struct modem_chat chat;
155 uint8_t chat_receive_buf[CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZE];
156 uint8_t *chat_argv[32];
157 uint8_t script_failure_counter;
158 uint8_t recovery_count;
159
160 /* Status */
161 enum cellular_registration_status registration_status_gsm;
162 enum cellular_registration_status registration_status_gprs;
163 enum cellular_registration_status registration_status_lte;
164 enum cellular_registration_status registration_status_5g;
165 enum cellular_access_technology access_tech;
166 uint8_t rssi;
167 uint8_t rsrp;
168 uint8_t rsrq;
169 struct cellular_evt_network_status network_status;
170 bool network_status_valid;
171 uint8_t imei[MODEM_CELLULAR_DATA_IMEI_LEN];
172 uint8_t sn[MODEM_CELLULAR_DATA_SN_LEN];
173 uint8_t model_id[MODEM_CELLULAR_DATA_MODEL_ID_LEN];
174 uint8_t imsi[MODEM_CELLULAR_DATA_IMSI_LEN];
175 uint8_t iccid[MODEM_CELLULAR_DATA_ICCID_LEN];
176 uint8_t manufacturer[MODEM_CELLULAR_DATA_MANUFACTURER_LEN];
177 uint8_t fw_version[MODEM_CELLULAR_DATA_FW_VERSION_LEN];
178 uint8_t apn[MODEM_CELLULAR_DATA_APN_LEN];
179
180 struct modem_chat_script_chat apn_chats[MODEM_CELLULAR_MAX_APN_CMDS];
181 struct modem_chat_script apn_script;
182 char apn_buf[MODEM_CELLULAR_MAX_APN_CMDS][MODEM_CELLULAR_APN_BUF_SIZE];
183
184 struct modem_chat_script board_init_script;
185
187#if defined(CONFIG_MODEM_CELLULAR_ON_DEMAND_CONNECT)
188 struct net_mgmt_event_callback if_event_callback;
189#endif
190
191 enum modem_cellular_state state;
193 const struct modem_chat_script *script_running;
194 const struct device *dev;
195 struct k_work_delayable timeout_work;
196
197 /* Power management */
198 struct k_sem suspended_sem;
199
200 /* Event dispatcher */
201 struct k_work event_dispatch_work;
202 struct k_msgq event_queue;
203 struct modem_cellular_event_pkg event_buf[8];
204 const void *event_ptr;
205
206 struct k_mutex api_lock;
207 struct modem_cellular_event_cb cb;
208
209 /* Ring interrupt */
210 struct gpio_callback ring_gpio_cb;
211
213 atomic_t periodic_paused;
215 bool periodic_timeout_skipped;
219 bool power_on_skipped;
221 bool suspend_pending;
223 bool cmux_connect_failed;
225 bool cmux_bus_opened;
226
227#if defined(CONFIG_MODEM_CELLULAR_STATS)
229 struct cellular_stats stats;
231 uint32_t stats_outage_start_ms;
232#endif
234};
235
237
238struct modem_cellular_user_pipe {
239 struct modem_cmux_dlci dlci;
240 uint8_t dlci_address;
241 uint8_t *dlci_receive_buf;
242 uint16_t dlci_receive_buf_size;
243 struct modem_pipe *pipe;
244 struct modem_pipelink *pipelink;
245};
246
248
278
324
326
327struct modem_cellular_config {
328 const struct device *uart;
329 const struct modem_cellular_vendor_config *vendor;
330 const void *vendor_specific;
331 struct modem_ppp *ppp;
332 struct gpio_dt_spec power_gpio;
333 struct gpio_dt_spec reset_gpio;
334 struct gpio_dt_spec wake_gpio;
335 struct gpio_dt_spec ring_gpio;
336 struct gpio_dt_spec dtr_gpio;
337 struct gpio_dt_spec status_gpio;
338 bool autostarts;
339 bool hold_reset_on_suspend;
340 bool reset_on_resume;
341 bool reset_on_recovery;
342 bool cmux_enable_runtime_power_save;
343 bool cmux_close_pipe_on_power_save;
344 bool cmux_no_powersave_handshake;
345 bool use_default_pdp_context;
346 bool use_default_apn;
347 k_timeout_t cmux_idle_timeout;
348 struct modem_cellular_user_pipe *user_pipes;
349 uint8_t user_pipes_size;
350};
351
355int modem_cellular_init(const struct device *dev);
356
357int modem_cellular_pm_action(const struct device *dev, enum pm_device_action action);
358
359extern const struct cellular_driver_api modem_cellular_api;
360
361void modem_cellular_emit_event(struct modem_cellular_data *data, enum cellular_event evt,
362 const void *payload);
363
364/*
365 * Store the latest serving-cell status and emit CELLULAR_EVENT_NETWORK_STATUS_CHANGED
366 * only when it changed, ignoring signal quality (rsrp/rsrq) so periodic polls do not
367 * re-fire the event on signal fluctuation.
368 */
369void modem_cellular_emit_network_status(struct modem_cellular_data *data,
370 const struct cellular_evt_network_status *status);
371
372void modem_cellular_chat_on_imei(struct modem_chat *chat, char **argv, uint16_t argc,
373 void *user_data);
374void modem_cellular_chat_on_cgsn_sn(struct modem_chat *chat, char **argv, uint16_t argc,
375 void *user_data);
376void modem_cellular_chat_on_cgsn_imei(struct modem_chat *chat, char **argv, uint16_t argc,
377 void *user_data);
378void modem_cellular_chat_on_cgmm(struct modem_chat *chat, char **argv, uint16_t argc,
379 void *user_data);
380void modem_cellular_chat_on_csq(struct modem_chat *chat, char **argv, uint16_t argc,
381 void *user_data);
382void modem_cellular_chat_on_cesq(struct modem_chat *chat, char **argv, uint16_t argc,
383 void *user_data);
384void modem_cellular_chat_on_iccid(struct modem_chat *chat, char **argv, uint16_t argc,
385 void *user_data);
386void modem_cellular_chat_on_imsi(struct modem_chat *chat, char **argv, uint16_t argc,
387 void *user_data);
388void modem_cellular_chat_on_cgmi(struct modem_chat *chat, char **argv, uint16_t argc,
389 void *user_data);
390void modem_cellular_chat_on_cgmr(struct modem_chat *chat, char **argv, uint16_t argc,
391 void *user_data);
392void modem_cellular_chat_on_cxreg(struct modem_chat *chat, char **argv, uint16_t argc,
393 void *user_data);
394void modem_cellular_chat_on_cgev(struct modem_chat *chat, char **argv, uint16_t argc,
395 void *user_data);
396void modem_cellular_chat_on_modem_ready(struct modem_chat *chat, char **argv, uint16_t argc,
397 void *user_data);
398
400
413 enum modem_chat_script_result result,
414 const struct modem_chat_script_completion_info *info,
415 void *user_data);
416
426
435#define MODEM_CELLULAR_INST_NAME(name, inst) \
436 CONCAT(name, _, DT_DRV_COMPAT, inst)
437
439
440#define MODEM_CELLULAR_DEFINE_USER_PIPE_DATA(inst, name, size) \
441 MODEM_PIPELINK_DT_INST_DEFINE(inst, name); \
442 static uint8_t MODEM_CELLULAR_INST_NAME(name, inst)[size] \
443
444#define MODEM_CELLULAR_INIT_USER_PIPE(_inst, _name, _dlci_address) \
445 { \
446 .dlci_address = _dlci_address, \
447 .dlci_receive_buf = MODEM_CELLULAR_INST_NAME(_name, _inst), \
448 .dlci_receive_buf_size = sizeof(MODEM_CELLULAR_INST_NAME(_name, _inst)), \
449 .pipelink = MODEM_PIPELINK_DT_INST_GET(_inst, _name), \
450 }
451
452#define MODEM_CELLULAR_DEFINE_USER_PIPES(inst, ...) \
453 static struct modem_cellular_user_pipe MODEM_CELLULAR_INST_NAME(user_pipes, inst)[] = { \
454 __VA_ARGS__ \
455 }
456
457#define MODEM_CELLULAR_GET_USER_PIPES(inst) \
458 MODEM_CELLULAR_INST_NAME(user_pipes, inst)
459
460/* Extract the first argument (pipe name) from a pair */
461#define MODEM_CELLULAR_GET_PIPE_NAME_ARG(arg1, ...) arg1
462
463/* Extract the second argument (DLCI address) from a pair */
464#define MODEM_CELLULAR_GET_DLCI_ADDRESS_ARG(arg1, arg2, ...) arg2
465
466/* Define user pipe data using instance and extracted pipe name */
467#define MODEM_CELLULAR_DEFINE_USER_PIPE_DATA_HELPER(_args, inst) \
468 MODEM_CELLULAR_DEFINE_USER_PIPE_DATA(inst, \
469 MODEM_CELLULAR_GET_PIPE_NAME_ARG _args, \
470 CONFIG_MODEM_CELLULAR_USER_PIPE_BUFFER_SIZES)
471
472/* Initialize user pipe using instance, extracted pipe name, and DLCI address */
473#define MODEM_CELLULAR_INIT_USER_PIPE_HELPER(_args, inst) \
474 MODEM_CELLULAR_INIT_USER_PIPE(inst, \
475 MODEM_CELLULAR_GET_PIPE_NAME_ARG _args, \
476 MODEM_CELLULAR_GET_DLCI_ADDRESS_ARG _args)
477
479
490#define MODEM_CELLULAR_DEFINE_AND_INIT_USER_PIPES(inst, ...) \
491 FOR_EACH_FIXED_ARG(MODEM_CELLULAR_DEFINE_USER_PIPE_DATA_HELPER, \
492 (;), inst, __VA_ARGS__); \
493 MODEM_CELLULAR_DEFINE_USER_PIPES( \
494 inst, \
495 FOR_EACH_FIXED_ARG(MODEM_CELLULAR_INIT_USER_PIPE_HELPER, \
496 (,), inst, __VA_ARGS__) \
497 );
498
509#define MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(_sym, _match, _separators, _callback) \
510 MODEM_CHAT_MATCHES_DEFINE(_sym, \
511 MODEM_CHAT_MATCH_INITIALIZER(_match, _separators, _callback, false, true), \
512 MODEM_CHAT_MATCH("OK", "", NULL))
513
521#define MODEM_CELLULAR_COMMON_CHAT_MATCHES() \
522 MODEM_CHAT_MATCH_DEFINE(ok_match, "OK", "", NULL); \
523 MODEM_CHAT_MATCHES_DEFINE(__maybe_unused allow_match, \
524 MODEM_CHAT_MATCH("OK", "", NULL), \
525 MODEM_CHAT_MATCH("ERROR", "", NULL)); \
526 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused imei_match, \
527 "", "", modem_cellular_chat_on_imei); \
528 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cgsn_sn_match, \
529 "", "", modem_cellular_chat_on_cgsn_sn); \
530 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cgsn_imei_match, \
531 "+CGSN: ", "", modem_cellular_chat_on_cgsn_imei); \
532 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cgmm_match, \
533 "", "", modem_cellular_chat_on_cgmm); \
534 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused csq_match, \
535 "+CSQ: ", ",", modem_cellular_chat_on_csq); \
536 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cesq_match, \
537 "+CESQ: ", ",", modem_cellular_chat_on_cesq); \
538 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused qccid_match, \
539 "+QCCID: ", "", modem_cellular_chat_on_iccid); \
540 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused iccid_match, \
541 "+ICCID: ", "", modem_cellular_chat_on_iccid); \
542 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused ccid_match, \
543 "+CCID: ", "", modem_cellular_chat_on_iccid); \
544 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cimi_match, \
545 "", "", modem_cellular_chat_on_imsi); \
546 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cgmi_match, \
547 "", "", modem_cellular_chat_on_cgmi); \
548 MODEM_CELLULAR_OK_CHAT_MATCH_DEFINE(__maybe_unused cgmr_match, \
549 "", "", modem_cellular_chat_on_cgmr); \
550 MODEM_CHAT_MATCH_DEFINE(connect_match __maybe_unused, \
551 "CONNECT", "", NULL); \
552 MODEM_CHAT_MATCHES_DEFINE(__maybe_unused abort_matches, \
553 MODEM_CHAT_MATCH("ERROR", "", NULL)); \
554 MODEM_CHAT_MATCHES_DEFINE(__maybe_unused dial_abort_matches, \
555 MODEM_CHAT_MATCH("ERROR", "", NULL), \
556 MODEM_CHAT_MATCH("BUSY", "", NULL), \
557 MODEM_CHAT_MATCH("NO ANSWER", "", NULL), \
558 MODEM_CHAT_MATCH("NO CARRIER", "", NULL), \
559 MODEM_CHAT_MATCH("NO DIALTONE", "", NULL))
560
567#define MODEM_CELLULAR_COMMON_UNSOL_MATCHES \
568 MODEM_CHAT_MATCH("+CREG: ", ",", modem_cellular_chat_on_cxreg), \
569 MODEM_CHAT_MATCH("+CEREG: ", ",", modem_cellular_chat_on_cxreg), \
570 MODEM_CHAT_MATCH("+CGREG: ", ",", modem_cellular_chat_on_cxreg), \
571 MODEM_CHAT_MATCH("+CGEV: ", ",", modem_cellular_chat_on_cgev), \
572 MODEM_CHAT_MATCH("APP RDY", "", modem_cellular_chat_on_modem_ready), \
573 MODEM_CHAT_MATCH("Ready", "", modem_cellular_chat_on_modem_ready)
574
588#define MODEM_CELLULAR_DEFINE_INSTANCE(inst, vendor_config, _vendor_specific) \
589 BUILD_ASSERT(vendor_config != NULL, "vendor_config must be non-NULL"); \
590 static const struct modem_cellular_config MODEM_CELLULAR_INST_NAME(config, inst) = { \
591 .uart = DEVICE_DT_GET(DT_INST_BUS(inst)), \
592 .vendor = vendor_config, \
593 .vendor_specific = _vendor_specific, \
594 .ppp = &MODEM_CELLULAR_INST_NAME(ppp, inst), \
595 .power_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_power_gpios, {}), \
596 .reset_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_reset_gpios, {}), \
597 .wake_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_wake_gpios, {}), \
598 .ring_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_ring_gpios, {}), \
599 .dtr_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_dtr_gpios, {}), \
600 .status_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_status_gpios, {}), \
601 .autostarts = DT_INST_PROP(inst, autostarts), \
602 .hold_reset_on_suspend = \
603 DT_INST_ENUM_HAS_VALUE(inst, zephyr_mdm_reset_behavior, hold_on_suspend), \
604 .reset_on_resume = DT_INST_ENUM_HAS_VALUE(inst, zephyr_mdm_reset_behavior, \
605 toggle_on_resume), \
606 .reset_on_recovery = DT_INST_ENUM_HAS_VALUE(inst, zephyr_mdm_reset_behavior, \
607 toggle_on_recovery), \
608 .cmux_enable_runtime_power_save = \
609 DT_INST_PROP_OR(inst, cmux_enable_runtime_power_save, 0), \
610 .cmux_close_pipe_on_power_save = \
611 DT_INST_PROP_OR(inst, cmux_close_pipe_on_power_save, 0), \
612 .cmux_no_powersave_handshake = \
613 DT_INST_PROP_OR(inst, cmux_no_powersave_handshake, 0), \
614 .use_default_pdp_context = DT_INST_PROP_OR(inst, zephyr_use_default_pdp_ctx, 0), \
615 .use_default_apn = DT_INST_PROP_OR(inst, zephyr_use_default_apn, 0), \
616 .cmux_idle_timeout = K_MSEC(DT_INST_PROP_OR(inst, cmux_idle_timeout_ms, 0)), \
617 .user_pipes = MODEM_CELLULAR_GET_USER_PIPES(inst), \
618 .user_pipes_size = ARRAY_SIZE(MODEM_CELLULAR_GET_USER_PIPES(inst)), \
619 }; \
620 \
621 PM_DEVICE_DT_INST_DEFINE(inst, modem_cellular_pm_action); \
622 \
623 DEVICE_DT_INST_DEFINE(inst, modem_cellular_init, PM_DEVICE_DT_INST_GET(inst), \
624 &MODEM_CELLULAR_INST_NAME(data, inst), \
625 &MODEM_CELLULAR_INST_NAME(config, inst), POST_KERNEL, \
626 CONFIG_MODEM_CELLULAR_INIT_PRIORITY, &modem_cellular_api);
627
634 const struct device *dev;
636};
637
650#if defined(CONFIG_MODEM_CELLULAR)
651#define MODEM_CELLULAR_BOARD_INIT_DEFINE(node_id, _script) \
652 static const STRUCT_SECTION_ITERABLE( \
653 modem_cellular_board_init, \
654 CONCAT(modem_cellular_board_init_, DT_DEP_ORD(node_id))) = { \
655 .dev = DEVICE_DT_GET(node_id), \
656 .script = (_script), \
657 }
658#else
659#define MODEM_CELLULAR_BOARD_INIT_DEFINE(node_id, _script)
660#endif
661
663
665
670
688
705
707
708#ifdef __cplusplus
709}
710#endif
711
712#endif /* ZEPHYR_INCLUDE_DRIVERS_CELLULAR_INTERNAL_H_ */
Header file for the Atomic operations API.
Main header file for cellular modem driver API.
Main header file for GPIO driver API.
Main header file for UART driver API.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
cellular_access_technology
Cellular access technologies (3GPP TS 27.007 AcT).
Definition cellular.h:39
cellular_event
Events emitted asynchronously by a cellular driver.
Definition cellular.h:145
int cellular_modem_pause_periodic_script(const struct device *dev)
Pause the cellular_modem driver's periodic chat script.
int cellular_modem_resume_periodic_script(const struct device *dev)
Resume the cellular_modem driver's periodic chat script.
cellular_registration_status
Cellular registration status (3GPP TS 27.007).
Definition cellular.h:117
uint32_t cellular_event_mask_t
Definition cellular.h:159
void(* cellular_event_cb_t)(const struct device *dev, enum cellular_event event, const void *payload, void *user_data)
Prototype for cellular event callbacks.
Definition cellular.h:234
void modem_cellular_chat_callback_handler(struct modem_chat *chat, enum modem_chat_script_result result, const struct modem_chat_script_completion_info *info, void *user_data)
Handle completion of a modem chat script.
modem_chat_script_result
Definition chat.h:250
pm_device_action
Device PM actions.
Definition device.h:154
state
Definition parser_state.h:29
Header file for the Device Power Management API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
<span class="mlabel">Driver Operations</span> Cellular driver operations
Definition cellular.h:284
Payload for CELLULAR_EVENT_NETWORK_STATUS_CHANGED.
Definition cellular.h:182
Cellular link operational statistics.
Definition cellular.h:205
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
GPIO callback structure.
Definition gpio.h:771
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
Message Queue Structure.
Definition kernel.h:5271
Kernel mutex structure.
Definition kernel.h:3514
Semaphore structure.
Definition kernel.h:3752
Kernel timeout type.
Definition clock.h:65
A structure used to submit work after a delay.
Definition kernel.h:4705
A structure used to submit work.
Definition kernel.h:4663
Definition uart.h:69
Descriptor binding a board-supplied init script to a modem instance.
Definition modem_cellular.h:633
const struct modem_chat_script * script
Definition modem_cellular.h:635
const struct device * dev
Definition modem_cellular.h:634
Chat scripts for cellular modem.
Definition modem_cellular.h:262
const struct modem_chat_script * periodic
Optional script that periodically polls modem state while registered.
Definition modem_cellular.h:272
const struct modem_chat_script * dial
Script that starts the PPP data connection.
Definition modem_cellular.h:270
const struct modem_chat_script * network
Optional script that waits for network registration before dialing.
Definition modem_cellular.h:268
const struct modem_chat_script * set_baudrate
Optional script that configures the modem's UART baud rate.
Definition modem_cellular.h:264
const struct modem_chat_script * shutdown
Optional script that prepares the modem for power-off.
Definition modem_cellular.h:274
const struct modem_chat_script * init
Script that initializes the modem and enables CMUX.
Definition modem_cellular.h:266
const struct modem_chat_script * dlci_setup
Optional script for configuring DLCI channels after opening.
Definition modem_cellular.h:276
Runtime data for a cellular modem driver instance.
Definition modem_cellular.h:129
Vendor-specific cellular modem configuration.
Definition modem_cellular.h:285
uint16_t shutdown_time_ms
Maximum modem shutdown delay, in milliseconds.
Definition modem_cellular.h:320
uint16_t reset_pulse_duration_ms
Duration of the modem reset pulse, in milliseconds.
Definition modem_cellular.h:311
bool force_autostart
Force autostart regardless of the devicetree autostarts property.
Definition modem_cellular.h:322
const char * chat_delimiter
Command delimiter used by the modem, as a NULL-terminated string.
Definition modem_cellular.h:300
struct modem_cellular_config_scripts scripts
Chat scripts implementing the modem lifecycle.
Definition modem_cellular.h:287
const struct modem_chat_match * matches
Array of unsolicited response matches, or NULL when size is zero.
Definition modem_cellular.h:291
uint16_t size
Number of elements in matches.
Definition modem_cellular.h:293
uint16_t power_pulse_duration_ms
Duration of the modem power-key pulse, in milliseconds.
Definition modem_cellular.h:309
const char * chat_filter
Characters filtered from modem responses, as a NULL-terminated string.
Definition modem_cellular.h:307
uint16_t cmux_disconnect_timeout_ms
Timeout for the modem to revert from CMUX to AT mode after a CMUX disconnect, in milliseconds.
Definition modem_cellular.h:316
uint16_t startup_time_ms
Maximum modem startup delay, in milliseconds.
Definition modem_cellular.h:318
struct modem_cellular_vendor_config::@176377142265263031027036153116374317160311334210 unsol_matches
Unsolicited modem response matches.
Modem chat match.
Definition chat.h:58
Modem chat script chat.
Definition chat.h:125
Extra information about the script that completed.
Definition chat.h:259
Modem chat script.
Definition chat.h:287
Chat instance internal context.
Definition chat.h:333
Network Management event callback structure Used to register a callback into the network management e...
Definition net_mgmt.h:164
Iterable sections helpers.