Implement global JSON API boolean toggle.

This commit is contained in:
Blaz Kristan
2023-11-06 20:08:45 +01:00
parent e1075a3bbf
commit 2b616b688d
3 changed files with 23 additions and 17 deletions

View File

@@ -69,6 +69,15 @@ bool getVal(JsonVariant elem, byte* val, byte vmin, byte vmax) {
}
bool getBoolVal(JsonVariant elem, bool dflt) {
if (elem.is<const char*>() && elem.as<const char*>()[0] == 't') {
return !dflt;
} else {
return elem | dflt;
}
}
bool updateVal(const char* req, const char* key, byte* val, byte minv, byte maxv)
{
const char *v = strstr(req, key);