LSH-Core
A robust C++ framework for Arduino-based home automation nodes
Loading...
Searching...
No Matches
protocol.hpp
Go to the documentation of this file.
1
21#ifndef LSHCORE_COMMUNICATION_CONSTANTS_PROTOCOL_HPP
22#define LSHCORE_COMMUNICATION_CONSTANTS_PROTOCOL_HPP
23
24#include <stdint.h>
25
26namespace LSH
27{
28 namespace protocol
29 {
30 // === JSON KEYS ===
31 constexpr const char *KEY_PAYLOAD = "p";
32 constexpr const char *KEY_NAME = "n";
33 constexpr const char *KEY_ACTUATORS_ARRAY = "a";
34 constexpr const char *KEY_BUTTONS_ARRAY = "b";
35 constexpr const char *KEY_ID = "i";
36 constexpr const char *KEY_STATE = "s";
37 constexpr const char *KEY_TYPE = "t";
38
42 enum class Command : uint8_t
43 {
44 // Arduino -> ESP
45 DEVICE_DETAILS = 1,
46 ACTUATORS_STATE = 2,
49
50 // Omnidirectional
51 BOOT = 4,
52 PING_ = 5,
53
54 // ESP -> Arduino (or MQTT -> ESP)
55 REQUEST_DETAILS = 10,
56 REQUEST_STATE = 11,
57 SET_STATE = 12,
60 FAILOVER = 15,
61 FAILOVER_CLICK = 16,
62
63 // ESP System command (MQTT -> ESP)
64 SYSTEM_REBOOT = 254,
65 SYSTEM_RESET = 255
66 };
67
71 enum class ProtocolClickType : uint8_t
72 {
73 LONG = 1,
74 SUPER_LONG = 2
75 };
76
77 } // namespace protocol
78} // namespace LSH
79
80#endif // LSHCORE_COMMUNICATION_CONSTANTS_PROTOCOL_HPP
constexpr const char * KEY_PAYLOAD
Payload type (Command enum)
Definition protocol.hpp:31
ProtocolClickType
Defines the valid click types for the 't' (type) key in JSON messages.
Definition protocol.hpp:72
constexpr const char * KEY_BUTTONS_ARRAY
Buttons IDs array.
Definition protocol.hpp:34
Command
Defines the valid command types for the 'p' (payload) key in JSON messages.
Definition protocol.hpp:43
@ FAILOVER_CLICK
Failover for specific click: {"p":16,"i":buttonId,"t":clickType}.
@ ACTUATORS_STATE
Bitpacked state: {"p":2,"s":[byte0,byte1,...]} (each byte = 8 actuators)
@ FAILOVER
General failover: {"p":15}.
@ PING_
Ping/heartbeat: {"p":5}.
@ NETWORK_CLICK_ACK
Acknowledge network click: {"p":14,"i":buttonId,"t":clickType}.
@ SET_STATE
Set all actuators: {"p":12,"s":[byte0,byte1,...]}.
@ SET_SINGLE_ACTUATOR
Set single actuator: {"p":13,"i":id,"s":0|1}.
@ NETWORK_CLICK_CONFIRM
Network click confirm after ACK received.
@ NETWORK_CLICK_REQUEST
Network click request: {"p":3,"i":buttonId,"t":clickType}.
@ REQUEST_DETAILS
Request device details: {"p":10}.
@ DEVICE_DETAILS
Device info: {"p":1,"n":"name","a":[ids],"b":[ids]}.
@ BOOT
Boot notification: {"p":4}.
@ REQUEST_STATE
Request current state: {"p":11}.
constexpr const char * KEY_STATE
Actuators State (bitpacked bytes array)
Definition protocol.hpp:36
constexpr const char * KEY_TYPE
Click Type.
Definition protocol.hpp:37
constexpr const char * KEY_NAME
Device Name.
Definition protocol.hpp:32
constexpr const char * KEY_ID
Actuator/Button ID.
Definition protocol.hpp:35
constexpr const char * KEY_ACTUATORS_ARRAY
Actuators IDs array.
Definition protocol.hpp:33