Skip to content

Commit 7a39db1

Browse files
jtguggedalrlubos
authored andcommitted
applications: asset_tracker_v2: Add modem module documentation
Add documentation of the modem module. Signed-off-by: Jan Tore Guggedal <[email protected]>
1 parent 85c69f5 commit 7a39db1

File tree

4 files changed

+249
-2
lines changed

4 files changed

+249
-2
lines changed

applications/asset_tracker_v2/README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ See the subpages for detailed documentation on the application and its internal
2222
doc/cloud_module
2323
doc/cloud_wrapper
2424
doc/debug_module
25+
doc/gnss_module
26+
doc/modem_module
2527
doc/sensor_module
2628
doc/ui_module
27-
doc/gnss_module
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
.. _asset_tracker_v2_modem_module:
2+
3+
Modem module
4+
############
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The modem module communicates with the modem to control the LTE connection and retrieve information from the modem about the device and LTE network.
11+
12+
Features
13+
********
14+
15+
This section documents the features implemented by the module.
16+
17+
LTE connection handling
18+
=======================
19+
20+
The module uses the :ref:`lte_lc_readme` library to control and monitor the LTE connection.
21+
The module registers an event handler with :ref:`lte_lc_readme` to receive updates from the modem about the state of the LTE connection and network information.
22+
If you use the :ref:`liblwm2m_carrier_readme` library, refer to :ref:`modem_module_carrier_lib` for additional information on LTE connection handling.
23+
24+
In its default configuration, the modem module makes an attempt to establish an LTE connection immediately when it is initialized.
25+
There is no timeout on the connection attempt, so the modem searches for a suitable LTE network until it finds one.
26+
27+
When the device is registered to an LTE network, the LTE connection is considered to be established, and a :c:enum:`MODEM_EVT_LTE_CONNECTED` event is sent.
28+
If the network registration is lost at some point, a :c:enum:`MODEM_EVT_LTE_DISCONNECTED` event is sent.
29+
30+
If the device connects to a new LTE cell, an :c:enum:`LTE_LC_EVT_CELL_UPDATE` is sent.
31+
The event contains cell ID and tracking area code as payload, which can be used to determine the device's coarse position.
32+
33+
If the modem module receives an ``APP_EVT_LTE_DISCONNECT`` event, it instructs the modem to detach from the network, and a subsequent :c:enum:`MODEM_EVT_LTE_DISCONNECTED` event can be expected after the disconnect.
34+
35+
To configure the LTE connection parameters, refer to the :ref:`lte_lc_readme` Kconfig options.
36+
These options can be used to select the access technology to use (LTE-M or NB-IoT), default values for :term:`Power Saving Mode (PSM)` timers and more.
37+
38+
Note that some network parameters, such as PSM timer values, are requests to the network and might not be granted as requested, and the network might grant a different value than the requested values or deny the request altogether.
39+
The actual values that are received from the network are distributed in :c:enum:`MODEM_EVT_LTE_PSM_UPDATE` events.
40+
41+
.. _modem_module_carrier_lib:
42+
43+
Carrier library support
44+
=======================
45+
46+
The modem module has support for the :ref:`liblwm2m_carrier_readme` library.
47+
When the library is enabled, the modem module leaves the LTE connection handling to the library in order to adhere to the specific carrier's requirements.
48+
49+
If the :ref:`liblwm2m_carrier_readme` library starts a modem firmware update, the modem module sends a :c:enum:`MODEM_EVT_CARRIER_FOTA_PENDING` event.
50+
This event signals that a modem firmware FOTA download is about to start, and all the other TLS connections in the system must be closed, including any cloud connection.
51+
After a successful FOTA, :c:enum:`MODEM_EVT_CARRIER_REBOOT_REQUEST` is sent, indicating that the application must perform a graceful shutdown and reboot the device to apply the new modem firmware.
52+
If a FOTA download fails, a :c:enum:`MODEM_EVT_CARRIER_FOTA_STOPPED` event is sent, and the application might again establish TLS connections and continue normal operation.
53+
54+
For more details and configuration options, you can refer to :ref:`liblwm2m_carrier_readme`.
55+
56+
Modem information
57+
=================
58+
59+
When the application module sends out an ``APP_EVT_DATA_GET`` event, the modem module checks the requested data list for relevant requests:
60+
61+
* ``APP_DATA_MODEM_STATIC`` - Static modem data, such as configured system mode (any combination of LTE-M, NB-IoT and GNSS), ICCID, modem firmware version, application version and board version.
62+
* ``APP_DATA_MODEM_DYNAMIC`` - Dynamic modem data, such as Cell ID, tracking area code, RSRP, IP address and PLMN (MCCMNC).
63+
* ``APP_DATA_BATTERY`` - Voltage of the modem's power supply.
64+
65+
The module uses :ref:`modem_info_readme` to acquire information about the modem, LTE network and the modem's power supply.
66+
The response for the three different data types is sent as separate events:
67+
68+
* Static data as :c:enum:`MODEM_EVT_MODEM_STATIC_DATA_READY`
69+
* Dynamic data as :c:enum:`MODEM_EVT_MODEM_DYNAMIC_DATA_READY`
70+
* Battery voltage as :c:enum:`MODEM_EVT_BATTERY_DATA_READY`
71+
72+
If the sampling of data fails, a corresponding error message is sent through one of the following events:
73+
74+
* :c:enum:`MODEM_EVT_MODEM_STATIC_DATA_NOT_READY`
75+
* :c:enum:`MODEM_EVT_MODEM_DYNAMIC_DATA_NOT_READY`
76+
* :c:enum:`MODEM_EVT_BATTERY_DATA_NOT_READY`
77+
78+
Neighbor cell measurements
79+
==========================
80+
81+
Neighbor cell measurements can be requested by the application by sending an ``APP_EVT_DATA_GET`` event where ``APP_DATA_NEIGHBOR_CELLS`` is part of the requested data list.
82+
Upon reception of that event, the modem module uses the LTE link controller to start a neighbor cell search of type :c:enum:`LTE_LC_NEIGHBOR_SEARCH_TYPE_DEFAULT`.
83+
See :ref:`lte_lc_readme` for more details on the available search types.
84+
When the search completes, the module sends a :c:enum:`MODEM_EVT_NEIGHBOR_CELLS_DATA_READY` event containing the cell information received from the modem.
85+
If the search fails, a :c:enum:`MODEM_EVT_NEIGHBOR_CELLS_DATA_NOT_READY` event is sent.
86+
87+
Module internals
88+
****************
89+
90+
The modem module has an internal thread with a message queue for processing.
91+
When an event is received in the :ref:`event_manager` handler, the event is converted to a message and put into the module's queue for processing in thread context.
92+
This gives the module the flexibility to call functions that might take some time to complete.
93+
94+
Module states
95+
=============
96+
97+
The modem module has an internal state machine with the following states:
98+
99+
* ``STATE_INIT`` - The initial state of the module in which it awaits the modem to be initialized.
100+
The module enters this state only if the :ref:`liblwm2m_carrier_readme` library is enabled because the modem is automatically initialized otherwise.
101+
* ``STATE_DISCONNECTED`` - The module has performed all required initializations and is ready to establish an LTE connection.
102+
This is the initial state for applications that do not use the :ref:`liblwm2m_carrier_readme` library.
103+
* ``STATE_CONNECTING`` - The modem is currently searching for a suitable LTE network and attempting to establish a connection.
104+
* ``STATE_CONNECTED`` - The device is connected to an LTE network.
105+
* ``STATE_SHUTDOWN`` - The module has been shut down after receiving a request from the utility module.
106+
107+
State transitions take place based on input from other modules through the event manager handler and the LTE link controller handler.
108+
109+
Configuration options
110+
*********************
111+
112+
You can set the following options to configure the modem module:
113+
114+
.. _CONFIG_MODEM_MODULE:
115+
116+
CONFIG_MODEM_MODULE - Configuration for modem module
117+
This option enables the modem module.
118+
119+
.. _CONFIG_MODEM_THREAD_STACK_SIZE:
120+
121+
CONFIG_MODEM_THREAD_STACK_SIZE - Configuration for thread stack size
122+
This option configures the modem module thread stack size.
123+
124+
.. _CONFIG_MODEM_SEND_ALL_SAMPLED_DATA:
125+
126+
CONFIG_MODEM_SEND_ALL_SAMPLED_DATA - Configuration for sending all sampled data
127+
By default, the modem module sends only events with sampled data that has changed since the last sampling.
128+
To send unchanged data also, enable this option.
129+
130+
.. _CONFIG_MODEM_AUTO_REQUEST_POWER_SAVING_FEATURES:
131+
132+
CONFIG_MODEM_AUTO_REQUEST_POWER_SAVING_FEATURES - Configuration for automatic requests of PSM
133+
The module automatically requests PSM from the LTE network.
134+
If PSM is granted by the network, it results in reduction of the modem's power consumption.
135+
Note that the device is not reachable from the cloud when it is in PSM.
136+
The device exits PSM whenever the application sends data, or the configured PSM TAU (Tracking Area Update) interval has passed.
137+
To not request PSM from the network, disable this option.
138+
139+
For more information on LTE configuration options, see :ref:`lte_lc_readme`.
140+
141+
Module events
142+
*************
143+
144+
The :file:`asset_tracker_v2/src/events/modem_module_event.h` header file contains a list of the events sent by the modem module.
145+
146+
Dependencies
147+
************
148+
149+
The module uses the following |NCS| libraries:
150+
151+
* :ref:`event_manager`
152+
* :ref:`lte_lc_readme`
153+
* :ref:`modem_info_readme`
154+
155+
API documentation
156+
*****************
157+
158+
| Header file: :file:`asset_tracker_v2/src/events/modem_module_event.h`
159+
| Source files: :file:`asset_tracker_v2/src/events/modem_module_event.c`, :file:`asset_tracker_v2/src/modules/modem_module.c`
160+
161+
.. doxygengroup:: modem_module_event
162+
:project: nrf
163+
:members:

