Minor string optimisations.

This commit is contained in:
Blaz Kristan 2022-10-09 12:09:46 +02:00
parent 1f32f96487
commit d00a708177
3 changed files with 9 additions and 9 deletions

View File

@ -293,8 +293,8 @@ class MultiRelay : public Usermod {
json[F("stat_t")] = "~";
json[F("cmd_t")] = F("~/command");
json[F("pl_off")] = F("off");
json[F("pl_on")] = F("on");
json[F("pl_off")] = "off";
json[F("pl_on")] = "on";
json[F("uniq_id")] = uid;
strcpy(buf, mqttDeviceTopic); //max length: 33 + 7 = 40

View File

@ -309,7 +309,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
receiveNotifications = udpn["recv"] | receiveNotifications;
if ((bool)udpn[F("nn")]) callMode = CALL_MODE_NO_NOTIFY; //send no notification just for this request
unsigned long timein = root[F("time")] | UINT32_MAX; //backup time source if NTP not synced
unsigned long timein = root["time"] | UINT32_MAX; //backup time source if NTP not synced
if (timein != UINT32_MAX) {
setTimeFromAPI(timein);
if (presetsModifiedTime == 0) presetsModifiedTime = timein;
@ -396,8 +396,8 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
// b) preset ID only or preset that does not change state (use embedded cycling limits if they exist in getVal())
presetCycCurr = ps;
presetId = ps;
root.remove(F("v")); // may be added in UI call
root.remove(F("time")); // may be added in UI call
root.remove("v"); // may be added in UI call
root.remove("time"); // may be added in UI call
root.remove("ps");
if (root.size() == 0) {
applyPreset(ps, callMode); // async load (only preset ID was specified)

View File

@ -36,13 +36,13 @@ static void doSaveState() {
}
sObj["n"] = saveName;
if (quickLoad[0]) sObj[F("ql")] = quickLoad;
/*
#ifdef WLED_DEBUG
DEBUG_PRINTLN(F("Serialized preset"));
serializeJson(doc,Serial);
DEBUG_PRINTLN();
#endif
*/
#if defined(ARDUINO_ARCH_ESP32)
if (!persist) {
if (tmpRAMbuffer!=nullptr) free(tmpRAMbuffer);
@ -165,7 +165,7 @@ void savePreset(byte index, const char* pname, JsonObject sObj)
playlistSave = false;
if (sObj[F("ql")].is<const char*>()) strlcpy(quickLoad, sObj[F("ql")].as<const char*>(), 3); // only 2 chars for QL
sObj.remove("v");
sObj.remove(F("time"));
sObj.remove("time");
sObj.remove(F("error"));
sObj.remove(F("psave"));
if (sObj["o"].isNull()) { // "o" marks a playlist or manually entered API
@ -196,7 +196,7 @@ void savePreset(byte index, const char* pname, JsonObject sObj)
void deletePreset(byte index) {
StaticJsonDocument<24> empty;
writeObjectToFileUsingId("/presets.json", index, &empty);
writeObjectToFileUsingId(getName(), index, &empty);
presetsModifiedTime = toki.second(); //unix time
updateFSInfo();
}