mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
feat: edit ops and the reads their forms need, for socket protocol 2
The edit routes become ops 26-44 (addRoom ... groupSortOrder): ProtoEdits turns an op's payload into the route's request, full names and real booleans, and loop() applies it with applyModelEdit() as the route does. The reply goes to the client that sent it, with an add's new id, or the route's reason and a shade's validation code; the HTTP routes keep sending requestResult. getNextRoom, getNextShade, getNextGroup and groupOptions (45-48) are answered by loop() from the shade model, through a new LoopQueue item. Messages that arrive in pieces, a frame over one TCP segment or several frames, are put back together by ProtoAssembly: one at a time across clients, up to 4 KB, in a buffer held only while one is on its way. A message in pieces is now told from its first frame's opcode, which also stops a fragmented message's last frame drawing a second reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ea973809e2
commit
77237111ea
22 changed files with 851 additions and 22 deletions
25
src/ProtoEdits.h
Normal file
25
src/ProtoEdits.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef PROTO_EDITS_H
|
||||
#define PROTO_EDITS_H
|
||||
#include <stdint.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "ProtoSchema.h"
|
||||
#include "ModelEditor.h"
|
||||
|
||||
// Socket protocol 2's edit ops and the reads an edit form needs
|
||||
// (docs/PROTOCOL.md). An edit op is the edit route of the same name: its
|
||||
// payload, in full names, is what loop() applies with applyModelEdit(), so the
|
||||
// rules stay in one place. Kept free of the shade model and the web server so
|
||||
// it can be unit tested on the PC (pio test -e native).
|
||||
|
||||
// The edit an op asks for; false for a type that isn't an edit op.
|
||||
bool protoEditType(uint8_t type, model_edit_type_t &out);
|
||||
// The request of an edit route, from the op's payload d: full names for the
|
||||
// short keys, and booleans as true and false. A sort order's request is its
|
||||
// list of ids. nullptr when it is good; otherwise what is wrong with it, for
|
||||
// a bad request reply. As with every op, only what was sent is in it.
|
||||
const char *expandEditPayload(model_edit_type_t type, JsonObjectConst d, JsonDocument &doc);
|
||||
|
||||
// getNextRoom, getNextShade, getNextGroup and groupOptions: answered by
|
||||
// loop() from the shade model.
|
||||
bool protoIsReadOp(uint8_t type);
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue