nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
slm_at_host.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef SLM_AT_HOST_
8#define SLM_AT_HOST_
9
16#include <zephyr/types.h>
17#include <ctype.h>
18#include <nrf_modem_at.h>
19#include <modem/at_monitor.h>
20#include <modem/at_cmd_custom.h>
21#include <modem/at_parser.h>
22#include "slm_defines.h"
23
24/* This delay is necessary to send AT responses at low baud rates. */
25#define SLM_UART_RESPONSE_DELAY K_MSEC(50)
26
27#define SLM_DATAMODE_FLAGS_NONE 0
28#define SLM_DATAMODE_FLAGS_MORE_DATA (1 << 0)
29#define SLM_DATAMODE_FLAGS_EXIT_HANDLER (1 << 1)
30
31extern uint8_t slm_data_buf[SLM_MAX_MESSAGE_SIZE]; /* For socket data. */
32extern uint8_t slm_at_buf[SLM_AT_MAX_CMD_LEN + 1]; /* AT command buffer. */
33
34extern uint16_t slm_datamode_time_limit; /* Send trigger by time in data mode. */
35
38 DATAMODE_SEND, /* Send data in datamode */
39 DATAMODE_EXIT /* Exit data mode */
40};
41
48typedef int (*slm_datamode_handler_t)(uint8_t op, const uint8_t *data, int len, uint8_t flags);
49
50/* All the AT backend API functions return 0 on success. */
52 int (*start)(void);
53 int (*send)(const uint8_t *data, size_t len);
54 int (*stop)(void);
55};
58
64int slm_at_send(const uint8_t *data, size_t len);
65
67int slm_at_send_str(const char *str);
68
70void slm_at_receive(const uint8_t *data, size_t len);
71
79
86
89
94
101void rsp_send(const char *fmt, ...);
102
106void rsp_send_ok(void);
107
111void rsp_send_error(void);
112
120void data_send(const uint8_t *data, size_t len);
121
133
139bool in_datamode(void);
140
152bool exit_datamode_handler(int result);
153
155typedef int slm_at_callback(enum at_parser_cmd_type cmd_type, struct at_parser *parser,
156 uint32_t param_count);
157
170int slm_at_cb_wrapper(char *buf, size_t len, char *at_cmd, slm_at_callback cb);
171
182#define SLM_AT_CMD_CUSTOM(entry, _filter, _callback) \
183 static int _callback(enum at_parser_cmd_type cmd_type, struct at_parser *parser, \
184 uint32_t); \
185 static int _callback##_wrapper_##entry(char *buf, size_t len, char *at_cmd) \
186 { \
187 return slm_at_cb_wrapper(buf, len, at_cmd, _callback); \
188 } \
189 AT_CMD_CUSTOM(entry, _filter, _callback##_wrapper_##entry);
190
193#endif /* SLM_AT_HOST_ */
at_parser_cmd_type
Identifies the type of a given AT command prefix.
Definition: at_parser.h:26
slm_datamode_operation
Operations in data mode.
Definition: slm_at_host.h:37
@ DATAMODE_SEND
Definition: slm_at_host.h:38
@ DATAMODE_EXIT
Definition: slm_at_host.h:39
int slm_at_callback(enum at_parser_cmd_type cmd_type, struct at_parser *parser, uint32_t param_count)
SLM AT command callback type.
Definition: slm_at_host.h:155
bool in_datamode(void)
Check whether SLM AT host is in data mode.
int slm_at_send_str(const char *str)
Identical to slm_at_send(str, strlen(str)).
int slm_at_host_power_off(void)
Turns the current AT backend and UART power off.
int(* slm_datamode_handler_t)(uint8_t op, const uint8_t *data, int len, uint8_t flags)
Data mode sending handler type.
Definition: slm_at_host.h:48
void rsp_send(const char *fmt,...)
Send AT command response.
int slm_at_set_backend(struct slm_at_backend backend)
void rsp_send_ok(void)
Send AT command response of OK.
int slm_at_host_init(void)
Initialize AT host for serial LTE modem.
int slm_at_host_power_on(void)
Counterpart to slm_at_host_power_off().
uint8_t slm_at_buf[4096+1]
void data_send(const uint8_t *data, size_t len)
Send raw data received in data mode.
void rsp_send_error(void)
Send AT command response of ERROR.
int slm_at_send(const uint8_t *data, size_t len)
Sends the given data via the current AT backend.
bool exit_datamode_handler(int result)
Exit the data mode handler.
int enter_datamode(slm_datamode_handler_t handler)
Request SLM AT host to enter data mode.
void slm_at_host_uninit(void)
Uninitialize AT host for serial LTE modem.
uint16_t slm_datamode_time_limit
uint8_t slm_data_buf[NRF_SOCKET_TLS_MAX_MESSAGE_SIZE]
void slm_at_receive(const uint8_t *data, size_t len)
Processes received AT bytes.
int slm_at_cb_wrapper(char *buf, size_t len, char *at_cmd, slm_at_callback cb)
Generic wrapper for a custom SLM AT command callback.
#define SLM_AT_MAX_CMD_LEN
Definition: slm_defines.h:24
#define SLM_MAX_MESSAGE_SIZE
Definition: slm_defines.h:29
AT parser.
Definition: at_parser.h:45
Set of parser variables needed for parser framework to operate.
Definition: parser.h:55
int(* send)(const uint8_t *data, size_t len)
Definition: slm_at_host.h:53
int(* stop)(void)
Definition: slm_at_host.h:54
int(* start)(void)
Definition: slm_at_host.h:52
Definition: slm_at_host.h:51