mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
feat!: remove the old API, ports 8081 and 8080 (step 4a)
Step 4a of docs/SECURITY_PLAN.md. Port 80 keeps the eleven HTTP routes of ADR 0006 and the socket at /ws; everything else moved to protocol 2. - Port 8081 (ApiRoutes) and the socket on 8080 (SocketEmitter) are gone. Protocol 2 owns its frame buffer and loop-task check. - Port 80 drops every route the old web UI called: reads, edits, settings, scans, reboot, /shades.cfg, /discovery. HttpRoutes.cpp holds what stays. - ModelSnapshot, SnapshotSlots and the read documents are gone. The item snapshot types stay, as ItemSnapshot, for events, MQTT and the command replies. - Model edits reply only to their protocol 2 op: requestResult goes. - The settings' toJSON writers, used only by the settings routes, go. - The _espsomfy_rts._tcp mDNS record moves to port 80, with path=/ws. - The memory event reports the loop-rate window it closes. - A deleted room no longer re-publishes its retained MQTT topics. - e2e: the heap check reads the sync's status; the sync is checked on its own instead of against /controller. - README gets an API and ports section. BREAKING CHANGE: ports 8081 and 8080 and the old HTTP routes are gone. Home Assistant needs integration 3.0.0 or newer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c91c20d444
commit
2a954aa158
53 changed files with 613 additions and 3549 deletions
|
|
@ -80,21 +80,6 @@ void appver_t::parse(const char *ver) {
|
|||
this->build = static_cast<uint8_t>(atoi(num) & 0xFF);
|
||||
if(strlen(ver) < i) strlcpy(this->suffix, &ver[i], sizeof(this->suffix));
|
||||
}
|
||||
bool appver_t::toJSON(JsonObject &obj) {
|
||||
obj["name"] = this->name;
|
||||
obj["major"] = this->major;
|
||||
obj["minor"] = this->minor;
|
||||
obj["build"] = this->build;
|
||||
obj["suffix"] = this->suffix;
|
||||
return true;
|
||||
}
|
||||
void appver_t::toJSON(JsonSockEvent *json) {
|
||||
json->addElem("name", this->name);
|
||||
json->addElem("major", this->major);
|
||||
json->addElem("minor", this->minor);
|
||||
json->addElem("build", this->build);
|
||||
json->addElem("suffix", this->suffix);
|
||||
}
|
||||
|
||||
bool BaseSettings::load() { return true; }
|
||||
bool BaseSettings::loadFile(const char *filename) {
|
||||
|
|
@ -115,15 +100,6 @@ bool BaseSettings::loadFile(const char *filename) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
bool BaseSettings::saveFile(const char *filename) {
|
||||
File file = LittleFS.open(filename, "w");
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
this->toJSON(obj);
|
||||
serializeJson(doc, file);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
bool BaseSettings::parseValueString(JsonObject &obj, const char *prop, char *pdest, size_t size) {
|
||||
if(!obj[prop].isNull()) strlcpy(pdest, obj[prop], size);
|
||||
return true;
|
||||
|
|
@ -234,13 +210,6 @@ bool ConfigSettings::save() {
|
|||
pref.end();
|
||||
return true;
|
||||
}
|
||||
bool ConfigSettings::toJSON(JsonObject &obj) {
|
||||
obj["ssdpBroadcast"] = this->ssdpBroadcast;
|
||||
obj["hostname"] = this->hostname;
|
||||
obj["connType"] = static_cast<uint8_t>(this->connType);
|
||||
obj["chipModel"] = this->chipModel;
|
||||
return true;
|
||||
}
|
||||
bool ConfigSettings::requiresAuth() { return this->Security.type != security_types::None; }
|
||||
bool ConfigSettings::fromJSON(JsonObject &obj) {
|
||||
if(!obj["ssdpBroadcast"].isNull()) this->ssdpBroadcast = obj["ssdpBroadcast"];
|
||||
|
|
@ -257,8 +226,6 @@ void ConfigSettings::print() {
|
|||
if(this->connType == conn_types_t::ethernet || this->connType == conn_types_t::ethernetpref) this->Ethernet.print();
|
||||
#endif
|
||||
}
|
||||
void ConfigSettings::emitSockets() {}
|
||||
void ConfigSettings::emitSockets(uint8_t num) {}
|
||||
uint16_t ConfigSettings::calcSettingsRecSize() {
|
||||
return strlen(this->fwVersion.name) + 3
|
||||
+ strlen(this->hostname) + 3
|
||||
|
|
@ -293,18 +260,6 @@ bool MQTTSettings::begin() {
|
|||
this->load();
|
||||
return true;
|
||||
}
|
||||
bool MQTTSettings::toJSON(JsonObject &obj) {
|
||||
obj["enabled"] = this->enabled;
|
||||
obj["pubDisco"] = this->pubDisco;
|
||||
obj["protocol"] = this->protocol;
|
||||
obj["hostname"] = this->hostname;
|
||||
obj["port"] = this->port;
|
||||
obj["username"] = this->username;
|
||||
obj["hasPassword"] = hasSecret(this->password);
|
||||
obj["rootTopic"] = this->rootTopic;
|
||||
obj["discoTopic"] = this->discoTopic;
|
||||
return true;
|
||||
}
|
||||
bool MQTTSettings::fromJSON(JsonObject &obj) {
|
||||
if(!obj["enabled"].isNull()) this->enabled = obj["enabled"];
|
||||
if(!obj["pubDisco"].isNull()) this->pubDisco = obj["pubDisco"];
|
||||
|
|
@ -351,16 +306,6 @@ bool MQTTSettings::load() {
|
|||
pref.end();
|
||||
return true;
|
||||
}
|
||||
bool ConfigSettings::toJSON(JsonDocument &doc) {
|
||||
doc["fwVersion"] = this->fwVersion.name;
|
||||
JsonObject objWIFI = doc.createNestedObject("WIFI");
|
||||
this->WIFI.toJSON(objWIFI);
|
||||
JsonObject objNTP = doc.createNestedObject("NTP");
|
||||
this->NTP.toJSON(objNTP);
|
||||
JsonObject objMQTT = doc.createNestedObject("MQTT");
|
||||
this->MQTT.toJSON(objMQTT);
|
||||
return true;
|
||||
}
|
||||
bool NTPSettings::begin() {
|
||||
this->load();
|
||||
this->apply();
|
||||
|
|
@ -391,11 +336,6 @@ bool NTPSettings::fromJSON(JsonObject &obj) {
|
|||
this->parseValueString(obj, "posixZone", this->posixZone, sizeof(this->posixZone));
|
||||
return true;
|
||||
}
|
||||
bool NTPSettings::toJSON(JsonObject &obj) {
|
||||
obj["ntpServer"] = this->ntpServer;
|
||||
obj["posixZone"] = this->posixZone;
|
||||
return true;
|
||||
}
|
||||
bool NTPSettings::apply() {
|
||||
// Sets the zone and starts SNTP, which sets the clock once the network is
|
||||
// up. Waiting here with getLocalTime() held up boot by 5 s before the
|
||||
|
|
@ -417,16 +357,6 @@ bool IPSettings::fromJSON(JsonObject &obj) {
|
|||
this->parseIPAddress(obj, "dns2", &this->dns2);
|
||||
return true;
|
||||
}
|
||||
bool IPSettings::toJSON(JsonObject &obj) {
|
||||
IPAddress ipEmpty(0,0,0,0);
|
||||
obj["dhcp"] = this->dhcp;
|
||||
obj["ip"] = this->ip == ipEmpty ? "" : this->ip.toString();
|
||||
obj["gateway"] = this->gateway == ipEmpty ? "" : this->gateway.toString();
|
||||
obj["subnet"] = this->subnet == ipEmpty ? "" : this->subnet.toString();
|
||||
obj["dns1"] = this->dns1 == ipEmpty ? "" : this->dns1.toString();
|
||||
obj["dns2"] = this->dns2 == ipEmpty ? "" : this->dns2.toString();
|
||||
return true;
|
||||
}
|
||||
bool IPSettings::save() {
|
||||
Preferences pref;
|
||||
pref.begin("IP");
|
||||
|
|
@ -481,14 +411,6 @@ bool SecuritySettings::fromJSON(JsonObject &obj) {
|
|||
if(!obj["permissions"].isNull()) this->permissions = obj["permissions"];
|
||||
return true;
|
||||
}
|
||||
bool SecuritySettings::toJSON(JsonObject &obj) {
|
||||
obj["type"] = static_cast<uint8_t>(this->type);
|
||||
obj["username"] = this->username;
|
||||
obj["hasPassword"] = hasSecret(this->password);
|
||||
obj["hasPin"] = hasSecret(this->pin);
|
||||
obj["permissions"] = this->permissions;
|
||||
return true;
|
||||
}
|
||||
bool SecuritySettings::save() {
|
||||
Preferences pref;
|
||||
pref.begin("SEC");
|
||||
|
|
@ -532,13 +454,6 @@ bool WifiSettings::fromJSON(JsonObject &obj) {
|
|||
if(!obj["hidden"].isNull()) this->hidden = obj["hidden"];
|
||||
return true;
|
||||
}
|
||||
bool WifiSettings::toJSON(JsonObject &obj) {
|
||||
obj["ssid"] = this->ssid;
|
||||
obj["hasPassphrase"] = hasSecret(this->passphrase);
|
||||
obj["roaming"] = this->roaming;
|
||||
obj["hidden"] = this->hidden;
|
||||
return true;
|
||||
}
|
||||
bool WifiSettings::save() {
|
||||
Preferences pref;
|
||||
pref.begin("WIFI");
|
||||
|
|
@ -615,16 +530,6 @@ bool EthernetSettings::fromJSON(JsonObject &obj) {
|
|||
if(!obj["MDIOPin"].isNull()) this->MDIOPin = obj["MDIOPin"];
|
||||
return true;
|
||||
}
|
||||
bool EthernetSettings::toJSON(JsonObject &obj) {
|
||||
obj["boardType"] = this->boardType;
|
||||
obj["phyAddress"] = this->phyAddress;
|
||||
obj["CLKMode"] = static_cast<uint8_t>(this->CLKMode);
|
||||
obj["phyType"] = this->phyType;
|
||||
obj["PWRPin"] = this->PWRPin;
|
||||
obj["MDCPin"] = this->MDCPin;
|
||||
obj["MDIOPin"] = this->MDIOPin;
|
||||
return true;
|
||||
}
|
||||
bool EthernetSettings::usesPin(uint8_t pin) {
|
||||
if((this->CLKMode == 0 || this->CLKMode == 1) && pin == 0) return true;
|
||||
else if(this->CLKMode == 2 && pin == 16) return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue