mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
/controller, /discovery, /rooms, /shades, /groups, /room, /shade and /group now take a SnapshotSlots slot, queue a fill on the LoopQueue and send a chunked response whose body waits (RESPONSE_TRY_AGAIN) until loop() has copied the shade model into the slot. SnapshotWriter then streams the document from that copy a unit at a time, so each document describes one moment. At most two reads run at once; a third gets 503. A slot's 5.6 KB snapshot is allocated only while a read holds it, and its atomic state decides whether loop() or the read frees it when the read goes away first. The JSON of each item is unchanged and now lives in ModelSnapshot.cpp, where the native tests check it. Replies still written on the web server task copy their one item with SomfySnapshot.cpp, so serializing a group no longer calls updateFlags(), which emitted groupState and published MQTT from async_tcp. Also: every read route is chunked and leaves out an item too big for its 3 KB unit, like /controller did; /discovery drops its timing log; the SOMFY_MAX_* limits move to ShadeTypes.h. 21 new native tests, 292 in all. Flash: esp32devdbg +440 bytes, esp32dev +2,064 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
670 B
C
17 lines
670 B
C
#ifndef SOMFY_SNAPSHOT_H
|
|
#define SOMFY_SNAPSHOT_H
|
|
#include "ModelSnapshot.h"
|
|
#include "Somfy.h"
|
|
|
|
// Copies the shade model into the ModelSnapshot types.
|
|
|
|
void snapshotRoom(SomfyRoom &room, room_snapshot_t &out);
|
|
void snapshotShade(SomfyShade &shade, shade_snapshot_t &out);
|
|
// Works the group's flags out from its shades without changing the group.
|
|
void snapshotGroup(SomfyGroup &group, group_snapshot_t &out);
|
|
// The whole shade model. loop() only.
|
|
void fillSnapshot(model_snapshot_t &snap);
|
|
// A shade_lookup_t over the live shade model for writeGroup. ctx is a
|
|
// shade_snapshot_t to copy into.
|
|
const shade_snapshot_t *liveShade(uint8_t shadeId, void *ctx);
|
|
#endif
|