configPrint FIX

This commit is contained in:
Patrick Haßel 2024-04-12 10:32:48 +02:00
parent 8b80a0e8e1
commit 05d2b22c9f
2 changed files with 24 additions and 4 deletions

View File

@ -68,11 +68,27 @@ void configPutDouble(const char *name, double value) {
void configPrint() {
info("Config:");
for (JsonPair pair: config.as<JsonObject>()) {
const char *value = pair.value().as<const char *>();
if (strcmp(pair.key().c_str(), "WIFI_PKEY") == 0) {
value = "[***]";
const char *key = pair.key().c_str();
const JsonVariant &value = pair.value();
char valueStr[64];
if (strcmp(key, "WIFI_PKEY") == 0) {
snprintf(valueStr, sizeof valueStr, "[PASSWORD REDACTED]");
} else {
if (value.is<const char *>()) {
snprintf(valueStr, sizeof valueStr, "%s", value.as<const char *>());
} else if (value.is<double>()) {
snprintf(valueStr, sizeof valueStr, "%f", value.as<double>());
} else if (value.is<int>()) {
snprintf(valueStr, sizeof valueStr, "%d", value.as<int>());
} else if (value.is<bool>()) {
snprintf(valueStr, sizeof valueStr, "%s", value.as<bool>() ? "true" : "false");
} else {
snprintf(valueStr, sizeof valueStr, "[UNKNOWN TYPE]");
}
}
info(" - %s: \"%s\"", pair.key().c_str(), value);
info(" -%-15s = %s", key, valueStr);
}
}

View File

@ -16,6 +16,10 @@ void configLoaded() {
}
bool patrix_command(char *first) {
if (strcmp(first, "test") == 0 || strcmp(first, "t") == 0) {
configPutDouble("test", millis());
return true;
}
return false;
}