nRF9160: Serial LTE Modem

The Serial LTE Modem (SLM) application demostrates sending AT commands between a host and a client device. An nRF9160 DK is used as the host, while the client can be simulated using either a PC or an nRF52 DK.

This application is an enhancement to the nRF9160: AT Client sample. It provides the following features:

  • Support for generic proprietary AT commands

  • Support for BSD Socket proprietary AT commands

  • Support for TCP/UDP proxy proprietary AT commands (optional)

  • Support for ICMP proprietary AT commands

  • Support for GPS proprietary AT commands

  • Support for MQTT client proprietary AT commands

  • Support for FTP client proprietary AT commands

  • Support for communication to external MCU over UART

All nRF91 modem AT commands are also supported.

Requirements

The application supports the following development kit:

Hardware platforms

PCA

Board name

Build target

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160ns

If the client is a PC, the application requires any terminal software, such as TeraTerm.

If the client is an nRF52 device, the application supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

Terminal connection

By default, configuration option CONFIG_SLM_CONNECT_UART_0 is defined. This means that you can use the J-Link COM port on the PC side to connect with nRF9160 DK, and send or receive AT commands there.

Terminal serial configuration:

  • Hardware flow control: disabled

  • Baud rate: 115200

  • Parity bit: no

Note

  • The default AT command terminator is Carrier Return and Line Feed, i.e. \r\n.

  • nRF91 logs are output to the same terminal port.

External MCU configuration

To work with the external MCU (nRF52), you must set the configuration options CONFIG_SLM_GPIO_WAKEUP and CONFIG_SLM_CONNECT_UART_2.

The pin interconnection between nRF91 and nRF52 is presented in the following table:

nRF52 DK

nRF91 DK

UART TX P0.6

UART RX P0.11

UART RX P0.8

UART TX P0.10

UART CTS P0.7

UART RTS P0.12

UART RTS P0.5

UART CTS P0.13

GPIO OUT P0.27

GPIO IN P0.31

UART instance in use:

  • nRF52840 and nRF52832 (UART0)

  • nRF9160 (UART2)

UART configuration:

  • Hardware flow control: enabled

  • Baud rate: 115200

  • Parity bit: no

  • Operation mode: IRQ

Note that the GPIO output level on nRF91 side should be 3 V.

Generic commands

The following proprietary generic AT commands are used in this application:

  • AT#XSLMVER

  • AT#XSLMUART=<baudrate>

  • AT#XSLEEP[=<shutdown_mode>]

  • AT#XCLAC

If the client sets new UART baudrate by AT#XSLMUART, the client should wait at least 100ms to send command in new baudrate.

BSD Socket AT commands

The following proprietary BSD socket AT commands are used in this application:

  • AT#XSOCKET=<op>[,<type>,<role>[,<sec_tag>]]

  • AT#XSOCKETOPT=<op>,<name>[,<value>]

  • AT#XBIND=<port>

  • AT#XLISTEN

  • AT#XACCEPT

  • AT#XCONNECT=<url>,<port>

  • AT#XSEND=<datatype>,<data>

  • AT#XRECV[=<length>]

  • AT#XSENDTO=<url>,<port>,<datatype>,<data>

  • AT#XRECVFROM[=<length>]

  • AT#XGETADDRINFO=<url>

If the configuration option CONFIG_SLM_TCP_PROXY is defined, the following AT commands are available to use the TCP proxy service:

  • AT#XTCPSVR=<op>[,<port>[,<sec_tag>]]

  • AT#XTCPCLI=<op>[,<url>,<port>[,<sec_tag>]

  • AT#XTCPSEND=<datatype>,<data>

  • AT#XTCPRECV[=<length>]

If the configuration option CONFIG_SLM_UDP_PROXY is defined, the following AT commands are available to use the UDP proxy service:

  • AT#XUDPSVR=<op>[,<port>]

  • AT#XUDPCLI=<op>[,<url>,<port>[,<sec_tag>]

  • AT#XUDPSEND=<datatype>,<data>

