feat: socket protocol 2 core on ws://host/ws

The /ws endpoint runs next to the old socket on port 8080.  The
handshake checks the token under security, the device sends hello,
then a sync of the schema (unless the client has it), header, rooms,
shades, groups, repeaters and status, paced by the client's next.
Events go out with the old ones: shadeState or the whole shade on a
config change, groups, rooms, removals, orders, repeaters,
shadeCommand, memory, wifi, ethernet, and the frames and
frequencyScan feeds.

The table of types, fields, errors and feeds is defined once and is
sent as the schema.  The writer, item writers, sync and client frame
parser are pure and natively tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-22 21:19:29 +02:00
parent a36888f8a1
commit 482e495678
24 changed files with 1839 additions and 5 deletions

View file

@ -22,14 +22,19 @@ enum : uint16_t {
SHADE_CHANGED_SUNNY = 0x0400,
SHADE_CHANGED_WINDY = 0x0800,
// Something only the socket's shadeState carries changed.
SHADE_CHANGED_STATE = 0x1000
SHADE_CHANGED_STATE = 0x1000,
// A setting changed (an edit, pairing, its room). Protocol 2 clients get the
// whole shade rather than its state.
SHADE_CHANGED_CONFIG = 0x2000
};
// The bits that have an MQTT topic.
#define SHADE_CHANGED_TOPICS 0x0FFF
// The same for a group: its direction topic, and groupState for the socket.
enum : uint8_t {
GROUP_CHANGED_DIRECTION = 0x01,
GROUP_CHANGED_STATE = 0x02
GROUP_CHANGED_STATE = 0x02,
// A setting or its shades changed: protocol 2 clients get the whole group.
GROUP_CHANGED_CONFIG = 0x04
};
// Publishes one MQTT topic: its name under shades/<id>/, its value and whether