Extending the application
You can extend the serial LTE modem application by adding your own AT commands and custom error handling.
Adding AT commands
If you want to implement custom AT commands and add them to the serial LTE modem application, see the parser implementation of the provided proprietary AT commands for reference.
The source files can be found in the applications/nrf9160/serial_lte_modem/src/
folder.
Complete the following steps to add a parser for your own AT commands:
Create a header file in
applications/nrf9160/serial_lte_modem/src/
. The file must expose the following functions:*_init()
- Initialize the parser.*_uninit()
- Uninitialize the parser.
See the files for existing AT command parsers for reference.
Implement your AT strings and handlers in a corresponding
.c
file. See the files for existing AT command parsers for reference.Pay attention to the following requirements:
The names of new AT commands should start with
AT#X
.Before entering idle state, the serial LTE modem application will call the uninit function. Make sure that the uninit function exits successfully. Otherwise, the application cannot enter idle state.
Edit
applications/nrf9160/serial_lte_modem/src/slm_at_commands.c
and add calls to your functions:In
slm_at_init()
, add a call to your init function.In
slm_at_uninit()
, add a call to your uninit function.Declare your command handler like those of other service modules.
In
slm_at_cmd_list
, add the mapping of your AT command and its handler.
If you discover any bugs in the main.c
, slm_at_host.h
, or slm_at_host.c
files, report them on the DevZone.
Error handling
The serial LTE modem application returns error codes that are defined in zephyr/lib/libc/minimal/include/errno.h
.
See the comments in that file for information about a specific error.
If an error occurs during TCP/IP processing, the socket is usually closed. See the POSIX Programmer’s Manual for information about the errors returned by each API.