Skip to content

Commit 5ff8db8

Browse files
junqingzourlubos
authored andcommitted
samples: nrf9160: Serial LTE Modem sample
The Serial LTE Modem (SLM) project is an enhancement to at_client sample - support TCP/IP proprietary AT commands - support GPS proprietary AT commands - support communication to external MCU over UART Like original at_client, all modem AT commands are still supported. More proprietary AT commands could be added in the future. Signed-off-by: Jun Qing Zou <[email protected]>
1 parent 739daf4 commit 5ff8db8

File tree

15 files changed

+2111
-0
lines changed

15 files changed

+2111
-0
lines changed

doc/nrf/links.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
.. _`system mode section in the AT Commands reference document`: https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/mob_termination_ctrl_status/xsystemmode.html
5454

55+
.. _`AT Commands reference`: https://infocenter.nordicsemi.com/topic/ref_at_commands/REF/at_commands/intro.html
56+
5557

5658

5759
.. ### Links to the Nordic website
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Copyright (c) 2019 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
5+
#
6+
7+
cmake_minimum_required(VERSION 3.8.2)
8+
9+
# This sample runs as a non-secure application on nRF91. Therefore, it
10+
# requires the secure_partition_manager that prepares the required
11+
# peripherals to be available for the application.
12+
#
13+
# Configure the SPM image to enable the peripherals that this sample
14+
# needs.
15+
set(spm_CONF_FILE
16+
prj.conf
17+
${CMAKE_CURRENT_LIST_DIR}/child_secure_partition_manager.conf
18+
)
19+
20+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
21+
project(serial_lte_modem)
22+
23+
target_sources(app PRIVATE src/main.c)
24+
target_sources_ifdef(CONFIG_SLM_AT_MODE app PRIVATE src/slm_at_host.c)
25+
target_sources_ifdef(CONFIG_SLM_TCPIP_AT_MODE app PRIVATE src/slm_at_tcpip.c)
26+
target_sources_ifdef(CONFIG_SLM_GPS_AT_MODE app PRIVATE src/slm_at_gps.c)
27+
28+
zephyr_include_directories(src)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#
2+
# Copyright (c) 2019 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
5+
#
6+
7+
source "$ZEPHYR_BASE/Kconfig.zephyr"
8+
9+
menu "Nordic Serial LTE Modem"
10+
11+
config SLM_AT_MODE
12+
bool "Serial LTE Modem by raw AT mode"
13+
default y
14+
select AT_CMD
15+
select AT_CMD_PARSER
16+
17+
config SLM_AT_MAX_PARAM
18+
int "Max number of parameters in AT command"
19+
default 8
20+
21+
#
22+
# TCP/IP
23+
#
24+
config SLM_TCPIP_AT_MODE
25+
bool "Support TCP/IP by raw AT mode"
26+
default y
27+
28+
#
29+
# GPS
30+
#
31+
config SLM_GPS_AT_MODE
32+
bool "Support GPS by raw AT mode"
33+
default y
34+
35+
#
36+
# Inter-Connect
37+
#
38+
choice
39+
prompt "UART for Interconnect"
40+
default SLM_CONNECT_UART_0
41+
help
42+
Sets the UART to use for interconnect
43+
- UART 0
44+
- UART 1
45+
- UART 2
46+
config SLM_CONNECT_UART_0
47+
bool "UART 0"
48+
config SLM_CONNECT_UART_1
49+
bool "UART 1"
50+
config SLM_CONNECT_UART_2
51+
bool "UART 2"
52+
endchoice
53+
54+
config SLM_CONNECT_UART
55+
int
56+
default 0 if SLM_CONNECT_UART_0
57+
default 1 if SLM_CONNECT_UART_1
58+
default 2 if SLM_CONNECT_UART_2
59+
60+
choice
61+
prompt "Termination Mode"
62+
default SLM_CR_LF_TERMINATION
63+
help
64+
Sets the termination ending from the serial terminal
65+
Levels are:
66+
- NULL Termination
67+
- CR Termination
68+
- LF Termination
69+
- CR+LF Termination
70+
config SLM_NULL_TERMINATION
71+
bool "NULL Termination"
72+
config SLM_CR_TERMINATION
73+
bool "CR Termination"
74+
config SLM_LF_TERMINATION
75+
bool "LF Termination"
76+
config SLM_CR_LF_TERMINATION
77+
bool "CR+LF Termination"
78+
endchoice
79+
80+
config SLM_AT_HOST_TERMINATION
81+
int
82+
default 0 if SLM_NULL_TERMINATION
83+
default 1 if SLM_CR_TERMINATION
84+
default 2 if SLM_LF_TERMINATION
85+
default 3 if SLM_CR_LF_TERMINATION
86+
87+
#
88+
# GPIO wakeup
89+
#
90+
config SLM_GPIO_WAKEUP
91+
bool "Support of GPIO wakeup"
92+
help
93+
Enable GPIO wakeup on nRF9160 side
94+
95+
config SLM_MODEM_WAKEUP_PIN
96+
int "GPIO for wakeup"
97+
depends on SLM_GPIO_WAKEUP
98+
default 31
99+
100+
module = SLM
101+
module-str = serial modem
102+
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
103+
104+
endmenu
105+
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
.. _serial_lte_modem:
2+
3+
nRF9160: Serial LTE Modem
4+
#########################
5+
6+
The Serial LTE Modem (SLM) sample demostrates sending AT commands between a host and a client device.
7+
An nRF9160 DK is used as the host, while the client can be simulated using either a PC or an nRF52 DK.
8+
9+
This sample is an enhancement to the at_client sample. It provides the following features:
10+
11+
* Support for TCP/IP proprietary AT commands.
12+
* Support for GPS proprietary AT commands.
13+
* Support for communication to external MCU over UART.
14+
15+
All nRF91 modem AT commands are also supported.
16+
17+
Requirements
18+
************
19+
20+
* The following development board:
21+
22+
* nRF9160 DK board (PCA10090)
23+
24+
* If the client is a PC:
25+
26+
* Any terminal software, such as TeraTerm.
27+
28+
* If the client is an nRF52 device:
29+
30+
* nRF52840 DK board (PCA10056)
31+
* nRF52832 DK board (PCA10040)
32+
33+
.. terminal_config
34+
35+
Terminal connection
36+
===================
37+
38+
By default, configuration option ``CONFIG_SLM_CONNECT_UART_0`` is defined.
39+
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.
40+
41+
Terminal serial configuration:
42+
43+
* Hardware flow control: disabled
44+
* Baud rate: 115200
45+
* Parity bit: no
46+
47+
.. note::
48+
* The default AT command terminator is Carrier Return and Line Feed, i.e. ``\r\n``.
49+
* nRF91 logs are output to the same terminal port.
50+
51+
External MCU configuration
52+
==========================
53+
54+
To work with external MCU (nRF52), you must set the configuration option ``CONFIG_SLM_CONNECT_UART_2``.
55+
The pin interconnection between nRF91 and nRF52 is presented in the following table:
56+
57+
.. list-table::
58+
:align: center
59+
:header-rows: 1
60+
61+
* - nRF52 DK
62+
- nRF91 DK
63+
* - UART TX P0.6
64+
- UART RX P0.11
65+
* - UART RX P0.8
66+
- UART TX P0.10
67+
* - UART CTS P0.7
68+
- UART RTS P0.12
69+
* - UART RTS P0.5
70+
- UART RTS P0.13
71+
* - GPIO OUT P0.27
72+
- GPIO IN P0.31
73+
74+
UART instance in use:
75+
76+
* nRF52840 and nRF52832 (UART0)
77+
* nRF9160 (UART2)
78+
79+
UART configuration:
80+
81+
* Hardware flow control: enabled
82+
* Baud rate: 115200
83+
* Parity bit: no
84+
* Operation mode: IRQ
85+
86+
Note that the GPIO output level on nRF91 side should be 3 V.
87+
88+
TCP/IP AT commands
89+
******************
90+
91+
The following proprietary TCP/IP AT commands are used in this sample:
92+
93+
* AT#XSOCKET=<op>,<type>
94+
* AT#XSOCKET?
95+
* AT#XBIND=<local_ip>,<local_port>
96+
* AT#XTCPCONN=<url>,<port>
97+
* AT#XTCPCONN?
98+
* AT#XTCPSEND=<data>
99+
* AT#XTCPRECV=<length>,<time>
100+
* AT#XUDPSENDTO=<url>,<port>,<data>
101+
* AT#XUDPRECVFROM=<url>,<port>,<length>,<time>
102+
103+
GPS AT Commands
104+
***************
105+
106+
The following proprietary GPS AT commands are used in this sample:
107+
108+
109+
* AT#XGPSRUN=<op>[,<mask>]
110+
* AT#XGPSRUN?
111+
112+
Building and Running
113+
********************
114+
115+
.. |sample path| replace:: :file:`samples/nrf9160/serial_lte_modem`
116+
117+
.. include:: /includes/build_and_run_nrf9160.txt
118+
119+
The following configuration files are located in the :file:`samples/nrf9160/serial_lte_modem` directory:
120+
121+
- :file:`prj.conf`
122+
This is the standard default configuration file.
123+
- :file:`child_secure_partition_manager.conf`
124+
This is the project-specific Secure Partition Manager configuration file.
125+
126+
Testing
127+
=======
128+
129+
To test the sample with a PC client, open a terminal window and start sending AT commands to the nRF9160 DK.
130+
See `Terminal connection`_ section for the serial connection configuration details.
131+
132+
When testing the sample with an nRF52 client, the DKs go through the following start-up sequence:
133+
134+
1. nRF91 starts up and enters sleep state.
135+
#. nRF52 starts up and starts a periodical timer to toggle the GPIO interface.
136+
#. nRF52 deasserts the GPIO interface.
137+
#. nRF91 is woken up and sends a ``Ready\r\n`` message to the nRF52.
138+
#. On receiving the message, nRF52 can proceed to issue AT commands.
139+
140+
Dependencies
141+
************
142+
143+
This application uses the following |NCS| libraries and drivers:
144+
145+
* ``nrf/drivers/lte_link_control``
146+
* ``nrf/drivers/at_cmd``
147+
* ``nrf/lib/bsd_lib``
148+
* ``nrf/lib/at_cmd_parser``
149+
* nRF BSD Socket
150+
* Zephyr BSD socket
151+
152+
In addition, it uses the Secure Partition Manager sample:
153+
154+
* :ref:`secure_partition_manager`
155+
156+
References
157+
**********
158+
159+
* nRF91 `AT Commands reference`_ in Nordic Infocenter
160+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# Copyright (c) 2019 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
5+
#
6+
7+
# Set UARTE2 as non-secure, used for serial modem protocol
8+
CONFIG_SPM_NRF_UARTE2_NS=y
9+
10+
# Set REGULATORS as non-secure, used for sleep/wakeup
11+
CONFIG_SPM_NRF_REGULATORS_NS=y
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
&uart2 {
2+
current-speed = <115200>;
3+
status = "okay";
4+
tx-pin = <10>;
5+
rx-pin = <11>;
6+
rts-pin = <12>;
7+
cts-pin = <13>;
8+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright (c) 2019 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
5+
#
6+
# General config
7+
CONFIG_TEST_RANDOM_GENERATOR=y
8+
CONFIG_LOG=y
9+
CONFIG_LOG_DEFAULT_LEVEL=3
10+
CONFIG_STACK_SENTINEL=y
11+
12+
# Network
13+
CONFIG_NETWORKING=y
14+
CONFIG_NET_SOCKETS=y
15+
CONFIG_NET_NATIVE=n
16+
17+
# BSD library
18+
CONFIG_BSD_LIBRARY=y
19+
CONFIG_BSD_LIBRARY_TRACE_ENABLED=y
20+
21+
# Use GPIO
22+
CONFIG_GPIO=y
23+
CONFIG_GPIO_NRFX=y
24+
CONFIG_GPIO_NRF_P0=y
25+
26+
# UART interface
27+
CONFIG_SERIAL=y
28+
CONFIG_UART_INTERRUPT_DRIVEN=y
29+
CONFIG_UART_2_NRF_UARTE=y
30+
CONFIG_UART_2_NRF_FLOW_CONTROL=y
31+
32+
# LTE link control
33+
CONFIG_LTE_LINK_CONTROL=y
34+
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
35+
36+
# Stacks and heaps
37+
CONFIG_MAIN_THREAD_PRIORITY=7
38+
CONFIG_MAIN_STACK_SIZE=4096
39+
CONFIG_HEAP_MEM_POOL_SIZE=16384
40+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192
41+
42+
# AT_CMD
43+
#CONFIG_AT_CMD_LOG_LEVEL_DBG=y
44+
45+
# Application-specific
46+
CONFIG_SLM_AT_MODE=y
47+
CONFIG_SLM_TCPIP_AT_MODE=y
48+
CONFIG_SLM_GPS_AT_MODE=y
49+
CONFIG_SLM_LOG_LEVEL_INF=y
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sample:
2+
name: serial lte modem sample
3+
tests:
4+
test_build:
5+
build_only: true
6+
build_on_all: true
7+
platform_whitelist: nrf9160_pca10090ns
8+
tags: ci_build

0 commit comments

Comments
 (0)