mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
feat: command ops for socket protocol 2
shadeCommand, groupCommand, tiltCommand, repeatCommand, setPositions, setSensor, setMyPosition, unpairShade, setRollingCode (types 16-24) are read on async_tcp by ProtoOps and handed to loop() through the LoopQueue, which replies once the request has run: ok, not found or radio unavailable. A bad payload, a paused radio or a full queue is answered straight away. sendRemoteCommand (25) touches nothing of the shade model, so it goes to the radio from async_tcp like its route. ShadeRequests::run() now says how a request went, not only whether the radio took it. An op reads only the fields that were sent, so setPositions can leave the tilt as it is. The shadeCommand event is renamed shadeCommanded, since the op has the route's name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9fe05105ff
commit
0b54264ee3
18 changed files with 812 additions and 50 deletions
34
src/ProtoOps.h
Normal file
34
src/ProtoOps.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef PROTO_OPS_H
|
||||
#define PROTO_OPS_H
|
||||
#include <stdint.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "ProtoSchema.h"
|
||||
#include "ShadeRequests.h"
|
||||
#include "SomfyFrame.h"
|
||||
|
||||
// Socket protocol 2's command ops (docs/PROTOCOL.md): what each one asks for,
|
||||
// read from its payload. Kept free of the shade model and the web server so
|
||||
// it can be unit tested on the PC (pio test -e native).
|
||||
//
|
||||
// The readers are strict where the HTTP routes guess: a field of the wrong
|
||||
// kind, a value out of range or a command name that isn't one is a bad
|
||||
// request, not a default.
|
||||
|
||||
// Every command op except sendRemoteCommand becomes a shade request that
|
||||
// loop() runs.
|
||||
bool protoIsShadeOp(uint8_t type);
|
||||
// nullptr when the payload is good and req is filled in; otherwise what is
|
||||
// wrong with it, for a bad request reply.
|
||||
const char *parseShadeOp(uint8_t type, JsonObjectConst d, shade_request_t &req);
|
||||
// sendRemoteCommand: a frame as a remote that isn't one of the shades, so it
|
||||
// touches nothing of the shade model. The same as parseShadeOp otherwise.
|
||||
const char *parseRemoteCommandOp(JsonObjectConst d, somfy_frame_t &frame, uint8_t &repeats);
|
||||
// A command by its name, as shadeCommanded reports it ("Up", "StepDown"),
|
||||
// in any case. False for a name that isn't a command.
|
||||
bool protoCommand(const char *name, somfy_commands &cmd);
|
||||
|
||||
// The reply to a shade request that loop() has run: none when it was done.
|
||||
proto_error_t protoRequestError(shade_request_result_t result);
|
||||
// What that reply says.
|
||||
const char *protoRequestErrorDesc(const shade_request_t &req, shade_request_result_t result);
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue