smartledz-protocol
Smart LEDZ protocol v1 command and state codec library
Loading...
Searching...
No Matches
state_codec.h File Reference

Stateful decoders for Smart LEDZ v1 notify payloads. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include <map>
#include <vector>
Include dependency graph for state_codec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  smartledz_protocol::v1::DeviceStateSnapshot
 Last known state fields decoded from mesh notifications. More...
 

Functions

void smartledz_protocol::v1::apply_online_status_payload (const uint8_t *payload10, size_t payload_len, uint32_t now_ms, std::map< uint16_t, DeviceStateSnapshot > *states, std::vector< uint16_t > *updated_addresses)
 Applies an online-status notify payload (opcode 0xDC).
 
void smartledz_protocol::v1::apply_status_payload (uint16_t src, const uint8_t *payload10, size_t payload_len, uint32_t now_ms, std::map< uint16_t, DeviceStateSnapshot > *states, std::vector< uint16_t > *updated_addresses)
 Applies a status notify payload (opcode 0xDB) for one source address.
 
void smartledz_protocol::v1::apply_f1_response_payload (uint16_t src, const uint8_t *payload10, size_t payload_len, uint32_t now_ms, std::map< uint16_t, DeviceStateSnapshot > *states, std::vector< uint16_t > *updated_addresses)
 Applies an extended dimming response payload (opcode 0xEA, body starts with 0xF1).
 

Detailed Description

Stateful decoders for Smart LEDZ v1 notify payloads.

Function Documentation

◆ apply_f1_response_payload()

void smartledz_protocol::v1::apply_f1_response_payload ( uint16_t  src,
const uint8_t *  payload10,
size_t  payload_len,
uint32_t  now_ms,
std::map< uint16_t, DeviceStateSnapshot > *  states,
std::vector< uint16_t > *  updated_addresses 
)

Applies an extended dimming response payload (opcode 0xEA, body starts with 0xF1).

Parameters
srcSource mesh address from the decrypted frame.
payload10Pointer to notify payload bytes.
payload_lenNumber of bytes in payload10.
now_msCaller timestamp used to set last_update_ms.
statesAddress-to-state map to update.
updated_addressesOptional output vector appended with src when decoded.
Note
This decoder accepts only func=1, item=4, and at least one data byte; brightness is taken from payload[6].

◆ apply_online_status_payload()

void smartledz_protocol::v1::apply_online_status_payload ( const uint8_t *  payload10,
size_t  payload_len,
uint32_t  now_ms,
std::map< uint16_t, DeviceStateSnapshot > *  states,
std::vector< uint16_t > *  updated_addresses 
)

Applies an online-status notify payload (opcode 0xDC).

Parameters
payload10Pointer to notify payload bytes.
payload_lenNumber of bytes in payload10.
now_msCaller timestamp used to set last_update_ms.
statesAddress-to-state map to update.
updated_addressesOptional output vector appended with updated addresses.
Note
Payload is parsed as repeated 4-byte tuples: [addr, status, brightness, type_raw]. Parsing stops at addr == 0x00 or sentinel tuple 0xFF, *, 0xFF, *.

◆ apply_status_payload()

void smartledz_protocol::v1::apply_status_payload ( uint16_t  src,
const uint8_t *  payload10,
size_t  payload_len,
uint32_t  now_ms,
std::map< uint16_t, DeviceStateSnapshot > *  states,
std::vector< uint16_t > *  updated_addresses 
)

Applies a status notify payload (opcode 0xDB) for one source address.

Parameters
srcSource mesh address from the decrypted frame.
payload10Pointer to notify payload bytes.
payload_lenNumber of bytes in payload10.
now_msCaller timestamp used to set last_update_ms.
statesAddress-to-state map to update.
updated_addressesOptional output vector appended with src when decoded.
Note
Requires at least 4 bytes and decodes: payload[0..2] => RGB, payload[3] => CT raw when in [18, 65].