Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/nrf/links.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

.. _`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

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



.. ### Links to the Nordic website
Expand Down
28 changes: 28 additions & 0 deletions samples/nrf9160/serial_lte_modem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2019 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

cmake_minimum_required(VERSION 3.8.2)

# This sample runs as a non-secure application on nRF91. Therefore, it
# requires the secure_partition_manager that prepares the required
# peripherals to be available for the application.
#
# Configure the SPM image to enable the peripherals that this sample
# needs.
set(spm_CONF_FILE
prj.conf
${CMAKE_CURRENT_LIST_DIR}/child_secure_partition_manager.conf
)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(serial_lte_modem)

target_sources(app PRIVATE src/main.c)
target_sources_ifdef(CONFIG_SLM_AT_MODE app PRIVATE src/slm_at_host.c)
target_sources_ifdef(CONFIG_SLM_TCPIP_AT_MODE app PRIVATE src/slm_at_tcpip.c)
target_sources_ifdef(CONFIG_SLM_GPS_AT_MODE app PRIVATE src/slm_at_gps.c)

zephyr_include_directories(src)
105 changes: 105 additions & 0 deletions samples/nrf9160/serial_lte_modem/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Copyright (c) 2019 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

source "$ZEPHYR_BASE/Kconfig.zephyr"

menu "Nordic Serial LTE Modem"

config SLM_AT_MODE
bool "Serial LTE Modem by raw AT mode"
default y
select AT_CMD
select AT_CMD_PARSER

config SLM_AT_MAX_PARAM
int "Max number of parameters in AT command"
default 8

#
# TCP/IP
#
config SLM_TCPIP_AT_MODE
bool "Support TCP/IP by raw AT mode"
default y

#
# GPS
#
config SLM_GPS_AT_MODE
bool "Support GPS by raw AT mode"
default y

#
# Inter-Connect
#
choice
prompt "UART for Interconnect"
default SLM_CONNECT_UART_0
help
Sets the UART to use for interconnect
- UART 0
- UART 1
- UART 2
config SLM_CONNECT_UART_0
bool "UART 0"
config SLM_CONNECT_UART_1
bool "UART 1"
config SLM_CONNECT_UART_2
bool "UART 2"
endchoice

config SLM_CONNECT_UART
int
default 0 if SLM_CONNECT_UART_0
default 1 if SLM_CONNECT_UART_1
default 2 if SLM_CONNECT_UART_2

choice
prompt "Termination Mode"
default SLM_CR_LF_TERMINATION
help
Sets the termination ending from the serial terminal
Levels are:
- NULL Termination
- CR Termination
- LF Termination
- CR+LF Termination
config SLM_NULL_TERMINATION
bool "NULL Termination"
config SLM_CR_TERMINATION
bool "CR Termination"
config SLM_LF_TERMINATION
bool "LF Termination"
config SLM_CR_LF_TERMINATION
bool "CR+LF Termination"
endchoice

config SLM_AT_HOST_TERMINATION
int
default 0 if SLM_NULL_TERMINATION
default 1 if SLM_CR_TERMINATION
default 2 if SLM_LF_TERMINATION
default 3 if SLM_CR_LF_TERMINATION

#
# GPIO wakeup
#
config SLM_GPIO_WAKEUP
bool "Support of GPIO wakeup"
help
Enable GPIO wakeup on nRF9160 side

config SLM_MODEM_WAKEUP_PIN
int "GPIO for wakeup"
depends on SLM_GPIO_WAKEUP
default 31

module = SLM
module-str = serial modem
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

endmenu

160 changes: 160 additions & 0 deletions samples/nrf9160/serial_lte_modem/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
.. _serial_lte_modem:

nRF9160: Serial LTE Modem
#########################

The Serial LTE Modem (SLM) sample 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 sample is an enhancement to the at_client sample. It provides the following features:

* Support for TCP/IP proprietary AT commands.
* Support for GPS proprietary AT commands.
* Support for communication to external MCU over UART.

All nRF91 modem AT commands are also supported.

Requirements
************

* The following development board:

* nRF9160 DK board (PCA10090)

* If the client is a PC:

* Any terminal software, such as TeraTerm.

* If the client is an nRF52 device:

* nRF52840 DK board (PCA10056)
* nRF52832 DK board (PCA10040)

.. terminal_config

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 external MCU (nRF52), you must set the configuration option ``CONFIG_SLM_CONNECT_UART_2``.
The pin interconnection between nRF91 and nRF52 is presented in the following table:

.. list-table::
:align: center
:header-rows: 1

* - 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 RTS 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.

TCP/IP AT commands
******************

The following proprietary TCP/IP AT commands are used in this sample:

* AT#XSOCKET=<op>,<type>
* AT#XSOCKET?
* AT#XBIND=<local_ip>,<local_port>
* AT#XTCPCONN=<url>,<port>
* AT#XTCPCONN?
* AT#XTCPSEND=<data>
* AT#XTCPRECV=<length>,<time>
* AT#XUDPSENDTO=<url>,<port>,<data>
* AT#XUDPRECVFROM=<url>,<port>,<length>,<time>

GPS AT Commands
***************

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


* AT#XGPSRUN=<op>[,<mask>]
* AT#XGPSRUN?

Building and Running
********************

.. |sample path| replace:: :file:`samples/nrf9160/serial_lte_modem`

.. include:: /includes/build_and_run_nrf9160.txt

The following configuration files are located in the :file:`samples/nrf9160/serial_lte_modem` directory:

- :file:`prj.conf`
This is the standard default configuration file.
- :file:`child_secure_partition_manager.conf`
This is the project-specific Secure Partition Manager configuration file.

Testing
=======

To test the sample 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 sample with an nRF52 client, the DKs go through the following start-up sequence:

1. nRF91 starts up and enters sleep state.
#. nRF52 starts up and starts a periodical timer to toggle the GPIO interface.
#. nRF52 deasserts the GPIO interface.
#. nRF91 is woken up and sends a ``Ready\r\n`` message to the nRF52.
#. On receiving the message, nRF52 can proceed to issue AT commands.

Dependencies
************

This application uses the following |NCS| libraries and drivers:

* ``nrf/drivers/lte_link_control``
* ``nrf/drivers/at_cmd``
* ``nrf/lib/bsd_lib``
* ``nrf/lib/at_cmd_parser``
* nRF BSD Socket
* Zephyr BSD socket

In addition, it uses the Secure Partition Manager sample:

* :ref:`secure_partition_manager`

References
**********

* nRF91 `AT Commands reference`_ in Nordic Infocenter

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

# Set UARTE2 as non-secure, used for serial modem protocol
CONFIG_SPM_NRF_UARTE2_NS=y

# Set REGULATORS as non-secure, used for sleep/wakeup
CONFIG_SPM_NRF_REGULATORS_NS=y
8 changes: 8 additions & 0 deletions samples/nrf9160/serial_lte_modem/nrf9160_pca10090ns.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
&uart2 {
Comment thread
lemrey marked this conversation as resolved.
Outdated
current-speed = <115200>;
status = "okay";
tx-pin = <10>;
rx-pin = <11>;
rts-pin = <12>;
cts-pin = <13>;
};
49 changes: 49 additions & 0 deletions samples/nrf9160/serial_lte_modem/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
# General config
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the default, so this should be redundant.

CONFIG_STACK_SENTINEL=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_NATIVE=n

# BSD library
CONFIG_BSD_LIBRARY=y
CONFIG_BSD_LIBRARY_TRACE_ENABLED=y

# Use GPIO
CONFIG_GPIO=y
CONFIG_GPIO_NRFX=y
CONFIG_GPIO_NRF_P0=y

# UART interface
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_2_NRF_UARTE=y
CONFIG_UART_2_NRF_FLOW_CONTROL=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# Stacks and heaps
CONFIG_MAIN_THREAD_PRIORITY=7
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192

# AT_CMD
#CONFIG_AT_CMD_LOG_LEVEL_DBG=y

# Application-specific
Comment thread
rlubos marked this conversation as resolved.
Outdated
CONFIG_SLM_AT_MODE=y
CONFIG_SLM_TCPIP_AT_MODE=y
CONFIG_SLM_GPS_AT_MODE=y
CONFIG_SLM_LOG_LEVEL_INF=y
8 changes: 8 additions & 0 deletions samples/nrf9160/serial_lte_modem/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sample:
name: serial lte modem sample
tests:
test_build:
build_only: true
build_on_all: true
platform_whitelist: nrf9160_pca10090ns
tags: ci_build
Loading