Application module

The application module controls key mechanisms in the Asset Tracker v2. It decides when to sample data, what types of data to sample, and has explicit control over some aspects of the application.


This section documents the features implemented by the module.

Sample requests

Depending on the application’s Real-time configurations, the application module sends periodic sample requests to other modules in the system. The sample requests are of type APP_EVT_DATA_GET and contains a list of Data types that must be sampled by the corresponding module. Each module handles the sample requests individually and if a module finds its corresponding data type in the list, it starts sampling for that particular data type. For instance, if the Location module finds the APP_DATA_LOCATION data type, it starts searching for a location. Some modules, such as the Modem module, even support multiple data types. It supports APP_DATA_MODEM_STATIC, APP_DATA_MODEM_DYNAMIC, and APP_DATA_BATTERY. In addition to the sample list, the module also includes a sample timeout in the APP_EVT_DATA_GET event. This timeout sets how much time each module has to sample data before the Data module sends what is available.


Sample requests are sent either periodically or upon detection of movement. The timeouts and modes that have an impact on the frequency of sample requests are documented in Real-time configurations.

Application start

The application module is the system’s initial point of entry and the source file of the module is asset_tracker_v2/src/main.c. When the application boots, the module initializes the Application Event Manager and sends out the initial event APP_EVT_START that starts the rest of the modules in the application. It also initializes the Common Application Framework overview by calling the module_set_state() API with the MODULE_STATE_READY state.

Configuration options

There are no configuration options for the application module.

Module states

The application module has an internal state machine with the following states:

  • STATE_INIT - The initial state of the module.

  • STATE_RUNNING - The module has received its initial configuration from the data module and has started the appropriate timers.

    • SUB_STATE_ACTIVE_MODE - The application is in the active mode. In this state, the module sends out sample requests periodically.

    • SUB_STATE_PASSIVE_MODE - The application is in the passive mode. In this state, the module sends out a sample request upon movement.

  • STATE_SHUTDOWN - The module has been shut down after receiving a request from the utility module.

Module events

The asset_tracker_v2/src/events/app_module_event.h header file contains a list of events sent by the module.


This module uses the following nRF Connect SDK libraries and drivers:

API documentation

Header file: asset_tracker_v2/src/events/app_module_event.h
Source files: asset_tracker_v2/src/events/app_module_event.c, asset_tracker_v2/src/main.c
group app_module_event

Application module event.


enum app_module_event_type

Event types submitted by Application module.


enumerator APP_EVT_START

Signal that the application has done necessary setup, and now started.


Connect to LTE network.


Disconnect from LTE network.

enumerator APP_EVT_DATA_GET

Signal other modules to start sampling and report the data when it’s ready. The event must also contain a list with requested data types, app_module_data_type.


Create a list with all available sensor types in the system and distribute it as an APP_EVT_DATA_GET event.


Request latest configuration from the cloud.


The application module has performed all procedures to prepare for a shutdown of the system.

enumerator APP_EVT_ERROR

An irrecoverable error has occurred in the application module. Error details are attached in the event structure.

enum app_module_data_type

Data types that the application module requests samples for in app_module_event_type APP_EVT_DATA_GET.


enumerator APP_DATA_COUNT
struct app_module_event
#include <app_module_event.h>

Application module event.

Public Members

int err

Code signifying the cause of error.

int timeout

The time each module has to fetch data before what is available is transmitted.