modules: cloud: integrate nRF Cloud CoAP connectivity module#22
Merged
Conversation
Add CONFIG_SENSOR_MODULE_TIMESTAMP option to conditionally include UTC epoch timestamps in sensor messages using date_time_now() instead of k_uptime_get(). Update controller logging to display human-readable timestamp format. Refs: #21 Signed-off-by: Natalia Pluta <pluta.natalia.m@gmail.com>
Closed
There was a problem hiding this comment.
Pull Request Overview
This PR integrates nRF Cloud CoAP connectivity by adapting Nordic's cloud module from the Asset Tracker Template. The system now transmits sensor data (temperature, humidity, air pressure, CO2, VOC, particulate matter, and CO levels) to nRF Cloud using CoAP protocol with configurable timestamps.
- Adds a complete cloud connectivity module with state machine architecture and automatic reconnection handling
- Implements configurable UTC timestamps for sensor data with fallback mechanism
- Refactors error handling to use a common app_common.h header instead of app_fatal_error.h
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| app/src/modules/sensor/sensor_module.h | Adds conditional timestamp field to sensor messages |
| app/src/modules/sensor/sensor_module.c | Implements UTC timestamp generation with fallback logic |
| app/src/modules/sensor/Kconfig.sensor | Adds timestamp configuration option |
| app/src/modules/network/network_shell.c | Minor shell output enhancement for RSRP display |
| app/src/modules/network/network_module.c | Updates include to use common error handling |
| app/src/modules/controller/controller_module.c | Conditionally logs timestamps based on configuration |
| app/src/modules/cloud/ | Complete cloud module implementation with CoAP connectivity |
| app/src/app_fatal_error.h | Removed in favor of common error handling |
| app/src/app_common.h | New common header with error handling and utility macros |
| app/prj.conf | Adds nRF Cloud and CoAP configuration |
| app/Kconfig | Includes cloud module configuration |
| app/CMakeLists.txt | Adds cloud module to build |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Integrate and adapt cloud module from Asset Tracker Template v1.1.1 providing: - State machine-based nRF Cloud CoAP connectivity management - ZBUS communication with sensor and network modules - Automatic sensor data transmission to nRF Cloud - Connection management with exponential/linear backoff strategies - Device shadow support and shell commands for cloud interaction - Watchdog integration and comprehensive error handling - Replace app_fatal_error.h with app_common.h for enhanced error handling Includes all necessary nRF Cloud configuration, CoAP client setup, and integration with existing fire detection system architecture. Refs: #21 Signed-off-by: Natalia Pluta <pluta.natalia.m@gmail.com>
5efe6cc to
c2d814d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MR Description
This MR integrates the cloud module from Asset Tracker Template v1.1.1 into the fire detection system, providing seamless nRF Cloud connectivity for sensor data transmission.
🎯 Overview
The integration adapts Nordic's proven cloud connectivity architecture to work with our fire detection system, enabling real-time sensor data transmission to nRF Cloud via CoAP protocol.
📋 Features Implemented
Cloud Module Integration (
modules: cloud: integrate nRF Cloud CoAP connectivity module)Timestamp Enhancement (
modules: sensor: add configurable UTC timestamps to sensor data)CONFIG_SENSOR_MODULE_TIMESTAMPenables UTC epoch timestampsdate_time_now()when available,k_uptime_get()otherwise🔧 Key Adaptations from Original Asset Tracker Template
Architecture Integration
ZBUS Channel Mapping
SENSOR_CHANsensor_chanNETWORK_CHANnetwork_chanLOCATION_CHANSensor Data Transmission
Smart Timestamp Handling
CONFIG_SENSOR_MODULE_TIMESTAMP=y: Real UTC timestamps for accurate cloud correlationCONFIG_SENSOR_MODULE_TIMESTAMP=n: UsesNRF_CLOUD_NO_TIMESTAMPto let nRF Cloud assign server time🏗️ System Architecture
📊 Configuration Options
Cloud Module Settings
CLOUD_MODULE_CONFIRMABLE_MESSAGESnCLOUD_MODULE_BACKOFF_INITIAL_SECONDS60CLOUD_MODULE_BACKOFF_TYPELINEARCLOUD_MODULE_THREAD_STACK_SIZE6144nRF Cloud Integration
🔍 Transmission Data Points
The system automatically transmits all fire detection sensor readings:
The integration provides a robust foundation for cloud-connected fire detection systems.
Original Source: Asset Tracker Template - Cloud Module
Closes #21
Signed-off-by: Natalia Pluta pluta.natalia.m@gmail.com