remove sync server

This commit is contained in:
cjkas 2026-03-24 14:36:57 +01:00
parent 9584f01a70
commit 8262f392f5
10 changed files with 12 additions and 369 deletions

View file

@ -85,13 +85,6 @@ bool appver_t::toJSON(JsonObject &obj) {
obj["suffix"] = this->suffix;
return true;
}
void appver_t::toJSON(JsonResponse &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);
}
void appver_t::toJSON(JsonSockEvent *json) {
json->addElem("name", this->name);
json->addElem("major", this->major);
@ -249,14 +242,6 @@ bool ConfigSettings::toJSON(JsonObject &obj) {
obj["checkForUpdate"] = this->checkForUpdate;
return true;
}
void ConfigSettings::toJSON(JsonResponse &json) {
json.addElem("ssdpBroadcast", this->ssdpBroadcast);
json.addElem("hostname", this->hostname);
json.addElem("connType", static_cast<uint8_t>(this->connType));
json.addElem("chipModel", this->chipModel);
json.addElem("checkForUpdate", this->checkForUpdate);
}
bool ConfigSettings::requiresAuth() { return this->Security.type != security_types::None; }
bool ConfigSettings::fromJSON(JsonObject &obj) {
if(obj.containsKey("ssdpBroadcast")) this->ssdpBroadcast = obj["ssdpBroadcast"];
@ -308,18 +293,6 @@ bool MQTTSettings::begin() {
this->load();
return true;
}
void MQTTSettings::toJSON(JsonResponse &json) {
json.addElem("enabled", this->enabled);
json.addElem("pubDisco", this->pubDisco);
json.addElem("protocol", this->protocol);
json.addElem("hostname", this->hostname);
json.addElem("port", (uint32_t)this->port);
json.addElem("username", this->username);
json.addElem("password", this->password);
json.addElem("rootTopic", this->rootTopic);
json.addElem("discoTopic", this->discoTopic);
}
bool MQTTSettings::toJSON(JsonObject &obj) {
obj["enabled"] = this->enabled;
obj["pubDisco"] = this->pubDisco;
@ -418,11 +391,6 @@ bool NTPSettings::fromJSON(JsonObject &obj) {
this->parseValueString(obj, "posixZone", this->posixZone, sizeof(this->posixZone));
return true;
}
void NTPSettings::toJSON(JsonResponse &json) {
json.addElem("ntpServer", this->ntpServer);
json.addElem("posixZone", this->posixZone);
}
bool NTPSettings::toJSON(JsonObject &obj) {
obj["ntpServer"] = this->ntpServer;
obj["posixZone"] = this->posixZone;
@ -459,16 +427,6 @@ bool IPSettings::toJSON(JsonObject &obj) {
obj["dns2"] = this->dns2 == ipEmpty ? "" : this->dns2.toString();
return true;
}
void IPSettings::toJSON(JsonResponse &json) {
IPAddress ipEmpty(0,0,0,0);
json.addElem("dhcp", this->dhcp);
json.addElem("ip", this->ip.toString().c_str());
json.addElem("gateway", this->gateway.toString().c_str());
json.addElem("subnet", this->subnet.toString().c_str());
json.addElem("dns1", this->dns1.toString().c_str());
json.addElem("dns2", this->dns2.toString().c_str());
}
bool IPSettings::save() {
pref.begin("IP");
pref.clear();
@ -529,14 +487,6 @@ bool SecuritySettings::toJSON(JsonObject &obj) {
obj["permissions"] = this->permissions;
return true;
}
void SecuritySettings::toJSON(JsonResponse &json) {
json.addElem("type", static_cast<uint8_t>(this->type));
json.addElem("username", this->username);
json.addElem("password", this->password);
json.addElem("pin", this->pin);
json.addElem("permissions", this->permissions);
}
bool SecuritySettings::save() {
pref.begin("SEC");
pref.clear();
@ -590,13 +540,6 @@ bool WifiSettings::toJSON(JsonObject &obj) {
obj["hidden"] = this->hidden;
return true;
}
void WifiSettings::toJSON(JsonResponse &json) {
json.addElem("ssid", this->ssid);
json.addElem("passphrase", this->passphrase);
json.addElem("roaming", this->roaming);
json.addElem("hidden", this->hidden);
}
bool WifiSettings::save() {
pref.begin("WIFI");
pref.clear();
@ -697,16 +640,6 @@ bool EthernetSettings::toJSON(JsonObject &obj) {
obj["MDIOPin"] = this->MDIOPin;
return true;
}
void EthernetSettings::toJSON(JsonResponse &json) {
json.addElem("boardType", this->boardType);
json.addElem("phyAddress", this->phyAddress);
json.addElem("CLKMode", static_cast<uint8_t>(this->CLKMode));
json.addElem("phyType", static_cast<uint8_t>(this->phyType));
json.addElem("PWRPin", this->PWRPin);
json.addElem("MDCPin", this->MDCPin);
json.addElem("MDIOPin", this->MDIOPin);
}
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;

View file

@ -34,7 +34,7 @@ struct appver_t {
char suffix[4] = "";
void parse(const char *ver);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
void toJSON(JsonSockEvent *json);
int8_t compare(appver_t &ver);
void copy(appver_t &ver);
@ -46,7 +46,7 @@ class BaseSettings {
bool loadFile(const char* filename);
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool parseIPAddress(JsonObject &obj, const char *prop, IPAddress *);
bool parseValueString(JsonObject &obj, const char *prop, char *dest, size_t size);
int parseValueInt(JsonObject &obj, const char *prop, int defVal);
@ -61,7 +61,7 @@ class NTPSettings: BaseSettings {
char posixZone[64] = "";
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool apply();
bool begin();
bool save();
@ -79,7 +79,7 @@ class WifiSettings: BaseSettings {
bool begin();
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
String mapEncryptionType(int type);
bool ssidExists(const char *ssid);
void printNetworks();
@ -102,7 +102,7 @@ class EthernetSettings: BaseSettings {
bool begin();
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool load();
bool save();
void print();
@ -120,7 +120,7 @@ class IPSettings: BaseSettings {
bool begin();
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool load();
bool save();
void print();
@ -145,7 +145,7 @@ class SecuritySettings: BaseSettings {
bool load();
void print();
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool fromJSON(JsonObject &obj);
};
class MQTTSettings: BaseSettings {
@ -163,7 +163,7 @@ class MQTTSettings: BaseSettings {
bool save();
bool load();
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool fromJSON(JsonObject &obj);
};
class ConfigSettings: BaseSettings {
@ -187,7 +187,7 @@ class ConfigSettings: BaseSettings {
bool requiresAuth();
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
bool begin();
bool save();
bool load();

View file

@ -72,22 +72,6 @@ void GitRelease::setAssetProperty(const char *key, const char *val) {
}
}
}
void GitRelease::toJSON(JsonResponse &json) {
Timestamp ts;
char buff[20];
sprintf(buff, "%llu", this->id);
json.addElem("id", buff);
json.addElem("name", this->name);
json.addElem("date", ts.getISOTime(this->releaseDate));
json.addElem("draft", this->draft);
json.addElem("preRelease", this->preRelease);
json.addElem("main", this->main);
json.addElem("hasFS", this->hasFS);
json.addElem("hwVersions", this->hwVersions);
json.beginObject("version");
this->version.toJSON(json);
json.endObject();
}
#define ERR_CLIENT_OFFSET -50
int16_t GitRepo::getReleases(uint8_t num) {
@ -230,22 +214,6 @@ int16_t GitRepo::getReleases(uint8_t num) {
settings.printAvailHeap();
return 0;
}
void GitRepo::toJSON(JsonResponse &json) {
json.beginObject("fwVersion");
settings.fwVersion.toJSON(json);
json.endObject();
json.beginObject("appVersion");
settings.appVersion.toJSON(json);
json.endObject();
json.beginArray("releases");
for(uint8_t i = 0; i < GIT_MAX_RELEASES + 1; i++) {
if(this->releases[i].id == 0) continue;
json.beginObject();
this->releases[i].toJSON(json);
json.endObject();
}
json.endArray();
}
#define UPDATE_ERR_OFFSET 20
#define ERR_DOWNLOAD_HTTP -40
#define ERR_DOWNLOAD_BUFFER -41
@ -310,23 +278,6 @@ void GitUpdater::setCurrentRelease(GitRepo &repo) {
}
this->emitUpdateCheck();
}
void GitUpdater::toJSON(JsonResponse &json) {
json.addElem("available", this->updateAvailable);
json.addElem("status", this->status);
json.addElem("error", (int32_t)this->error);
json.addElem("cancelled", this->cancelled);
json.addElem("checkForUpdate", settings.checkForUpdate);
json.addElem("inetAvailable", this->inetAvailable);
json.beginObject("fwVersion");
settings.fwVersion.toJSON(json);
json.endObject();
json.beginObject("appVersion");
settings.appVersion.toJSON(json);
json.endObject();
json.beginObject("latest");
this->latest.toJSON(json);
json.endObject();
}
void GitUpdater::emitUpdateCheck(uint8_t num) {
JsonSockEvent *json = sockEmit.beginEmit("fwStatus");
json->beginObject();

View file

@ -28,13 +28,13 @@ class GitRelease {
appver_t version;
void setReleaseProperty(const char *key, const char *val);
void setAssetProperty(const char *key, const char *val);
void toJSON(JsonResponse &json);
};
class GitRepo {
public:
int16_t getReleases(uint8_t num = GIT_MAX_RELEASES);
GitRelease releases[GIT_MAX_RELEASES + 1];
void toJSON(JsonResponse &json);
};
class GitUpdater {
public:
@ -58,7 +58,7 @@ class GitUpdater {
void setFirmwareFile();
void setCurrentRelease(GitRepo &repo);
void loop();
void toJSON(JsonResponse &json);
bool recoverFilesystem();
int checkInternet();
void emitUpdateCheck(uint8_t num=255);

View file

@ -1,7 +1,6 @@
#include <Preferences.h>
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <SPI.h>
#include <WebServer.h>
#include <esp_task_wdt.h>
#include "Utils.h"
#include "ConfigSettings.h"
@ -3328,72 +3327,6 @@ int8_t SomfyShade::fromJSON(JsonObject &obj) {
}
return err;
}
void SomfyShade::toJSONRef(JsonResponse &json) {
json.addElem("shadeId", this->getShadeId());
json.addElem("roomId", this->roomId);
json.addElem("name", this->name);
json.addElem("remoteAddress", (uint32_t)this->m_remoteAddress);
json.addElem("paired", this->paired);
json.addElem("shadeType", static_cast<uint8_t>(this->shadeType));
json.addElem("flipCommands", this->flipCommands);
json.addElem("flipPosition", this->flipCommands);
json.addElem("bitLength", this->bitLength);
json.addElem("proto", static_cast<uint8_t>(this->proto));
json.addElem("flags", this->flags);
json.addElem("sunSensor", this->hasSunSensor());
json.addElem("hasLight", this->hasLight());
json.addElem("repeats", this->repeats);
//SomfyRemote::toJSON(json);
}
void SomfyShade::toJSON(JsonResponse &json) {
json.addElem("shadeId", this->getShadeId());
json.addElem("roomId", this->roomId);
json.addElem("name", this->name);
json.addElem("remoteAddress", (uint32_t)this->m_remoteAddress);
json.addElem("upTime", (uint32_t)this->upTime);
json.addElem("downTime", (uint32_t)this->downTime);
json.addElem("paired", this->paired);
json.addElem("lastRollingCode", (uint32_t)this->lastRollingCode);
json.addElem("position", this->transformPosition(this->currentPos));
json.addElem("tiltType", static_cast<uint8_t>(this->tiltType));
json.addElem("tiltPosition", this->transformPosition(this->currentTiltPos));
json.addElem("tiltDirection", this->tiltDirection);
json.addElem("tiltTime", (uint32_t)this->tiltTime);
json.addElem("stepSize", (uint32_t)this->stepSize);
json.addElem("tiltTarget", this->transformPosition(this->tiltTarget));
json.addElem("target", this->transformPosition(this->target));
json.addElem("myPos", this->transformPosition(this->myPos));
json.addElem("myTiltPos", this->transformPosition(this->myTiltPos));
json.addElem("direction", this->direction);
json.addElem("shadeType", static_cast<uint8_t>(this->shadeType));
json.addElem("bitLength", this->bitLength);
json.addElem("proto", static_cast<uint8_t>(this->proto));
json.addElem("flags", this->flags);
json.addElem("flipCommands", this->flipCommands);
json.addElem("flipPosition", this->flipPosition);
json.addElem("inGroup", this->isInGroup());
json.addElem("sunSensor", this->hasSunSensor());
json.addElem("light", this->hasLight());
json.addElem("repeats", this->repeats);
json.addElem("sortOrder", this->sortOrder);
json.addElem("gpioUp", this->gpioUp);
json.addElem("gpioDown", this->gpioDown);
json.addElem("gpioMy", this->gpioMy);
json.addElem("gpioLLTrigger", ((this->gpioFlags & (uint8_t)gpio_flags_t::LowLevelTrigger) == 0) ? false : true);
json.addElem("simMy", this->simMy());
json.beginArray("linkedRemotes");
for(uint8_t i = 0; i < SOMFY_MAX_LINKED_REMOTES; i++) {
SomfyLinkedRemote &lremote = this->linkedRemotes[i];
if(lremote.getRemoteAddress() != 0) {
json.beginObject();
lremote.toJSON(json);
json.endObject();
}
}
json.endArray();
}
/*
bool SomfyShade::toJSON(JsonObject &obj) {
//Serial.print("Serializing Shade:");
@ -3461,12 +3394,6 @@ bool SomfyRoom::toJSON(JsonObject &obj) {
return true;
}
*/
void SomfyRoom::toJSON(JsonResponse &json) {
json.addElem("roomId", this->roomId);
json.addElem("name", this->name);
json.addElem("sortOrder", this->sortOrder);
}
bool SomfyGroup::fromJSON(JsonObject &obj) {
if(obj.containsKey("name")) strlcpy(this->name, obj["name"], sizeof(this->name));
if(obj.containsKey("roomId")) this->roomId = obj["roomId"];
@ -3488,50 +3415,6 @@ bool SomfyGroup::fromJSON(JsonObject &obj) {
}
return true;
}
void SomfyGroup::toJSON(JsonResponse &json) {
this->updateFlags();
json.addElem("groupId", this->getGroupId());
json.addElem("roomId", this->roomId);
json.addElem("name", this->name);
json.addElem("remoteAddress", (uint32_t)this->m_remoteAddress);
json.addElem("lastRollingCode", (uint32_t)this->lastRollingCode);
json.addElem("bitLength", this->bitLength);
json.addElem("proto", static_cast<uint8_t>(this->proto));
json.addElem("sunSensor", this->hasSunSensor());
json.addElem("flipCommands", this->flipCommands);
json.addElem("flags", this->flags);
json.addElem("repeats", this->repeats);
json.addElem("sortOrder", this->sortOrder);
json.beginArray("linkedShades");
for(uint8_t i = 0; i < SOMFY_MAX_GROUPED_SHADES; i++) {
uint8_t shadeId = this->linkedShades[i];
if(shadeId > 0 && shadeId < 255) {
SomfyShade *shade = somfy.getShadeById(shadeId);
if(shade) {
json.beginObject();
shade->toJSONRef(json);
json.endObject();
}
}
}
json.endArray();
}
void SomfyGroup::toJSONRef(JsonResponse &json) {
this->updateFlags();
json.addElem("groupId", this->getGroupId());
json.addElem("roomId", this->roomId);
json.addElem("name", this->name);
json.addElem("remoteAddress", (uint32_t)this->m_remoteAddress);
json.addElem("lastRollingCode", (uint32_t)this->lastRollingCode);
json.addElem("bitLength", this->bitLength);
json.addElem("proto", static_cast<uint8_t>(this->proto));
json.addElem("sunSensor", this->hasSunSensor());
json.addElem("flipCommands", this->flipCommands);
json.addElem("flags", this->flags);
json.addElem("repeats", this->repeats);
json.addElem("sortOrder", this->sortOrder);
}
/*
bool SomfyGroup::toJSON(JsonObject &obj) {
this->updateFlags();
@ -3563,10 +3446,6 @@ bool SomfyGroup::toJSON(JsonObject &obj) {
}
*/
void SomfyRemote::toJSON(JsonResponse &json) {
json.addElem("remoteAddress", (uint32_t)this->getRemoteAddress());
json.addElem("lastRollingCode", (uint32_t)this->lastRollingCode);
}
/*
bool SomfyRemote::toJSON(JsonObject &obj) {
//obj["remotePrefId"] = this->getRemotePrefId();
@ -4131,26 +4010,6 @@ uint16_t SomfyRemote::setRollingCode(uint16_t code) {
}
return code;
}
void SomfyShadeController::toJSONRooms(JsonResponse &json) {
for(uint8_t i = 0; i < SOMFY_MAX_ROOMS; i++) {
SomfyRoom *room = &this->rooms[i];
if(room->roomId != 0) {
json.beginObject();
room->toJSON(json);
json.endObject();
}
}
}
void SomfyShadeController::toJSONShades(JsonResponse &json) {
for(uint8_t i = 0; i < SOMFY_MAX_SHADES; i++) {
SomfyShade &shade = this->shades[i];
if(shade.getShadeId() != 255) {
json.beginObject();
shade.toJSON(json);
json.endObject();
}
}
}
/*
bool SomfyShadeController::toJSON(DynamicJsonDocument &doc) {
@ -4205,21 +4064,6 @@ bool SomfyShadeController::toJSONGroups(JsonArray &arr) {
return true;
}
*/
void SomfyShadeController::toJSONGroups(JsonResponse &json) {
for(uint8_t i = 0; i < SOMFY_MAX_GROUPS; i++) {
SomfyGroup &group = this->groups[i];
if(group.getGroupId() != 255) {
json.beginObject();
group.toJSON(json);
json.endObject();
}
}
}
void SomfyShadeController::toJSONRepeaters(JsonResponse &json) {
for(uint8_t i = 0; i < SOMFY_MAX_REPEATERS; i++) {
if(somfy.repeaters[i] != 0) json.addElem((uint32_t)somfy.repeaters[i]);
}
}
void SomfyShadeController::loop() {
this->transceiver.loop();
for(uint8_t i = 0; i < SOMFY_MAX_SHADES; i++) {
@ -4703,11 +4547,6 @@ void Transceiver::disableReceive(void) {
interruptPin = 0;
}
void Transceiver::toJSON(JsonResponse& json) {
json.beginObject("config");
this->config.toJSON(json);
json.endObject();
}
/*
bool Transceiver::toJSON(JsonObject& obj) {
//Serial.println("Setting Transceiver Json");
@ -4786,22 +4625,6 @@ void transceiver_config_t::fromJSON(JsonObject& obj) {
*/
Serial.printf("SCK:%u MISO:%u MOSI:%u CSN:%u RX:%u TX:%u\n", this->SCKPin, this->MISOPin, this->MOSIPin, this->CSNPin, this->RXPin, this->TXPin);
}
void transceiver_config_t::toJSON(JsonResponse &json) {
json.addElem("type", this->type);
json.addElem("TXPin", this->TXPin);
json.addElem("RXPin", this->RXPin);
json.addElem("SCKPin", this->SCKPin);
json.addElem("MOSIPin", this->MOSIPin);
json.addElem("MISOPin", this->MISOPin);
json.addElem("CSNPin", this->CSNPin);
json.addElem("rxBandwidth", this->rxBandwidth); // float
json.addElem("frequency", this->frequency); // float
json.addElem("deviation", this->deviation); // float
json.addElem("txPower", this->txPower);
json.addElem("proto", static_cast<uint8_t>(this->proto));
json.addElem("enabled", this->enabled);
json.addElem("radioInit", this->radioInit);
}
/*
void transceiver_config_t::toJSON(JsonObject& obj) {
obj["type"] = this->type;

View file

@ -209,7 +209,6 @@ class SomfyRoom {
void clear();
bool save();
bool fromJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
void emitState(const char *evt = "roomState");
void emitState(uint8_t num, const char *evt = "roomState");
void publish();
@ -239,7 +238,6 @@ class SomfyRemote {
uint8_t repeats = 1;
virtual bool isLastCommand(somfy_commands cmd);
char *getRemotePrefId() {return m_remotePrefId;}
virtual void toJSON(JsonResponse &json);
virtual void setRemoteAddress(uint32_t address);
virtual uint32_t getRemoteAddress();
virtual uint16_t getNextRollingCode();
@ -304,9 +302,7 @@ class SomfyShade : public SomfyRemote {
SomfyLinkedRemote linkedRemotes[SOMFY_MAX_LINKED_REMOTES];
bool paired = false;
int8_t validateJSON(JsonObject &obj);
void toJSONRef(JsonResponse &json);
int8_t fromJSON(JsonObject &obj);
void toJSON(JsonResponse &json) override;
char name[21] = "";
void setShadeId(uint8_t id) { shadeId = id; }
@ -393,9 +389,6 @@ class SomfyGroup : public SomfyRemote {
void clear();
bool fromJSON(JsonObject &obj);
//bool toJSON(JsonObject &obj);
void toJSON(JsonResponse &json);
void toJSONRef(JsonResponse &json);
bool linkShade(uint8_t shadeId);
bool unlinkShade(uint8_t shadeId);
bool hasShadeId(uint8_t shadeId);
@ -485,7 +478,6 @@ struct transceiver_config_t {
*/
void fromJSON(JsonObject& obj);
//void toJSON(JsonObject& obj);
void toJSON(JsonResponse& json);
void save();
void load();
void apply();
@ -500,7 +492,6 @@ class Transceiver {
transceiver_config_t config;
bool printBuffer = false;
//bool toJSON(JsonObject& obj);
void toJSON(JsonResponse& json);
bool fromJSON(JsonObject& obj);
bool save();
bool begin();
@ -557,10 +548,6 @@ class SomfyShadeController {
SomfyGroup groups[SOMFY_MAX_GROUPS];
bool linkRepeater(uint32_t address);
bool unlinkRepeater(uint32_t address);
void toJSONShades(JsonResponse &json);
void toJSONRooms(JsonResponse &json);
void toJSONGroups(JsonResponse &json);
void toJSONRepeaters(JsonResponse &json);
uint8_t repeaterCount();
uint8_t roomCount();
uint8_t shadeCount();

View file

@ -1,6 +1,4 @@
#include "WResp.h"
#include <WebServer.h>
#include <esp_task_wdt.h>
void JsonSockEvent::beginEvent(AsyncWebSocket *server, const char *evt, char *buff, size_t buffSize) {
this->server = server;
this->buff = buff;
@ -35,41 +33,6 @@ void JsonSockEvent::_safecat(const char *val, bool escape) {
else strcat(this->buff, val);
if(escape) strcat(this->buff, "\"");
}
void JsonResponse::beginResponse(WebServer *server, char *buff, size_t buffSize) {
this->server = server;
this->buff = buff;
this->buffSize = buffSize;
this->buff[0] = 0x00;
this->_nocomma = true;
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
}
void JsonResponse::endResponse() {
if(strlen(buff)) this->send();
server->sendContent("", 0);
}
void JsonResponse::send() {
Serial.println("JsonResponse::send start ");
unsigned long ts = millis();
esp_task_wdt_reset();
if(!this->_headersSent) server->send_P(200, "application/json", this->buff);
else server->sendContent(this->buff);
//Serial.printf("Sent %d bytes %d\n", strlen(this->buff), this->buffSize);
this->buff[0] = 0x00;
this->_headersSent = true;
Serial.printf("JsonResponse::send end took %d ms\n", millis() - ts);
}
void JsonResponse::_safecat(const char *val, bool escape) {
size_t len = (escape ? this->calcEscapedLength(val) : strlen(val)) + strlen(this->buff);
if(escape) len += 2;
if(len >= this->buffSize) {
this->send();
}
if(escape) strcat(this->buff, "\"");
if(escape) this->escapeString(val, &this->buff[strlen(this->buff)]);
else strcat(this->buff, val);
if(escape) strcat(this->buff, "\"");
}
void AsyncJsonResp::beginResponse(AsyncWebServerRequest *request, char *buff, size_t buffSize) {
this->_request = request;
this->buff = buff;

View file

@ -3,8 +3,6 @@
#ifndef wresp_h
#define wresp_h
class WebServer;
class JsonFormatter {
protected:
char *buff;
@ -54,15 +52,6 @@ class JsonFormatter {
void addElem(const char *name, const char *val);
void addElem(const char* name, uint64_t lval);
};
class JsonResponse : public JsonFormatter {
protected:
void _safecat(const char *val, bool escape = false) override;
public:
WebServer *server;
void beginResponse(WebServer *server, char *buff, size_t buffSize);
void endResponse();
void send();
};
class AsyncJsonResp : public JsonFormatter {
protected:
void _safecat(const char *val, bool escape = false) override;

View file

@ -63,8 +63,6 @@ void Web::startup() {
void Web::loop() {
delay(1);
}
void Web::end() {
}
bool Web::isAuthenticated(AsyncWebServerRequest *request, bool cfg) {
Serial.println("Checking async authentication");
if(settings.Security.type == security_types::None) return true;

View file

@ -9,7 +9,6 @@ class Web {
void startup();
void begin();
void loop();
void end();
// Auth helpers
bool createAPIToken(const IPAddress ipAddress, char *token);
bool createAPIToken(const char *payload, char *token);