applications/asset_tracker_v2/src/events/modem_module_event.h

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,122 @@ extern "C" {
2626
enum modem_module_event_type {
2727
/** Event signalling that the modem library and AT command library
2828
* have been initialized and are ready for use by other modules.
29+
* The event has no associated payload.
2930
*/
3031
MODEM_EVT_INITIALIZED,
32+
33+
/** The device has been registered with an LTE network.
34+
* The event has no associated payload.
35+
*/
3136
MODEM_EVT_LTE_CONNECTED,
37+
38+
/** The device has been de-registered with an LTE network.
39+
* The event has no associated payload.
40+
*/
3241
MODEM_EVT_LTE_DISCONNECTED,
42+
43+
/** The device is searching for an LTE network.
44+
* The event has no associated payload.
45+
*/
3346
MODEM_EVT_LTE_CONNECTING,
47+
48+
/** The device is connected to a new LTE cell.
49+
* The event has associated payload of type @ref modem_module_cell in
50+
* the `data.cell` member.
51+
*/
3452
MODEM_EVT_LTE_CELL_UPDATE,
53+
54+
/** PSM configuration has been received.
55+
* The event has associated payload of type @ref modem_module_psm in
56+
* the `data.psm` member.
57+
*/
3558
MODEM_EVT_LTE_PSM_UPDATE,
59+
60+
/** eDRX configuration has been received.
61+
* The event has associated payload of type @ref modem_module_edrx in
62+
* the `data.edrx` member.
63+
*/
3664
MODEM_EVT_LTE_EDRX_UPDATE,
65+
66+
/** Static modem data has been sampled and is ready.
67+
* The event has associated payload of type @ref modem_module_static_modem_data in
68+
* the `data.modem_static` member.
69+
*/
3770
MODEM_EVT_MODEM_STATIC_DATA_READY,
71+
72+
/** Dynamic modem data has been sampled and is ready.
73+
* The event has associated payload of type @ref modem_module_dynamic_modem_data in
74+
* the `data.modem_dynamic` member.
75+
*/
3876
MODEM_EVT_MODEM_DYNAMIC_DATA_READY,
77+
78+
/** Static modem data could not be sampled will not be ready for this
79+
* sampling interval.
80+
* The event has no associated payload.
81+
*/
3982
MODEM_EVT_MODEM_STATIC_DATA_NOT_READY,
83+
84+
/** Dynamic modem data could not be sampled will not be ready for this
85+
* sampling interval.
86+
* The event has no associated payload.
87+
*/
4088
MODEM_EVT_MODEM_DYNAMIC_DATA_NOT_READY,
89+
90+
/** Neighbor cell measurements have been gathered and the data is ready.
91+
* The event has associated payload of type @ref modem_module_neighbor_cells in
92+
* the `data.neighbor_cells` member.
93+
*/
4194
MODEM_EVT_NEIGHBOR_CELLS_DATA_READY,
95+
96+
/** Neighbor cell data measurements could not be gathered will not be ready for this
97+
* sampling interval.
98+
* The event has no associated payload.
99+
*/
42100
MODEM_EVT_NEIGHBOR_CELLS_DATA_NOT_READY,
43-
MODEM_EVT_BATTERY_DATA_NOT_READY,
101+
102+
/** Battery voltage has been sampled and is ready.
103+
* The event has associated payload of type @ref modem_module_battery_data in
104+
* the `data.bat` member.
105+
*/
44106
MODEM_EVT_BATTERY_DATA_READY,
107+
108+
/** Battery data could not be sampled will not be ready for this sampling interval.
109+
* The event has no associated payload.
110+
*/
111+
MODEM_EVT_BATTERY_DATA_NOT_READY,
112+
113+
/** The modem module has successfully shut down.
114+
* The event has associated payload of type `uint32_t` in the `data.id` member.
115+
*/
45116
MODEM_EVT_SHUTDOWN_READY,
117+
118+
/** A crtical error has occurred, and the application should reboot to recover as
119+
* the module may enter an undefined state.
120+
* The event has associated payload of the type `int` in the `data.err` member.
121+
*/
46122
MODEM_EVT_ERROR,
123+
47124
/** The carrier library has initialized the modem library and it is
48125
* now ready to be used. When the carrier library is enabled, this
49126
* event must be received before the modem module can proceed to initialize
50127
* other dependencies and subsequently send MODEM_EVT_INITIALIZED.
128+
* The event has no associated payload.
51129
*/
52130
MODEM_EVT_CARRIER_INITIALIZED,
53131
/** Due to modem limitations for active TLS connections, the carrier
54132
* library requires all other TLS connections in the system to
55133
* be terminated while FOTA update is ongoing.
134+
* The event has no associated payload.
56135
*/
57136
MODEM_EVT_CARRIER_FOTA_PENDING,
58137
/** FOTA update has been stopped and the application can set up TLS
59138
* connections again.
139+
* The event has no associated payload.
60140
*/
61141
MODEM_EVT_CARRIER_FOTA_STOPPED,
62142
/** The carrier library requests that the device reboots to apply
63143
* downloaded firmware image(s) or for other reasons.
144+
* The event has no associated payload.
64145
*/
65146
MODEM_EVT_CARRIER_REBOOT_REQUEST,
66147
};

doc/nrf/releases/release-notes-changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ nRF9160: Asset Tracker v2
6565
* Updated the code and documentation to use the acronym GNSS instead of GPS when not referring explicitly to the GPS system.
6666
* Added support for atmospheric pressure readings retrieved from the BME680 sensor on Thingy:91.
6767
* Fixed an issue where PSM could be requested from the network even though it was disabled in Kconfig.
68+
* Added new documentation for Asset Tracker v2 :ref:`asset_tracker_v2_modem_module`.
6869

6970
* Added:
7071

@@ -336,4 +337,5 @@ In addition to documentation related to the changes listed above, the following
336337

337338
* Reduced the ToC levels of the subpages.
338339

340+
339341
.. |no_changes_yet_note| replace:: No changes since the latest |NCS| release.

0 commit comments

Comments
 (0)