ICMP AT commands

The following proprietary ICMP AT commands are used in this application:

  • AT#XPING=<addr>,<length>,<timeout>[,<count>[,<interval>]]

GPS AT Commands

The following proprietary GPS AT commands are used in this application:

  • AT#XGPS=<op>[,<mask>]

If the configuration option CONFIG_SUPL_CLIENT_LIB is defined, SUPL A-GPS is enabled. Default SUPL server is as below: CONFIG_SLM_SUPL_SERVER=”supl.google.com” CONFIG_SLM_SUPL_PORT=7276

MQTT AT Commands

The following proprietary MQTT AT commands are used in this application:

  • AT#XMQTTCON=<op>[,<cid>,<username>,<password>,<url>,<port>[,<sec_tag>]]

  • AT#XMQTTPUB=<topic>,<datatype>,<msg>,<qos>,<retain>

  • AT#XMQTTSUB=<topic>,<qos>

  • AT#XMQTTUNSUB=<topic>

The following unsolicited notification indicates that an MQTT event occurred:

  • #XMQTTEVT=<type>,<result>

The following unsolicited notification indicates that a publish message was received and reports the topic and the message:

  • #XMQTTMSG=<datatype>,<topic_length>,<message_length><CR><LF><topic><CR><LF><message>

FTP AT Commands

The following proprietary FTP AT commands are used in this application:

  • AT#XFTP=<cmd>[,<param1>[<param2]..]]

The different command options for <cmd> are listed below:

  • AT#XFTP=”open”,<username>,<password>,<hostname>[,<port>[,<sec_tag>]]

  • AT#XFTP=”status”

  • AT#XFTP=”ascii”

  • AT#XFTP=”binary”

  • AT#XFTP=”close”

  • AT#XFTP=”pwd”

  • AT#XFTP=”cd”,<folder>

  • AT#XFTP=”ls”[,<options>[,<folder or file>]]

  • AT#XFTP=”mkdir”,<folder>

  • AT#XFTP=”rmdir”,<folder>

  • AT#XFTP=”rename”,<filename_old>,<filename_new>

  • AT#XFTP=”delete”,<file>

  • AT#XFTP=”get”,<file>

  • AT#XFTP=”put”,<file>[<datatype>,<data>]

Building and Running

This sample can be found under applications/nrf9160/serial_lte_modem in the nRF Connect SDK folder structure.

The sample is built as a non-secure firmware image for the nrf9160dk_nrf9160ns build target. Because of this, it automatically includes the Secure Partition Manager.

See Building and programming a sample application for information about how to build and program the application.

The following configuration files are located in the applications/nrf9160/serial_lte_modem directory:

  • prj.conf This is the standard default configuration file.

  • child_secure_partition_manager.conf This is the project-specific Secure Partition Manager configuration file.

Testing

To test the application with a PC client, open a terminal window and start sending AT commands to the nRF9160 DK. See Terminal connection section for the serial connection configuration details.

When testing the application with an nRF52 client, the DKs go through the following start-up sequence:

  1. nRF91 starts up and enters sleep state.

  2. nRF52 starts up and starts a periodical timer to toggle the GPIO interface.

  3. nRF52 deasserts the GPIO interface.

  4. nRF91 is woken up and sends a Ready\r\n message to the nRF52.

  5. On receiving the message, nRF52 can proceed to issue AT commands.

Dependencies

This application uses the following nRF Connect SDK libraries and drivers:

  • nrf/drivers/lte_link_control

  • nrf/drivers/at_cmd

  • nrf/lib/bsd_lib

  • nrf/lib/at_cmd_parser

  • nrf/lib/at_notif

  • nrf/lib/modem_info

  • nrf/subsys/net/lib/ftp_client

In addition, it uses the Secure Partition Manager sample:

References