[LORA] Fix save function for parameters that are not frequency (#1987)
This commit is contained in:
1 parent
b67016bd05
commit
35124f2af8
1 file changed
+20
-2
+20
-2
@@ -347,6 +347,21 @@ void LORAConfig_fromJson(JsonObject& LORAdata) {
|
|||||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||||
JsonObject jo = jsonBuffer.to<JsonObject>();
|
JsonObject jo = jsonBuffer.to<JsonObject>();
|
||||||
jo["frequency"] = LORAConfig.frequency;
|
jo["frequency"] = LORAConfig.frequency;
|
||||||
|
jo["txpower"] = LORAConfig.txPower;
|
||||||
|
jo["spreadingfactor"] = LORAConfig.spreadingFactor;
|
||||||
|
jo["signalbandwidth"] = LORAConfig.signalBandwidth;
|
||||||
|
jo["codingrate"] = LORAConfig.codingRateDenominator;
|
||||||
|
jo["preamblelength"] = LORAConfig.preambleLength;
|
||||||
|
if (LORAConfig.syncWord < 0 || LORAConfig.syncWord > 255) {
|
||||||
|
Log.error(F("Invalid syncWord value: %d" CR), LORAConfig.syncWord);
|
||||||
|
} else {
|
||||||
|
char syncWordHex[5];
|
||||||
|
snprintf(syncWordHex, sizeof(syncWordHex), "0x%02X", LORAConfig.syncWord);
|
||||||
|
jo["syncword"] = syncWordHex;
|
||||||
|
}
|
||||||
|
jo["enablecrc"] = LORAConfig.crc;
|
||||||
|
jo["invertiq"] = LORAConfig.invertIQ;
|
||||||
|
jo["onlyknown"] = LORAConfig.onlyKnown;
|
||||||
// Save config into NVS (non-volatile storage)
|
// Save config into NVS (non-volatile storage)
|
||||||
String conf = "";
|
String conf = "";
|
||||||
serializeJson(jsonBuffer, conf);
|
serializeJson(jsonBuffer, conf);
|
||||||
@@ -541,10 +556,13 @@ String stateLORAMeasures() {
|
|||||||
LORAdata["signalbandwidth"] = LORAConfig.signalBandwidth;
|
LORAdata["signalbandwidth"] = LORAConfig.signalBandwidth;
|
||||||
LORAdata["codingrate"] = LORAConfig.codingRateDenominator;
|
LORAdata["codingrate"] = LORAConfig.codingRateDenominator;
|
||||||
LORAdata["preamblelength"] = LORAConfig.preambleLength;
|
LORAdata["preamblelength"] = LORAConfig.preambleLength;
|
||||||
// Convert syncWord to a hexadecimal string and store it in the JSON
|
if (LORAConfig.syncWord < 0 || LORAConfig.syncWord > 255) {
|
||||||
char syncWordHex[5]; // Enough space for 0xXX and null terminator
|
Log.error(F("Invalid syncWord value: %d" CR), LORAConfig.syncWord);
|
||||||
|
} else {
|
||||||
|
char syncWordHex[5];
|
||||||
snprintf(syncWordHex, sizeof(syncWordHex), "0x%02X", LORAConfig.syncWord);
|
snprintf(syncWordHex, sizeof(syncWordHex), "0x%02X", LORAConfig.syncWord);
|
||||||
LORAdata["syncword"] = syncWordHex;
|
LORAdata["syncword"] = syncWordHex;
|
||||||
|
}
|
||||||
LORAdata["enablecrc"] = LORAConfig.crc;
|
LORAdata["enablecrc"] = LORAConfig.crc;
|
||||||
LORAdata["invertiq"] = LORAConfig.invertIQ;
|
LORAdata["invertiq"] = LORAConfig.invertIQ;
|
||||||
LORAdata["onlyknown"] = LORAConfig.onlyKnown;
|
LORAdata["onlyknown"] = LORAConfig.onlyKnown;
|
||||||
|
|||||||
Reference in new issue
Block a user