2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-08-02 04:01:00 +08:00
|
|
|
zephyr_sources_ifdef(CONFIG_MODEM_RECEIVER modem_receiver.c)
|
2018-08-02 04:03:00 +08:00
|
|
|
zephyr_sources_ifdef(CONFIG_MODEM_SHELL modem_shell.c)
|
2019-02-19 18:17:51 +08:00
|
|
|
|
2019-08-07 23:01:00 +08:00
|
|
|
zephyr_sources_ifdef(CONFIG_MODEM_CONTEXT
|
|
|
|
modem_context.c
|
|
|
|
modem_pin.c
|
|
|
|
)
|
|
|
|
|
2019-08-07 23:02:00 +08:00
|
|
|
zephyr_sources_ifdef(CONFIG_MODEM_IFACE_UART modem_iface_uart.c)
|
drivers: modem: cmd handler: introduce cmd handler driver layer
This is a generic command handler implementation which uses the
supplied modem interface to process incoming data and hand it
back to the modem driver via callbacks defined for:
- modem responses
- unsolicited messages
- specified handlers for current operation
The individual modem drivers define functions as command handlers
via the MODEM_CMD_DEFINE() macro.
To use these handlers, a modem operation defines a series of
modem_cmd structures and passes them to the modem_cmd_send()
function. The modem_cmd includes data for:
- a matching string for when to execute the handler
- # of parameters to parse after the matching string
- delimeters for the parameters
Example modem driver setup code looks like this:
/* create modem context object */
static struct modem_context mctx;
/* net_buf receive pool */
NET_BUF_POOL_DEFINE(mdm_recv_pool, MDM_RECV_MAX_BUF,
MDM_RECV_BUF_SIZE, 0, NULL);
/* modem cmds */
static struct modem_cmd_handler_data cmd_handler_data;
static u8_t cmd_read_buf[MDM_RECV_BUF_SIZE];
static u8_t cmd_match_buf[MDM_RECV_BUF_SIZE];
/* modem response handlers */
static struct modem_cmd response_cmds[] = {
MODEM_CMD("OK", on_cmd_ok, 0U, ""),
MODEM_CMD("ERROR", on_cmd_error, 0U, ""),
MODEM_CMD("+CME ERROR: ", on_cmd_exterror, 1U, ""),
};
/* unsolicited handlers */
static struct modem_cmd unsol_cmds[] = {
MODEM_CMD("+UUSOCL: ", on_cmd_socknotifyclose, 1U, ""),
MODEM_CMD("+UUSORD: ", on_cmd_socknotifydata, 2U, ","),
MODEM_CMD("+UUSORF: ", on_cmd_socknotifydata, 2U, ","),
MODEM_CMD("+CREG: ", on_cmd_socknotifycreg, 1U, ""),
};
/* setup cmd handler data */
cmd_handler_data.cmds[CMD_RESP] = response_cmds;
cmd_handler_data.cmds_len[CMD_RESP] = ARRAY_SIZE(response_cmds);
cmd_handler_data.cmds[CMD_UNSOL] = unsol_cmds;
cmd_handler_data.cmds_len[CMD_UNSOL] = ARRAY_SIZE(unsol_cmds);
cmd_handler_data.read_buf = &cmd_read_buf[0];
cmd_handler_data.read_buf_len = sizeof(cmd_read_buf);
cmd_handler_data.match_buf = &cmd_match_buf[0];
cmd_handler_data.match_buf_len = sizeof(cmd_match_buf);
cmd_handler_data.buf_pool = &mdm_recv_pool;
cmd_handler_data.alloc_timeout = BUF_ALLOC_TIMEOUT;
ret = modem_cmd_handler_init(&mctx.cmd_handler, &cmd_handler_data);
Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-07 23:03:00 +08:00
|
|
|
zephyr_sources_ifdef(CONFIG_MODEM_CMD_HANDLER modem_cmd_handler.c)
|
2019-08-07 23:04:00 +08:00
|
|
|
zephyr_sources_ifdef(CONFIG_MODEM_SOCKET modem_socket.c)
|
2019-08-07 23:02:00 +08:00
|
|
|
|
2019-08-07 23:06:00 +08:00
|
|
|
if(CONFIG_MODEM_UBLOX_SARA)
|
2019-05-18 01:14:00 +08:00
|
|
|
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip)
|
|
|
|
zephyr_library_sources(ublox-sara-r4.c)
|
|
|
|
endif()
|
|
|
|
|
2019-02-19 18:17:51 +08:00
|
|
|
if(CONFIG_MODEM_WNCM14A2A)
|
|
|
|
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip)
|
|
|
|
zephyr_library_sources(wncm14a2a.c)
|
|
|
|
endif()
|