In this exercise, we will use the Serial LTE Modem application to send AT commands from an external computer to the modem. This way, we can send commands and read the response on a terminal emulator instead of through an application running on the device.
This sample enables the AT Host Library through the config CONFIG_AT_HOST_LIBRARY
. This will automatically spawn a thread to handle the AT commands, meaning to utilize this library, the only thing needed in your application is enabling it through the Kconfig.
Some of the terminal output logs displayed below and throughout other exercises will vary depending on your available network provider and network configurations.
1. Open the Quick Start application in nRF Connect for Desktop.
We are going to use the Quick Start application to flash this exercise sample to our device.
2. Select the device you are using.
The Quick Start application will search for devices connected to your computer. Select the DK or Thingy:91 X, depending on the board you are using, then select Continue.
3. Program the device.
Go through the steps until the Program section, then select AT Commands. Select Program to continue.
This will program the device with the Serial LTE modem application, which allows us to send AT commands to interface with the modem on the nRF91 Series SiP:
This course builds on the nRF Connect SDK Fundamentals course and focuses on Cellular IoT. You need to read Lesson 1 in the nRF Connect SDK Fundamentals to learn how to install nRF Connect SDK on your machine and build applications. Furthermore, completing the nRF Connect SDK Fundamentals course is strongly advised as it provides a comprehensive understanding of the nRF Connect SDK. The exercises in this course assume you have a basic understanding of the nRF Connect SDK.
1. Open the Serial LTE Modem application in VS Code, by selecting Browse samples -> nRF Connect SDK <version> -> Serial LTE Modem.
2. Add a build configuration, select All then select thingy91/nrf9160/ns
.
Make sure the Build after generating configuration option is enabled to trigger the build process after clicking on the Build Configuration button.
3. When the build is complete, flash the application to your device.
If you are using the Thingy:91 without an external debugger, make sure to follow the Thingy:91 flash procedure.
4. Open nRF Connect for Desktop and install and launch the Serial Terminal application. This is a terminal emulator for serial port connections and is what we will use to send AT commands to the modem.
4.1 In the upper left-hand corner, select your device.
4.2 Then select Connect to port.
4.3 Send the AT commands in the panel right above the terminal, where it says, “Type and press enter to send.”
Subscribe to notifications
5. Subscribe to network status notifications using +CEREG
.
We would like to receive unsolicited network status notifications. The command also lets you set how much information you would like in each notification, determined by setting between levels 1 and 5.
Let’s subscribe to a level-5 notification, through +CEREG
, by sending
AT+CEREG=5
When we turn on the modem, you should observe the following regular output printed intermittently.
+CEREG: <stat>, <tac>, <ci>, <AcT>, <cause_type>, <reject_cause>, <Active-Time>, <Periodic-TAU>
6. Subscribe to result code notifications using +CSCON
.
This command subscribes to unsolicited result code notifications, and the value you set determines how much information the notification contains between levels 1 and 3.
Let’s subscribe to level-1-related unsolicited notifications, through +CSCON
, by sending
AT+CSCON=1
When we turn on the modem, you should observe the following regular output printed intermittently.
+CSCON: <mode>
7. Set the system mode using %XSYSTEMMODE
.
Using LTE-M:
AT%XSYSTEMMODE=1,0,1,0
This command sets the system modes as LTE-M and GNSS.
Using NB-IoT:
AT%XSYSTEMMODE=0,1,1,0
This command sets the system modes as NB-IoT and GNSS.
Choose whichever system mode you will use in your application. Note the last parameter is 0
, meaning no LTE mode preference will be set.
This command must be set before the modem is turned on. If you try to use this command when the modem is operating, it will return ERROR
.
8. Turn on the modem using +CFUN
.
Set the modem to full functionality, which according to the documentation, is the value 1
.
AT+CFUN=1
9. Wait until the log output indicates we have a cellular connection.
Observe the unsolicited notifications from +CEREG
, and specifically stat
parameter indicating either
1 - Registered, home network
5 - Registered, roaming
+CEREG: 2,"76C1","030EB103",7
+CSCON: 1
+CEREG: 5,"76C1","030EB103",7,,,"11100000","11100000"
+CSCON: 0
TerminalHere we can see that the unsolicited notifications (+CEREG: 2
) indicate the UE is not registered but is either searching for an operator or trying to attach, and the modem is in RRC Connected mode (+CSCON: 1
). Then the UE attaches and is registered with a network (+CEREG: 5
), and the modem goes to RRC Idle mode (+CSON: 0
).
10. Store the current configurations to flash using +CFUN
.
Now that we’ve connected to a network, let’s store all the configurations to flash. This will store certain AT command configurations and the network information so that in the event of a reset, the device does not have to go through the same procedure again, thus speeding up the connection process.
Send the following commands, one after another.
AT+CFUN=0
AT+CFUN=1
This will save the current configurations and turn the modem on again.
The state of +CEREG
and +CSCON
are not stored when running AT+CFUN=0
. These commands must be run again if you want these unsolicited notifications.
Error handling
For error handling, let’s enable some error reporting functions through available AT commands
11. Let’s enable the use of the +CME
error codes in responses, through +CMEE
, by sending
AT+CMEE=1
12. Confirm this by sending an invalid command that we know returns a +CME
error.
Let’s try to set the system mode while the modem is on by sending the following
AT%XSYSTEMMODE=1,0,1,0
You should observe the following output
AT%XSYSTEMMODE=1,0,1,0
+CME ERROR: 518
TerminalAccording to the %XSYSTEMMODE
documentation, this means Not allowed in active state.
13. Let’s also activate unsolicited reporting of error codes sent by the network, via +CNEC
AT+CNEC=24
The above command enables both result code +CNEC_EMM
and +CNEC_ESM
.
Recall that the error codes that result from these notifications are documented in
+CNEC_EMM
: 3GPP TS 24.301 Table 9.9.3.9.1 for EPS mobility management errors codes+CNEC_ESM
: 3GPP TS 24.301 Table 9.9.4.4.1 for EPS session management errors codesPower saving techniques
14. Now we will test the available power-saving technique PSM
14.1 Calculate the timer value for 6 minutes <Active-Time>
and 8 hours <Periodic-TAU>
.
Recall the table for interpreting the different timers.
<Active-Time>
<Periodic-TAU>
<Active-Time>: Let’s choose the timer value unit corresponding to 6 minutes: 010
. Then the timer value should be 1 in binary: 00001
. This gives us 01000001
.
<Periodic-Tau>: The largest time value unit applicable is 1 hour: 001
. To get 8 hours, the timer value should be 8, which in binary is 01000
. This gives us 00101000
.
14.2 Enable power saving mode and request <Periodic-TAU>
be 8 hours and <Active-Time>
be 6 minutes, through +CPSMS
, by sending
AT+CPSMS=1,,,"00101000","01000001"
In the above command, we are setting a requested value for the periodic TAU timer and the Active-Time timer. Note that these can be ignored by the network.
AT+CPSMS?
will just read the values you are requesting, not the actual values set by the network.
14.3 Now that we’ve requested PSM let’s read out the values to confirm that it was actually enabled by the network. This is done by reading the value of <Active-Time>
, either using +CEREG
or %XMONITOR
. If it is deactivated, you do not have PSM.
Send the following command
AT%XMONITOR
Below are two examples of response messages, one where PSM was enabled and the requested values granted and the other where PSM was not enabled.
PSM enabled:
%XMONITOR: 5,"Telia","Telia","24202","0CE9",9,20,"020A6B1C",188,6254,51,29,"","00100110","00101001","01011111"
TerminalObserve the PSM values
<Active-Time>
: "00100110"
(6 minutes)<Periodic-TAU-ext>: "00101001"
(9 hours)PSM has been granted by the network with a slightly larger Periodic TAU than requested.
PSM not enabled:
%XMONITOR: 5,"","","24202","0901",7,20,"02024720",428,6300,52,36,"","11100000","11100000","01001001"
TerminalObserve that the PSM values requested in the previous step have not been granted by the network, and the field <Active-Time>
is indicating the timer is deactivated (11100000
).
PSM has not been enabled by the network and is most likely not supported by the network provider.
15. Now, we will test the available power-saving technique eDRX with PSM.
15.1 Disable PSM by sending the following command
AT+CPSMS=0
15.2 Enable eDRX by setting the applicable eDRX parameters, through +CEDRXS
, by sending
Requesting for LTE-M:
AT+CEDRXS=2,4,"0010"
Requesting for NB-IoT:
AT+CEDRXS=2,5,"0010"
The above command sets <mode>
to 2
which enables the use of eDRX and enables the unsolicited result code +CEDRXP
. <AcT-type>
sets for which AcT-type the value configured should apply (either 4 or 5, for LTE-M or NB-IoT, respectively), and requests the eDRX interval of 20,48 seconds (<Requested_eDRX_value>
to "0010"
).
15.3 Now that we’ve requested eDRX let’s read out the values to confirm that it was actually enabled by the network. Similar to +CPSMS
, the read command of +CEDRXS
will only return the requested values. To read the values from the network, we can either wait for the unsolicited notification (if <mode>
is 2
) or use +CEDRXRDP
.
Send the following command
AT+CEDRXRDP
Below are two examples of response messages, one where eDRX was enabled and the requested values granted and the other where eDRX was not enabled.
eDRX enabled:
+CEDRXRDP: 5,"0010","0010","0111"
TerminalObserve the eDRX values
<NW-Provided_eDRX_value>
: "0010"
(20.48 s)<Paging_time_window>: "0111"
(20.48 s)eDRX has been granted by the network with the requested eDRX Cycle.
eDRX not enabled:
+CEDRXRDP:5,"0010","",""
TerminalObserve that the eDRX Cycle requested has not been granted since the response does not contain the parameters.
eDRX has not been enabled by the network and is most likely not supported by the network provider.
If steps 14 and 15 were successful and you were granted both PSM and eDRX, proceed to the next step.
16 (Optional). Let’s enable PSM and check if eDRX and PSM are supported simultaneously by the network provider.
AT+CPSMS=1,,,"00101000","01000001"
In our case, we observe the following output
%XMONITOR: 5,"Telia","Telia","24202","0CE9",9,20,"020A6B1C",188,6254,53,31,"0010","00100110","00101001","01011111"
TerminalThis log output shows the following granted values
<NW-Provided_eDRX_value>
: "0010" (20.48 seconds)
<Active-Time>
: "00100110"
(6 minutes)<Periodic-TAU-ext>: "00101001"
(9 hours)
We have been granted both eDRX and PSM from the network.
Now you have practiced using AT commands to establish an LTE connection, read and understand notifications from the network and configure power saving techniques.
In this exercise, we will use the Serial LTE Modem application to send AT commands from an external computer to the modem. This way, we can send commands and read the response on a terminal emulator instead of through an application running on the device.
This sample enables the AT Host Library through the config CONFIG_AT_HOST_LIBRARY
. This will automatically spawn a thread to handle the AT commands, meaning to utilize this library, the only thing needed in your application is enabling it through the Kconfig.
Some of the terminal output logs displayed below and throughout other exercises will vary depending on your available network provider and network configurations.
1. Open the Quick Start application in nRF Connect for Desktop.
We are going to use the Quick Start application to flash this exercise sample to our device.
2. Select the nRF91 DK.
The Quick Start application will search for devices connected to your computer. Select the nRF91 DK, then select Continue.
3. Program the device.
Go through the steps until the Program section, then select AT Commands. Select Program to continue.
This will program the device with the Serial LTE modem application, which allows us to send AT commands to interface with the modem on the nRF91 Series SiP:
This course builds on the nRF Connect SDK Fundamentals course and focuses on Cellular IoT. You need to read Lesson 1 in the nRF Connect SDK Fundamentals to learn how to install nRF Connect SDK on your machine and build applications. Furthermore, completing the nRF Connect SDK Fundamentals course is strongly advised as it provides a comprehensive understanding of the nRF Connect SDK. The exercises in this course assume you have a basic understanding of the nRF Connect SDK.
1. Open the Serial LTE Modem application in VS Code, by selecting Browse samples -> nRF Connect SDK <version> -> Serial LTE Modem.
2. Add a build configuration, select All then select thingy91_nrf9160_ns
.
Make sure the Build after generating configuration option is enabled to trigger the build process after clicking on the Build Configuration button.
3. When the build is complete, flash the application to your device.
If you are using the Thingy:91 without an external debugger, make sure to follow the Thingy:91 flash procedure.
4. Open nRF Connect for Desktop and install and launch the Serial Terminal application. This is a terminal emulator for serial port connections and is what we will use to send AT commands to the modem.
4.1 In the upper left-hand corner, select your device.
4.2 Then select Connect to port.
4.3 Send the AT commands in the panel right above the terminal, where it says, “Type and press enter to send.”
Subscribe to notifications
5. Subscribe to network status notifications using +CEREG
.
We would like to receive unsolicited network status notifications. The command also lets you set how much information you would like in each notification, determined by setting between levels 1 and 5.
Let’s subscribe to a level-5 notification, through +CEREG
, by sending
AT+CEREG=5
When we turn on the modem, you should observe the following regular output printed intermittently.
+CEREG: <stat>, <tac>, <ci>, <AcT>, <cause_type>, <reject_cause>, <Active-Time>, <Periodic-TAU>
6. Subscribe to result code notifications using +CSCON
.
This command subscribes to unsolicited result code notifications, and the value you set determines how much information the notification contains between levels 1 and 3.
Let’s subscribe to level-1-related unsolicited notifications, through +CSCON
, by sending
AT+CSCON=1
When we turn on the modem, you should observe the following regular output printed intermittently.
+CSCON: <mode>
7. Set the system mode using %XSYSTEMMODE
.
Using LTE-M:
AT%XSYSTEMMODE=1,0,1,0
This command sets the system modes as LTE-M and GNSS.
Using NB-IoT:
AT%XSYSTEMMODE=0,1,1,0
This command sets the system modes as NB-IoT and GNSS.
Choose whichever system mode you will use in your application. Note the last parameter is 0
, meaning no LTE mode preference will be set.
This command must be set before the modem is turned on. If you try to use this command when the modem is operating, it will return ERROR
.
8. Turn on the modem using +CFUN
.
Set the modem to full functionality, which according to the documentation, is the value 1
.
AT+CFUN=1
9. Wait until the log output indicates we have a cellular connection.
Observe the unsolicited notifications from +CEREG
, and specifically stat
parameter indicating either
1 - Registered, home network
5 - Registered, roaming
+CEREG: 2,"76C1","030EB103",7
+CSCON: 1
+CEREG: 5,"76C1","030EB103",7,,,"11100000","11100000"
+CSCON: 0
TerminalHere we can see that the unsolicited notifications (+CEREG: 2
) indicate the UE is not registered but is either searching for an operator or trying to attach, and the modem is in RRC Connected mode (+CSCON: 1
). Then the UE attaches and is registered with a network (+CEREG: 5
), and the modem goes to RRC Idle mode (+CSON: 0
).
10. Store the current configurations to flash using +CFUN
.
Now that we’ve connected to a network, let’s store all the configurations to flash. This will store certain AT command configurations and the network information so that in the event of a reset, the device does not have to go through the same procedure again, thus speeding up the connection process.
Send the following commands, one after another.
AT+CFUN=0
AT+CFUN=1
This will save the current configurations and turn the modem on again.
The state of +CEREG
and +CSCON
are not stored when running AT+CFUN=0
. These commands must be run again if you want these unsolicited notifications.
Error handling
For error handling, let’s enable some error reporting functions through available AT commands
11. Let’s enable the use of the +CME
error codes in responses, through +CMEE
, by sending
AT+CMEE=1
12. Confirm this by sending an invalid command that we know returns a +CME
error.
Let’s try to set the system mode while the modem is on by sending the following
AT%XSYSTEMMODE=1,0,1,0
You should observe the following output
AT%XSYSTEMMODE=1,0,1,0
+CME ERROR: 518
TerminalAccording to the %XSYSTEMMODE
documentation, this means Not allowed in active state.
13. Let’s also activate unsolicited reporting of error codes sent by the network, via +CNEC
AT+CNEC=24
The above command enables both result code +CNEC_EMM
and +CNEC_ESM
.
Recall that the error codes that result from these notifications are documented in
+CNEC_EMM
: 3GPP TS 24.301 Table 9.9.3.9.1 for EPS mobility management errors codes+CNEC_ESM
: 3GPP TS 24.301 Table 9.9.4.4.1 for EPS session management errors codesPower saving techniques
14. Now we will test the available power-saving technique PSM
14.1 Calculate the timer value for 6 minutes <Active-Time>
and 8 hours <Periodic-TAU>
.
Recall the table for interpreting the different timers.
<Active-Time>
<Periodic-TAU>
<Active-Time>: Let’s choose the timer value unit corresponding to 6 minutes: 010
. Then the timer value should be 1 in binary: 00001
. This gives us 01000001
.
<Periodic-Tau>: The largest time value unit applicable is 1 hour: 001
. To get 8 hours, the timer value should be 8, which in binary is 01000
. This gives us 00101000
.
14.2 Enable power saving mode and request <Periodic-TAU>
be 8 hours and <Active-Time>
be 6 minutes, through +CPSMS
, by sending
AT+CPSMS=1,,,"00101000","01000001"
In the above command, we are setting a requested value for the periodic TAU timer and the Active-Time timer. Note that these can be ignored by the network.
AT+CPSMS?
will just read the values you are requesting, not the actual values set by the network.
14.3 Now that we’ve requested PSM let’s read out the values to confirm that it was actually enabled by the network. This is done by reading the value of <Active-Time>
, either using +CEREG
or %XMONITOR
. If it is deactivated, you do not have PSM.
Send the following command
AT%XMONITOR
Below are two examples of response messages, one where PSM was enabled and the requested values granted and the other where PSM was not enabled.
PSM enabled:
%XMONITOR: 5,"Telia","Telia","24202","0CE9",9,20,"020A6B1C",188,6254,51,29,"","00100110","00101001","01011111"
TerminalObserve the PSM values
<Active-Time>
: "00100110"
(6 minutes)<Periodic-TAU-ext>: "00101001"
(9 hours)PSM has been granted by the network with a slightly larger Periodic TAU than requested.
PSM not enabled:
%XMONITOR: 5,"","","24202","0901",7,20,"02024720",428,6300,52,36,"","11100000","11100000","01001001"
TerminalObserve that the PSM values requested in the previous step have not been granted by the network, and the field <Active-Time>
is indicating the timer is deactivated (11100000
).
PSM has not been enabled by the network and is most likely not supported by the network provider.
15. Now, we will test the available power-saving technique eDRX with PSM.
15.1 Disable PSM by sending the following command
AT+CPSMS=0
15.2 Enable eDRX by setting the applicable eDRX parameters, through +CEDRXS
, by sending
Requesting for LTE-M:
AT+CEDRXS=2,4,"0010"
Requesting for NB-IoT:
AT+CEDRXS=2,5,"0010"
The above command sets <mode>
to 2
which enables the use of eDRX and enables the unsolicited result code +CEDRXP
. <AcT-type>
sets for which AcT-type the value configured should apply (either 4 or 5, for LTE-M or NB-IoT, respectively), and requests the eDRX interval of 20,48 seconds (<Requested_eDRX_value>
to "0010"
).
15.3 Now that we’ve requested eDRX let’s read out the values to confirm that it was actually enabled by the network. Similar to +CPSMS
, the read command of +CEDRXS
will only return the requested values. To read the values from the network, we can either wait for the unsolicited notification (if <mode>
is 2
) or use +CEDRXRDP
.
Send the following command
AT+CEDRXRDP
Below are two examples of response messages, one where eDRX was enabled and the requested values granted and the other where eDRX was not enabled.
eDRX enabled:
+CEDRXRDP: 5,"0010","0010","0111"
TerminalObserve the eDRX values
<NW-Provided_eDRX_value>
: "0010"
(20.48 s)<Paging_time_window>: "0111"
(20.48 s)eDRX has been granted by the network with the requested eDRX Cycle.
eDRX not enabled:
+CEDRXRDP:5,"0010","",""
TerminalObserve that the eDRX Cycle requested has not been granted since the response does not contain the parameters.
eDRX has not been enabled by the network and is most likely not supported by the network provider.
If steps 14 and 15 were successful and you were granted both PSM and eDRX, proceed to the next step.
16 (Optional). Let’s enable PSM and check if eDRX and PSM are supported simultaneously by the network provider.
AT+CPSMS=1,,,"00101000","01000001"
In our case, we observe the following output
%XMONITOR: 5,"Telia","Telia","24202","0CE9",9,20,"020A6B1C",188,6254,53,31,"0010","00100110","00101001","01011111"
TerminalThis log output shows the following granted values
<NW-Provided_eDRX_value>
: "0010" (20.48 seconds)
<Active-Time>
: "00100110"
(6 minutes)<Periodic-TAU-ext>: "00101001"
(9 hours)
We have been granted both eDRX and PSM from the network.
Now you have practiced using AT commands to establish an LTE connection, read and understand notifications from the network and configure power saving techniques.
In this exercise, we will use the Serial LTE Modem application to send AT commands from an external computer to the modem. This way, we can send commands and read the response on a terminal emulator instead of through an application running on the device. This application can be used to emulate a stand-alone LTE modem on the nRF91 Series device.
This sample enables the AT Host Library through the config CONFIG_AT_HOST_LIBRARY
. This will automatically spawn a thread to handle the AT commands, meaning to utilize this library, the only thing needed in your application is enabling it through the Kconfig.
Some of the terminal output logs displayed below and throughout other exercises will vary depending on your available network provider and network configurations.
This course builds on the nRF Connect SDK Fundamentals course and focuses on Cellular IoT. You need to read Lesson 1 in the nRF Connect SDK Fundamentals to learn how to install nRF Connect SDK on your machine and build applications. Furthermore, completing the nRF Connect SDK Fundamentals course is strongly advised as it provides a comprehensive understanding of the nRF Connect SDK. The exercises in this course assume you have a basic understanding of the nRF Connect SDK.
1. Open the Serial LTE Modem application in VS Code, by selecting Browse samples -> nRF Connect SDK <version> -> Serial LTE Modem.
2. Add a build configuration, select All then select nrf9160dk_nrf9160_ns
.
Make sure the Build after generating configuration option is enabled to trigger the build process after clicking on the Build Configuration button.
3. When the build is complete, flash the application to your device.
This course builds on the nRF Connect SDK Fundamentals course and focuses on Cellular IoT. You need to read Lesson 1 in the nRF Connect SDK Fundamentals to learn how to install nRF Connect SDK on your machine and build applications. Furthermore, completing the nRF Connect SDK Fundamentals course is strongly advised as it provides a comprehensive understanding of the nRF Connect SDK. The exercises in this course assume you have a basic understanding of the nRF Connect SDK.
1. Open the Serial LTE Modem application in VS Code, by selecting Browse samples -> nRF Connect SDK <version> -> Serial LTE Modem.
2. Add a build configuration, select All then select thingy91_nrf9160_ns
.
Make sure the Build after generating configuration option is enabled to trigger the build process after clicking on the Build Configuration button.
3. When the build is complete, flash the application to your device.
If you are using the Thingy:91 without an external debugger, make sure to follow the Thingy:91 flash procedure.
4. Open nRF Connect for Desktop and install and launch the Serial Terminal application. This is a terminal emulator for serial port connections and is what we will use to send AT commands to the modem.
4.1 In the upper left-hand corner, select your device.
4.2 Then select Connect to port.
4.3 Send the AT commands in the panel right above the terminal, where it says, “Type and press enter to send.”
Subscribe to notifications
5. Subscribe to network status notifications using +CEREG
.
We would like to receive unsolicited network status notifications. The command also lets you set how much information you would like in each notification, determined by setting between levels 1 and 5.
Let’s subscribe to a level-5 notification, through +CEREG
, by sending
AT+CEREG=5
When we turn on the modem, you should observe the following regular output printed intermittently.
+CEREG: <stat>, <tac>, <ci>, <AcT>, <cause_type>, <reject_cause>, <Active-Time>, <Periodic-TAU>
6. Subscribe to result code notifications using +CSCON
.
This command subscribes to unsolicited result code notifications, and the value you set determines how much information the notification contains between levels 1 and 3.
Let’s subscribe to level-1-related unsolicited notifications, through +CSCON
, by sending
AT+CSCON=1
When we turn on the modem, you should observe the following regular output printed intermittently.
+CSCON: <mode>
7. Set the system mode using %XSYSTEMMODE
.
Using LTE-M:
AT%XSYSTEMMODE=1,0,1,0
This command sets the system modes as LTE-M and GNSS.
Using NB-IoT:
AT%XSYSTEMMODE=0,1,1,0
This command sets the system modes as NB-IoT and GNSS.
Choose whichever system mode you will use in your application. Note the last parameter is 0
, meaning no LTE mode preference will be set.
This command must be set before the modem is turned on. If you try to use this command when the modem is operating, it will return ERROR
.
8. Turn on the modem using +CFUN
.
Set the modem to full functionality, which according to the documentation, is the value 1
.
AT+CFUN=1
9. Wait until the log output indicates we have a cellular connection.
Observe the unsolicited notifications from +CEREG
, and specifically stat
parameter indicating either
1 - Registered, home network
5 - Registered, roaming
+CEREG: 2,"76C1","030EB103",7
+CSCON: 1
+CEREG: 5,"76C1","030EB103",7,,,"11100000","11100000"
+CSCON: 0
TerminalHere we can see that the unsolicited notifications (+CEREG: 2
) indicate the UE is not registered but is either searching for an operator or trying to attach, and the modem is in RRC Connected mode (+CSCON: 1
). Then the UE attaches and is registered with a network (+CEREG: 5
), and the modem goes to RRC Idle mode (+CSON: 0
).
10. Store the current configurations to flash using +CFUN
.
Now that we’ve connected to a network, let’s store all the configurations to flash. This will store certain AT command configurations and the network information so that in the event of a reset, the device does not have to go through the same procedure again, thus speeding up the connection process.
Send the following commands, one after another.
AT+CFUN=0
AT+CFUN=1
This will save the current configurations and turn the modem on again.
The state of +CEREG
and +CSCON
are not stored when running AT+CFUN=0
. These commands must be run again if you want these unsolicited notifications.
Error handling
For error handling, let’s enable some error reporting functions through available AT commands
11. Let’s enable the use of the +CME
error codes in responses, through +CMEE
, by sending
AT+CMEE=1
12. Confirm this by sending an invalid command that we know returns a +CME
error.
Let’s try to set the system mode while the modem is on by sending the following
AT%XSYSTEMMODE=1,0,1,0
You should observe the following output
AT%XSYSTEMMODE=1,0,1,0
+CME ERROR: 518
TerminalAccording to the %XSYSTEMMODE
documentation, this means Not allowed in active state.
13. Let’s also activate unsolicited reporting of error codes sent by the network, via +CNEC
AT+CNEC=24
The above command enables both result code +CNEC_EMM
and +CNEC_ESM
.
Recall that the error codes that result from these notifications are documented in
+CNEC_EMM
: 3GPP TS 24.301 Table 9.9.3.9.1 for EPS mobility management errors codes+CNEC_ESM
: 3GPP TS 24.301 Table 9.9.4.4.1 for EPS session management errors codesPower saving techniques
14. Now we will test the available power-saving technique PSM
14.1 Calculate the timer value for 6 minutes <Active-Time>
and 8 hours <Periodic-TAU>
.
Recall the table for interpreting the different timers.
<Active-Time>
<Periodic-TAU>
<Active-Time>: Let’s choose the timer value unit corresponding to 6 minutes: 010
. Then the timer value should be 1 in binary: 00001
. This gives us 01000001
.
<Periodic-Tau>: The largest time value unit applicable is 1 hour: 001
. To get 8 hours, the timer value should be 8, which in binary is 01000
. This gives us 00101000
.
14.2 Enable power saving mode and request <Periodic-TAU>
be 8 hours and <Active-Time>
be 6 minutes, through +CPSMS
, by sending
AT+CPSMS=1,,,"00101000","01000001"
In the above command, we are setting a requested value for the periodic TAU timer and the Active-Time timer. Note that these can be ignored by the network.
AT+CPSMS?
will just read the values you are requesting, not the actual values set by the network.
14.3 Now that we’ve requested PSM let’s read out the values to confirm that it was actually enabled by the network. This is done by reading the value of <Active-Time>
, either using +CEREG
or %XMONITOR
. If it is deactivated, you do not have PSM.
Send the following command
AT%XMONITOR
Below are two examples of response messages, one where PSM was enabled and the requested values granted and the other where PSM was not enabled.
PSM enabled:
%XMONITOR: 5,"Telia","Telia","24202","0CE9",9,20,"020A6B1C",188,6254,51,29,"","00100110","00101001","01011111"
TerminalObserve the PSM values
<Active-Time>
: "00100110"
(6 minutes)<Periodic-TAU-ext>: "00101001"
(9 hours)PSM has been granted by the network with a slightly larger Periodic TAU than requested.
PSM not enabled:
%XMONITOR: 5,"","","24202","0901",7,20,"02024720",428,6300,52,36,"","11100000","11100000","01001001"
TerminalObserve that the PSM values requested in the previous step have not been granted by the network, and the field <Active-Time>
is indicating the timer is deactivated (11100000
).
PSM has not been enabled by the network and is most likely not supported by the network provider.
15. Now, we will test the available power-saving technique eDRX with PSM.
15.1 Disable PSM by sending the following command
AT+CPSMS=0
15.2 Enable eDRX by setting the applicable eDRX parameters, through +CEDRXS
, by sending
Requesting for LTE-M:
AT+CEDRXS=2,4,"0010"
Requesting for NB-IoT:
AT+CEDRXS=2,5,"0010"
The above command sets <mode>
to 2
which enables the use of eDRX and enables the unsolicited result code +CEDRXP
. <AcT-type>
sets for which AcT-type the value configured should apply (either 4 or 5, for LTE-M or NB-IoT, respectively), and requests the eDRX interval of 20,48 seconds (<Requested_eDRX_value>
to "0010"
).
15.3 Now that we’ve requested eDRX let’s read out the values to confirm that it was actually enabled by the network. Similar to +CPSMS
, the read command of +CEDRXS
will only return the requested values. To read the values from the network, we can either wait for the unsolicited notification (if <mode>
is 2
) or use +CEDRXRDP
.
Send the following command
AT+CEDRXRDP
Below are two examples of response messages, one where eDRX was enabled and the requested values granted and the other where eDRX was not enabled.
eDRX enabled:
+CEDRXRDP: 5,"0010","0010","0111"
TerminalObserve the eDRX values
<NW-Provided_eDRX_value>
: "0010"
(20.48 s)<Paging_time_window>: "0111"
(20.48 s)eDRX has been granted by the network with the requested eDRX Cycle.
eDRX not enabled:
+CEDRXRDP:5,"0010","",""
TerminalObserve that the eDRX Cycle requested has not been granted since the response does not contain the parameters.
eDRX has not been enabled by the network and is most likely not supported by the network provider.
If steps 14 and 15 were successful and you were granted both PSM and eDRX, proceed to the next step.
16 (Optional). Let’s enable PSM and check if eDRX and PSM are supported simultaneously by the network provider.
AT+CPSMS=1,,,"00101000","01000001"
In our case, we observe the following output
%XMONITOR: 5,"Telia","Telia","24202","0CE9",9,20,"020A6B1C",188,6254,53,31,"0010","00100110","00101001","01011111"
TerminalThis log output shows the following granted values
<NW-Provided_eDRX_value>
: "0010" (20.48 seconds)
<Active-Time>
: "00100110"
(6 minutes)<Periodic-TAU-ext>: "00101001"
(9 hours)
We have been granted both eDRX and PSM from the network.
Now you have practiced using AT commands to establish an LTE connection, read and understand notifications from the network and configure power saving techniques.