LSH-Core
A robust C++ framework for Arduino-based home automation nodes
Loading...
Searching...
No Matches
protocol.hpp File Reference

Defines the communication protocol contract (JSON keys, command IDs). More...

#include <stdint.h>
Include dependency graph for protocol.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  LSH::protocol::Command : uint8_t {
  DEVICE_DETAILS = 1 , ACTUATORS_STATE = 2 , NETWORK_CLICK_REQUEST = 3 , NETWORK_CLICK_CONFIRM = 17 ,
  BOOT = 4 , PING_ = 5 , REQUEST_DETAILS = 10 , REQUEST_STATE = 11 ,
  SET_STATE = 12 , SET_SINGLE_ACTUATOR = 13 , NETWORK_CLICK_ACK = 14 , FAILOVER = 15 ,
  FAILOVER_CLICK = 16 , SYSTEM_REBOOT = 254 , SYSTEM_RESET = 255
}
 Defines the valid command types for the 'p' (payload) key in JSON messages. More...
 
enum class  LSH::protocol::ProtocolClickType : uint8_t { LONG = 1 , SUPER_LONG = 2 }
 Defines the valid click types for the 't' (type) key in JSON messages.
 

Variables

constexpr const char * LSH::protocol::KEY_PAYLOAD = "p"
 Payload type (Command enum)
 
constexpr const char * LSH::protocol::KEY_NAME = "n"
 Device Name.
 
constexpr const char * LSH::protocol::KEY_ACTUATORS_ARRAY = "a"
 Actuators IDs array.
 
constexpr const char * LSH::protocol::KEY_BUTTONS_ARRAY = "b"
 Buttons IDs array.
 
constexpr const char * LSH::protocol::KEY_ID = "i"
 Actuator/Button ID.
 
constexpr const char * LSH::protocol::KEY_STATE = "s"
 Actuators State (bitpacked bytes array)
 
constexpr const char * LSH::protocol::KEY_TYPE = "t"
 Click Type.
 

Detailed Description

Defines the communication protocol contract (JSON keys, command IDs).

Author
Jacopo Labardi (labodj)

Copyright 2025 Jacopo Labardi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Enumeration Type Documentation

◆ Command

enum class LSH::protocol::Command : uint8_t
strong

Defines the valid command types for the 'p' (payload) key in JSON messages.

Enumerator
DEVICE_DETAILS 

Device info: {"p":1,"n":"name","a":[ids],"b":[ids]}.

ACTUATORS_STATE 

Bitpacked state: {"p":2,"s":[byte0,byte1,...]} (each byte = 8 actuators)

NETWORK_CLICK_REQUEST 

Network click request: {"p":3,"i":buttonId,"t":clickType}.

NETWORK_CLICK_CONFIRM 

Network click confirm after ACK received.

BOOT 

Boot notification: {"p":4}.

PING_ 

Ping/heartbeat: {"p":5}.

REQUEST_DETAILS 

Request device details: {"p":10}.

REQUEST_STATE 

Request current state: {"p":11}.

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_ACK 

Acknowledge network click: {"p":14,"i":buttonId,"t":clickType}.

FAILOVER 

General failover: {"p":15}.

FAILOVER_CLICK 

Failover for specific click: {"p":16,"i":buttonId,"t":clickType}.