nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
modem_slm.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef MODEM_SLM_H_
8#define MODEM_SLM_H_
9
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <stddef.h>
25#include <stdbool.h>
26#include <zephyr/types.h>
27#include <zephyr/kernel.h>
28#include <zephyr/sys/util_macro.h>
29#include <zephyr/toolchain.h>
30
32#define SLM_AT_CMD_RESPONSE_MAX_LEN 2100
33
43};
44
57typedef void (*slm_data_handler_t)(const uint8_t *data, size_t datalen);
58
64typedef void (*slm_ind_handler_t)(void);
65
73
78
88int modem_slm_register_ind(slm_ind_handler_t handler, bool wakeup);
89
96
102
116int modem_slm_send_cmd(const char *const command, uint32_t timeout);
117
126int modem_slm_send_data(const uint8_t *const data, size_t datalen);
127
133typedef void (*slm_monitor_handler_t)(const char *notif);
134
140 const char *filter;
144 uint8_t paused;
145};
146
148#define MON_ANY NULL
150#define MON_PAUSED 1
152#define MON_ACTIVE 0
153
164#define SLM_MONITOR(name, _filter, _handler, ...) \
165 static void _handler(const char *); \
166 static STRUCT_SECTION_ITERABLE(slm_monitor_entry, name) = { \
167 .filter = _filter, \
168 .handler = _handler, \
169 COND_CODE_1(__VA_ARGS__, (.paused = __VA_ARGS__,), ()) \
170 }
171
179static inline void slm_monitor_pause(struct slm_monitor_entry *mon)
180{
181 mon->paused = MON_PAUSED;
182}
183
191static inline void slm_monitor_resume(struct slm_monitor_entry *mon)
192{
193 mon->paused = MON_ACTIVE;
194}
195
196#ifdef __cplusplus
197}
198#endif
199
202#endif /* MODEM_SLM_H_ */
at_cmd_state
AT command result codes.
Definition: modem_slm.h:37
@ AT_CMD_OK
Definition: modem_slm.h:38
@ AT_CMD_ERROR_CMS
Definition: modem_slm.h:40
@ AT_CMD_ERROR_CME
Definition: modem_slm.h:41
@ AT_CMD_ERROR
Definition: modem_slm.h:39
@ AT_CMD_PENDING
Definition: modem_slm.h:42
int modem_slm_wake_up(void)
Wakeup nRF9160 SiP via MODEM_SLM_WAKEUP_PIN.
int modem_slm_uninit(void)
Un-initialize Modem SLM library.
int modem_slm_register_ind(slm_ind_handler_t handler, bool wakeup)
Register callback for MODEM_SLM_INDICATE_PIN indication.
int modem_slm_send_data(const uint8_t *const data, size_t datalen)
Function to send raw data in SLM data mode.
void(* slm_monitor_handler_t)(const char *notif)
SLM monitor callback.
Definition: modem_slm.h:133
void(* slm_ind_handler_t)(void)
Definition: modem_slm.h:64
int modem_slm_send_cmd(const char *const command, uint32_t timeout)
Function to send an AT command in SLM command mode.
static void slm_monitor_resume(struct slm_monitor_entry *mon)
Resume monitor.
Definition: modem_slm.h:191
int modem_slm_init(slm_data_handler_t handler)
Initialize Modem SLM library.
#define MON_ACTIVE
Definition: modem_slm.h:152
void modem_slm_reset_uart(void)
Reset the RX function of the serial interface.
void(* slm_data_handler_t)(const uint8_t *data, size_t datalen)
Definition: modem_slm.h:57
#define MON_PAUSED
Definition: modem_slm.h:150
static void slm_monitor_pause(struct slm_monitor_entry *mon)
Pause monitor.
Definition: modem_slm.h:179
const char * filter
Definition: modem_slm.h:140
uint8_t paused
Definition: modem_slm.h:144
const slm_monitor_handler_t handler
Definition: modem_slm.h:142
SLM monitor entry.
Definition: modem_slm.h:138