#include "esp_err.h"
#include "general/node_cfg.h"
#include "master/lora_msg_protocol.h"
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
|
| uint8_t | lora_serialize_registration (uint8_t *buffer, uint8_t slave_id, const char *name, int32_t longitude, int32_t latitude) |
| | Serialize a registration message into a compact byte buffer.
|
| |
| uint8_t | lora_serialize_periodic (uint8_t *buffer, const slave_data *slaves, uint8_t slave_count) |
| | Serialize a periodic status message for all registered slaves.
|
| |
| uint8_t | lora_serialize_alarm (uint8_t *buffer, uint8_t slave_id) |
| | Serialize an alarm message.
|
| |
| int | lora_send_registration (uint8_t slave_id, const char *name, int32_t longitude, int32_t latitude) |
| | Send a registration message via LoRaWAN.
|
| |
| int | lora_send_periodic (const slave_data *slaves, uint8_t slave_count) |
| | Send periodic status for all slaves via LoRaWAN.
|
| |
| int | lora_send_alarm (uint8_t slave_id) |
| | Send an alarm message via LoRaWAN.
|
| |
◆ LORA_ALARM_MSG_SIZE
| #define LORA_ALARM_MSG_SIZE 2 |
◆ LORA_PERIODIC_HEADER_SIZE
| #define LORA_PERIODIC_HEADER_SIZE 2 |
◆ LORA_PERIODIC_MAX_SIZE
◆ LORA_PERIODIC_SLAVE_SIZE
| #define LORA_PERIODIC_SLAVE_SIZE 3 |
◆ LORA_REG_MSG_SIZE
| #define LORA_REG_MSG_SIZE 42 |
◆ lora_send_alarm()
| int lora_send_alarm |
( |
uint8_t |
slave_id | ) |
|
Send an alarm message via LoRaWAN.
- Parameters
-
| slave_id | ID of the slave that detected tampering/sabotage |
- Returns
- ESP_OK on success
◆ lora_send_periodic()
| int lora_send_periodic |
( |
const slave_data * |
slaves, |
|
|
uint8_t |
slave_count |
|
) |
| |
Send periodic status for all slaves via LoRaWAN.
- Parameters
-
| slaves | Array of slave data |
| slave_count | Number of active slaves |
- Returns
- ESP_OK on success
◆ lora_send_registration()
| int lora_send_registration |
( |
uint8_t |
slave_id, |
|
|
const char * |
name, |
|
|
int32_t |
longitude, |
|
|
int32_t |
latitude |
|
) |
| |
Send a registration message via LoRaWAN.
- Parameters
-
| slave_id | Slave device ID |
| name | Device name |
| longitude | GPS longitude (fixed-point, *1e6) |
| latitude | GPS latitude (fixed-point, *1e6) |
- Returns
- ESP_OK on success
◆ lora_serialize_alarm()
| uint8_t lora_serialize_alarm |
( |
uint8_t * |
buffer, |
|
|
uint8_t |
slave_id |
|
) |
| |
Serialize an alarm message.
Format: [msg_type:1][slave_id:1] Total: 2 bytes
- Parameters
-
| buffer | Output buffer (must be at least LORA_ALARM_MSG_SIZE bytes) |
| slave_id | ID of the slave that triggered the alarm |
- Returns
- Number of bytes written
◆ lora_serialize_periodic()
| uint8_t lora_serialize_periodic |
( |
uint8_t * |
buffer, |
|
|
const slave_data * |
slaves, |
|
|
uint8_t |
slave_count |
|
) |
| |
Serialize a periodic status message for all registered slaves.
Format: [msg_type:1][slave_count:1][slave_data:N*3] Each slave: [slave_id:1][battery:1][moisture:1]
- Parameters
-
| buffer | Output buffer (must be at least LORA_PERIODIC_MAX_SIZE bytes) |
| slaves | Array of slave data structures |
| slave_count | Number of registered slaves (will be capped at MAX_SLAVE_NUM) |
- Returns
- Number of bytes written
◆ lora_serialize_registration()
| uint8_t lora_serialize_registration |
( |
uint8_t * |
buffer, |
|
|
uint8_t |
slave_id, |
|
|
const char * |
name, |
|
|
int32_t |
longitude, |
|
|
int32_t |
latitude |
|
) |
| |
Serialize a registration message into a compact byte buffer.
Format: [msg_type:1][slave_id:1][name:32][longitude:4][latitude:4] Total: 42 bytes
- Parameters
-
| buffer | Output buffer (must be at least LORA_REG_MSG_SIZE bytes) |
| slave_id | Slave device ID (0-15) |
| name | Device name (32 char max, will be padded/truncated) |
| longitude | GPS longitude as fixed-point (multiply by 1e6) |
| latitude | GPS latitude as fixed-point (multiply by 1e6) |
- Returns
- Number of bytes written