This is the firmware that is programmed on the nRF9151 of the Thingy:91 X in factory. It's goal is to showcase the device's functionality and to spur interest into trying out the device. nRF Cloud CoAP is used as the cloud solution.
The architecture is based on ZBUS.
Rather than having a main.c
file to tie the application together, 12 modules communicate via ZBUS channels.
This enables us to keep the modules relatively small and reusable by separation of concerns.
Cloud to device communication is done with runtime settings. Device to cloud communication uses CBOR encoded LwM2M objects. Each module encodes its own data using ZCBOR. The format is specified in CDDL files and encoding functions are automatically generated. The encoded data is sent to the payload channel, which takes care of forwarding it to cloud.
- beating heart of the application: send triggers to control other modules
- handles the different states the application is in
- manage connection to nRF Cloud CoAP, notify about cloud connection status
- forward payloads to cloud
- wrap connection manager subsystem and notify about network events
- FOTA handling using nRF Cloud CoAP, notifies about FOTA status
- manages runtime settings
- wrap
date_time
library, notify when time is available
- upload runtime stats and coredumps to Memfault for easier debugging
- wrap
fuel_gauge
subsystem and publish battery status as payload
- notify other modules about button presses
- publish button message as payload
- wrap
bm68x_iaq
driver and publish air quality, temperature, humidity data as payload
- monitor various events and display sophisticated LED patterns
- wrap
location
library, gather and send location data - note: data is sent directly using the library rather than being repackaged in the module
- test related shell functions
- turn off UART for power saving when leaving polling mode
Note: the ERROR channel and channels only used internally in modules were omitted.
CHANNEL | battery | environment | location | network | trigger | app | button | fota | led | memfault | shell | transport |
---|---|---|---|---|---|---|---|---|---|---|---|---|
CLOUD | r | r | r | r | r | w | ||||||
CONFIG | r | r | w | |||||||||
LOCATION | w | r | r | |||||||||
BUTTON | r | w | w | |||||||||
FOTA | r | w | ||||||||||
TRIGGER | r | r | r | r | w | |||||||
TRIGGER_MODE | w | r | ||||||||||
NETWORK | r | r | w | r | r | |||||||
PAYLOAD | w | w | w | w | r | |||||||
TIME | r | r | r | w | r |