The SMS sample demonstrates how you can send and receive SMS messages with your nRF9160-based device.
The SMS sample registers the nRF9160-based device for SMS service within the nRF9160 modem using the SMS subscriber library. The sample requires an LTE connection.
When the sample starts, it sends SMS if a recipient phone number is set in the configuration. The sample then receives all the SMS messages and displays the information about the messages including the text that is sent.
The maximum size of the AT command response defined by
CONFIG_AT_CMD_RESPONSE_MAX_LEN might limit the size of the SMS message that can be received.
This parameter is defined in the AT command interface module.
Values over 512 bytes will not restrict the size of the received message as the maximum data length of the SMS is 140 bytes.
The sample supports the following development kit:
See Configuring your application for information about how to permanently or temporarily change the configuration.
Check and configure the following configuration option for the sample:
- Configuration for recipient phone number.¶
The sample configuration is used to set the recipient phone number if you need to send SMS.
Check and configure the following mandatory library options that are used by the sample:
Check and configure the following optional library options that are used by the sample:
This sample can be found under
samples/nrf9160/sms 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. You can also configure it to use TF-M instead of SPM.
See Building and programming an application for information about how to build and program the application.
After programming the sample to your development kit, test the sample by performing the following steps:
Connect the kit to the computer using a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.
Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.
Observe that the sample shows the UART output from the device. Note that this is an example, and the output need not be identical to your observed output.
Send an SMS message to the number associated with the SIM card that you have placed into your nRF9160-based device.
Not all IoT SIM cards support SMS service. You must check with your operator if the SMS service does not work as expected.
The following output is logged in the terminal:
*** Booting Zephyr OS build v2.4.99-ncs1-1818-g54dea0b2b530 *** SMS sample starting SMS sample is ready for receiving messages Sending SMS: number=1234567890, text="SMS sample: testing" SMS status report received SMS received: Time: 21-04-12 15:42:52 Text: 'Testing' Length: 7