mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
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:
parent
a36888f8a1
commit
482e495678
24 changed files with 1839 additions and 5 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "ESPNetwork.h"
|
||||
#include "entryPoints/Web.h"
|
||||
#include "outputs/SocketEmitter.h"
|
||||
#include "outputs/ProtoSocket.h"
|
||||
#include "Utils.h"
|
||||
#include "SSDP.h"
|
||||
#include "MqttConnection.h"
|
||||
|
|
@ -223,6 +224,9 @@ void ESPNetwork::emitSockets(uint8_t num) {
|
|||
}
|
||||
// A broadcast comes from emitSockets(), which has already sent memStatus.
|
||||
if(num != 255) this->emitHeap(num);
|
||||
// Protocol 2 clients get the status in their sync, so only broadcasts.
|
||||
else if(this->connType == conn_types_t::ethernet) protoSocket.ethernet();
|
||||
else protoSocket.wifi();
|
||||
}
|
||||
// Runs on the WiFi/Ethernet event task, so it sends nothing on the sockets.
|
||||
// loop() broadcasts the new status and a client that reconnects gets it from
|
||||
|
|
@ -690,5 +694,8 @@ void ESPNetwork::emitHeap(uint8_t num) {
|
|||
json->addElem("loopMaxUs", loopStats.maxUs());
|
||||
json->endObject();
|
||||
sockEmit.endEmit(num);
|
||||
if(num == 255) loopStats.publish(millis());
|
||||
if(num == 255) {
|
||||
protoSocket.memory();
|
||||
loopStats.publish(millis());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue