Application Event Manager

The Application Event Manager sample demonstrates the functionality of the Application Event Manager subsystem. It uses an event-driven architecture, where different modules communicate through sending and processing events.

Overview

The sample application consists of three modules that communicate using events:

Sensor (sensor_simulated.c):

This module waits for a configuration event (which is sent by main.c). After receiving this event, it simulates measured data at constant intervals. Every time the data is updated, the module sends the current values as measurement event. When the module receives a control event from the Controller, it responds with an ACK event.

Controller (controller.c):

This module waits for measurement events from the sensor. Every time a measurement event is received, the module checks one of the measurement values that are transmitted as part of the event and, if the value exceeds a static threshold, sends a control event.

Statistics (stats.c):

This module waits for measurement events from the sensor. The module calculates and logs basic statistics about one of the measurement values that are transmitted as part of the event.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160_ns

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF21540 DK

PCA10112

nrf21540dk_nrf52840

nrf21540dk_nrf52840

When built for an _ns build target, the sample is configured to compile and run as a non-secure application. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

Configuration

See Configuring your application for information about how to permanently or temporarily change the configuration.

Building and running

This sample can be found under samples/app_event_manager in the nRF Connect SDK folder structure.

When built as a non-secure firmware image for the _ns build target, the sample automatically includes the Trusted Firmware-M (TF-M).

See Building and programming an application for information about how to build and program the application and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.

Testing

After programming the sample to your development kit, test it by performing the following steps:

  1. Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.

  2. Reset the kit.

  3. Observe that output similar to the following is logged on UART:

    ***** Booting Zephyr OS v1.13.99-ncs1-4741-g1d6219f *****
    [00:00:00.000,854] <inf> app_event_manager: e: config_event init_val_1=3
    [00:00:00.001,068] <inf> app_event_manager: e: measurement_event val1=3 val2=3 val3=3
    [00:00:00.509,063] <inf> app_event_manager: e: measurement_event val1=3 val2=6 val3=9
    [00:00:01.018,005] <inf> app_event_manager: e: measurement_event val1=3 val2=9 val3=18
    [00:00:01.526,947] <inf> app_event_manager: e: measurement_event val1=3 val2=12 val3=30
    [00:00:02.035,888] <inf> app_event_manager: e: measurement_event val1=3 val2=15 val3=45
    [00:00:02.035,949] <inf> app_event_manager: e: control_event
    [00:00:02.035,980] <inf> app_event_manager: e: ack_event
    [00:00:02.544,830] <inf> app_event_manager: e: measurement_event val1=-3 val2=12 val3=57
    [00:00:03.053,771] <inf> app_event_manager: e: measurement_event val1=-3 val2=9 val3=66
    [00:00:03.562,713] <inf> app_event_manager: e: measurement_event val1=-3 val2=6 val3=72
    [00:00:04.071,655] <inf> app_event_manager: e: measurement_event val1=-3 val2=3 val3=75
    [00:00:04.580,596] <inf> app_event_manager: e: measurement_event val1=-3 val2=0 val3=75
    [00:00:04.580,596] <inf> stats: Average value3: 45
    

Dependencies

This sample uses the following nRF Connect SDK subsystems:

In addition, it uses the following Zephyr subsystems:

The sample also uses the following secure firmware component: