Safe Sprinkler
Master/slave irrigation system (ESP-NOW + LoRaWAN)
Loading...
Searching...
No Matches
message_protocol.h
Go to the documentation of this file.
1#ifndef PROTOCOL_H
2#define PROTOCOL_H
3
4#include <stdint.h>
5
6typedef uint8_t esp_message_id_t;
7
8#define MSG_REGISTRATION 0
9#define MSG_MEASUREMENT 1
10#define MSG_ALARM 2
11#define WIFI_CHANNEL 1
12#define MAX_RETRY 3
13#define TIMEOUT_MS 200 // tweak
14
15typedef struct
16{
17 uint8_t id;
19
20// Registration message sent by slave → broadcast
21typedef struct
22{
24 char name[32];
25 int32_t longitude; // [-180; 180] * 1e6
26 int32_t latitude; // [-90; 90] * 1e6
28
29// Acknowledgement for registration sent master → slave
30typedef struct
31{
34
35// Measurement message sent by slave → master
36typedef struct
37{
39 uint8_t moisture;
40 uint8_t battery;
42
43// Measurement ACK with time sync sent master → slave
44typedef struct
45{
47 uint64_t masterTime;
49
50// Alarm message sent by slave → master
51typedef struct
52{
55
56// Alarm acknowledgment sent master → slave
57typedef struct
58{
61
72
73// internal struct to process messages
74typedef struct
75{
77 uint8_t mac[6];
78
80
81#endif // PROTOCOL_H
uint8_t esp_message_id_t
Definition message_protocol.h:6
Definition message_protocol.h:58
msg_header_t header
Definition message_protocol.h:59
Definition message_protocol.h:45
msg_header_t header
Definition message_protocol.h:46
uint64_t masterTime
Definition message_protocol.h:47
Definition message_protocol.h:31
msg_header_t header
Definition message_protocol.h:32
Definition message_protocol.h:52
msg_header_t header
Definition message_protocol.h:53
Definition message_protocol.h:37
uint8_t moisture
Definition message_protocol.h:39
msg_header_t header
Definition message_protocol.h:38
uint8_t battery
Definition message_protocol.h:40
Definition message_protocol.h:75
message_data_t data
Definition message_protocol.h:76
Definition message_protocol.h:16
uint8_t id
Definition message_protocol.h:17
Definition message_protocol.h:22
msg_header_t header
Definition message_protocol.h:23
int32_t longitude
Definition message_protocol.h:25
int32_t latitude
Definition message_protocol.h:26
Definition message_protocol.h:62
alarm_msg_t alarm
Definition message_protocol.h:66
ack_registration_t ack_reg
Definition message_protocol.h:68
measurement_msg_t measurement
Definition message_protocol.h:65
ack_alarm_t ack_alarm
Definition message_protocol.h:70
msg_header_t header
Definition message_protocol.h:63
ack_measurement_t ack_meas
Definition message_protocol.h:69
registration_msg_t registration
Definition message_protocol.h:64