Default lora config

This commit is contained in:
Sassa NF
2024-12-31 11:00:48 +00:00
parent 55273f80eb
commit 6368eca7aa
4 changed files with 54 additions and 36 deletions
+23 -30
View File
@@ -107,23 +107,26 @@ Config Config::init()
return c;
}
#define UPDATE_BOOL(val, key, value) \
if (key.equalsIgnoreCase(#val)) \
{ \
String v = value; \
bool p = v.equalsIgnoreCase("true"); \
if (!p && !v.equalsIgnoreCase("false")) \
{ \
Serial.printf("Expected bool for '%s', found '%s' - ignoring\n", \
key.c_str(), value.c_str()); \
} \
else \
{ \
val = p; \
} \
return true; \
}
bool Config::updateConfig(String key, String value)
{
if (key.equalsIgnoreCase("print_profile_time"))
{
String v = value;
bool p = v.equalsIgnoreCase("true");
if (!p && !v.equalsIgnoreCase("false"))
{
Serial.printf("Expected bool for '%s', found '%s' - ignoring\n", key.c_str(),
value.c_str());
}
else
{
print_profile_time = p;
}
return true;
}
UPDATE_BOOL(print_profile_time, key, value);
if (key.equalsIgnoreCase("log_data_json_interval"))
{
@@ -167,21 +170,9 @@ bool Config::updateConfig(String key, String value)
return true;
}
if (key.equalsIgnoreCase("is_host"))
{
String v = value;
bool p = v.equalsIgnoreCase("true");
if (!p && !v.equalsIgnoreCase("false"))
{
Serial.printf("Expected bool for '%s', found '%s' - ignoring\n", key.c_str(),
value.c_str());
}
else
{
is_host = p;
}
return true;
}
UPDATE_BOOL(is_host, key, value);
UPDATE_BOOL(lora_enabled, key, value);
return false;
}
@@ -512,6 +503,8 @@ bool Config::write_config(const char *path)
f.println("tx_lora = " + getConfig("tx_lora"));
f.println("is_host = " + getConfig("is_host"));
f.println("lora_enabled = " + getConfig("lora_enabled"));
f.close();
return true;
}