Classes | |
| struct | ResponseFormat |
| Intermediate structure to pass data from the Modbus callback to tasks. More... | |
| struct | BitPacker |
| Utility for packing arbitrary bits into a byte stream. More... | |
| struct | SensorDataPayload |
| Container for processed sensor data, ready for aggregation. More... | |
Macros | |
| #define | MAX_SENSOR_PAYLOAD 128 |
| Maximum size of an individual sensor payload. | |
| #define | AGGREGATION_INTERVAL_MS 6100 |
| Aggregation interval (ms). | |
| #define | AGGREGATION_INTERVAL_MS 6100 |
| Aggregation interval (ms). | |
Functions | |
| static bool | formatAndEnqueueSensorData (const ResponseFormat &response, const ModbusRequestInfo &request, std::vector< uint8_t > &values) |
| Extracts and formats data from a sampling Modbus response. | |
| void | DataFormatter (void *pvParameters) |
| Data Formatter task. | |
| std::vector< uint8_t > | construirPayloadUnificado (uint8_t id_mensaje, const std::vector< SensorDataPayload > &collectedPayloads) |
| Builds a unified payload from a collection of sensor data. | |
| void | DataAggregatorTask (void *pvParameters) |
| Proactive task that collects and packages sensor data at a fixed rate. | |
This module is responsible for:
Flow summary:
1) Response formatting
2) Payload aggregation
3) Delivery to transmission
The firmware uses an optimized binary scheme to maximize transmission efficiency over LoRaWAN. This section describes the payload structure to facilitate decoder implementation.
Payload components:
Structure of each length byte (8 bits):
Field descriptions:
Length byte order:
Length bytes follow the same order as the Activate byte flags (LSB → MSB):
Example: If Activate byte = 0x06 (voltage + current active), there will be 2 length bytes: first for voltage, second for current.
| #define AGGREGATION_INTERVAL_MS 6100 |
Aggregation interval (ms).
Aggregation interval (6s + 100ms margin).
| #define AGGREGATION_INTERVAL_MS 6100 |
Aggregation interval (ms).
Aggregation interval (6s + 100ms margin).
| std::vector< uint8_t > construirPayloadUnificado | ( | uint8_t | id_mensaje, |
| const std::vector< SensorDataPayload > & | collectedPayloads ) |
Builds a unified payload from a collection of sensor data.
Payload Structure: [ID_MSG][TIMESTAMP][ACTIVATE_BYTE][LEN_BYTES...][DATA_BLOCKS...]
| id_mensaje | The message ID byte (Header). |
| collectedPayloads | The vector with the collected data. |
| void DataAggregatorTask | ( | void * | pvParameters | ) |
Proactive task that collects and packages sensor data at a fixed rate.
Wakes up every AGGREGATION_INTERVAL_MS, empties the data queue, and sends a single LoRaWAN payload if it has collected anything.
| void DataFormatter | ( | void * | pvParameters | ) |
Data Formatter task.
Consumes responses from queueRespuestas, processes them according to their type (Discovery or Sampling) and enqueues the formatted results.
|
static |
Extracts and formats data from a sampling Modbus response.
| response | Raw response received. |
| request | Information from the original request. |
| values | Output vector where the processed bytes will be stored. |