Node to Cloud Communication
This page outlines how nodes securely interact with the cloud using MQTT over TLS. Each node possesses a unique identifier and credentials established during the claiming process, ensuring secure, authenticated communication. The node configuration, detailing attributes like devices and parameters, is sent to the cloud upon startup, enabling clients such as mobile apps to interpret and utilize this data. Understanding this communication framework is essential for developers to effectively integrate and manage IoT devices within the ESP RainMaker ecosystem.
All communication between the node and cloud happens over secure MQTT
How does a Node ensure secured communication with the Cloud?
A node ensures secured communicated with the cloud by providing:
- Transport Layer Security (TLS)
- MQTT Policies
TLS
The communication between a node and the cloud is secured using TLS encryption with X.509 certificate-based mutual authentication, ensuring only trusted devices can connect.
A generic workflow to establish secured communication:
- The node first generates its own private key and then creates a Certificate Signing Request (CSR), which is like applying for an official ID.
- This request is sent to a Certification Authority (CA), which verifies it, signs it, and returns a client certificate—essentially an authenticated ID badge.
- During the Claiming process, the node receives this certificate, allowing it to establish a secure, encrypted connection with the cloud.
- Before any data exchange, both the node and the cloud verify each other’s certificates to confirm they are communicating with the right entity.
- This ensures privacy, security, and protection against unauthorized access, preventing fake or malicious devices from infiltrating the system.
- Ensures that only trusted nodes can connect to the cloud.
- Prevents hackers or fake devices from pretending to be real nodes.
- Keeps all communication private and secure.
MQTT Policies
The MQTT Policy ensures that a node can only connect to the cloud if its Client ID matches its Node ID, preventing unauthorized access. Additionally, the node is restricted to publishing and subscribing only to topics that start with node/<node_id>/
meaning it cannot access topics from other nodes.
For example, if a node has an ID of 1234, it can only interact with topics like node/1234/status
or node/1234/command
, but it cannot subscribe to node/5678/status
.
This policy acts as a security mechanism to keep each node’s communication isolated and protected, ensuring that data remains private and that nodes cannot interfere with each other.
In Summary
Security Aspect | Description |
---|---|
TLS | Locks the communication channel so that no one can listen in or tamper with messages. |
MQTT Policies | Sets rules on what a node is allowed to talk about within the secured channel. |
MQTT Topics
What is an MQTT Topic?
In ESP RainMaker, an MQTT topic acts as a communication path where a node publishes (sends) updates and subscribes (receives) commands or configurations. Here are the different types of MQTT topics in ESP RainMaker.
- Node Configuration
- Node Parameters
- User-Node Mapping
- Time Series
- Alert and Notify
- Command Response
- OTA
Node Configuration
In ESP RainMaker, Node Configuration is a collection of all the information about a node (i.e. ESP32-S3). When the node starts up, it sends this configuration to the ESP RainMaker Cloud and also reports it to clients, like mobile apps and command-line interfaces (CLI). This configuration contains everything needed to define the node’s identity, features, and capabilities.
Below is the node configuration layout that ESP RainMaker firmware and phone Apps currently use in the order from top to bottom.
Node Configuration Layout (Click to view)
- Box in RED is a mandatory entry in a node configuration.
- Box in GREEN is a mandatory parameter of an entry.
- The strings below each entries indicate the corresponding key in
(JSON representation , Data type).
1. Node ID
2. Config Version
2. Information
3. Node Attributes
4. Devices & Params
MQTT
- Topic
node/<node_id>/config
- Operation:
PUBLISH
- Data:
Node configuration JSON object described below
JSON Payload (Click to view)
"node_id": "5d898491-a498-48ec-9476-a4e23519fe31",
"config_version": "2019-02-27",
"info": {
"name": "My_Bridge",
"fw_version": "1.0",
"type": "Bridge"
},
"attributes": [{
"name": "serial_num",
"value": "123abc"
}, {
"name": "model",
"value": "myBridge-2019"
}],
"devices": [{
"name": "Switch",
"primary": "power",
"params": [{
"name": "name",
"type": "esp.param.name",
"data_type": "string",
"properties": ["read", "write"]
}, {
"name": "power",
"data_type": "bool",
"properties": ["read", "write", "time_series"],
"ui_type": "esp.ui.toggle"
}]
}, {
"name": "Light",
"type": "esp.device.lightbulb",
"attributes": [{
"name": "serial_number",
"value": "012345"
}, {
"name": "mac",
"value": "xx:yy:zz:aa:bb:cc"
}],
"primary": "power",
"params": [{
"name": "name",
"type": "esp.param.name",
"data_type": "string",
"properties": ["read", "write"]
}, {
"name": "power",
"data_type": "bool",
"properties": ["read", "write", "time_series"],
"ui_type": "esp.ui.toggle"
}, {
"name": "brightness",
"data_type": "int",
"properties": ["read", "write"],
"bounds": {
"min": 0,
"max": 100
},
"ui_type": "esp.ui.slider"
}]
}]
By default, the device reports once after power on and connection to the cloud. It will also report when the esp_rmaker_report_node_details
is called.
Firmware API: esp_rmaker_report_node_details()
Node Parameters
All parameter changes are managed through specific node parameter topics.