|
|
@@ -421,7 +421,8 @@ void parseEncryptedPayload (const EncryptedPayloadStruct *enc) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define STR_EQ_LIT(s, lit) (memcmp ((s), (lit), sizeof (lit) - 1) == 0)
|
|
|
|
//#define STR_EQ_LIT(s, lit) (memcmp ((s), (lit), sizeof (lit) - 1) == 0)
|
|
|
|
|
|
|
|
#define STR_EQ_LIT(s, lit) (strcmp(s, lit) == 0)
|
|
|
|
|
|
|
|
|
|
|
|
void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
PlainTextMessagePayload replyPayload;
|
|
|
|
PlainTextMessagePayload replyPayload;
|
|
|
@@ -492,22 +493,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------- Neighbors ---------------- */
|
|
|
|
/*
|
|
|
|
else if (STR_EQ_LIT (cmd, "neighbors")) {
|
|
|
|
|
|
|
|
Callbacks_FormatNeighborsReply ((char *)reply);
|
|
|
|
|
|
|
|
} else if (STR_EQ_LIT (cmd, "neighbor.remove ")) {
|
|
|
|
|
|
|
|
const char *hex = cmd + 16;
|
|
|
|
|
|
|
|
uint8_t pubkey[PUB_KEY_SIZE];
|
|
|
|
|
|
|
|
int len = strlen (hex) / 2;
|
|
|
|
|
|
|
|
if (mesh_fromHex (pubkey, len, hex)) {
|
|
|
|
|
|
|
|
Callbacks_RemoveNeighbor (pubkey, len);
|
|
|
|
|
|
|
|
strcpy ((char *)reply, "OK");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
strcpy ((char *)reply, "ERR: bad pubkey");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------- Radio / Temp ---------------- */
|
|
|
|
|
|
|
|
else if (STR_EQ_LIT (cmd, "tempradio ")) {
|
|
|
|
else if (STR_EQ_LIT (cmd, "tempradio ")) {
|
|
|
|
char tmp[64];
|
|
|
|
char tmp[64];
|
|
|
|
strcpy (tmp, &cmd[10]);
|
|
|
|
strcpy (tmp, &cmd[10]);
|
|
|
@@ -529,6 +515,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
strcpy ((char *)reply, "Error, invalid params");
|
|
|
|
strcpy ((char *)reply, "Error, invalid params");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------- Password ---------------- */
|
|
|
|
/* ---------------- Password ---------------- */
|
|
|
|
else if (STR_EQ_LIT (cmd, "password ")) {
|
|
|
|
else if (STR_EQ_LIT (cmd, "password ")) {
|
|
|
@@ -543,6 +530,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
|
|
|
|
|
|
|
|
if (memcmp (config, "af", 2) == 0) {
|
|
|
|
if (memcmp (config, "af", 2) == 0) {
|
|
|
|
sprintf (reply, "> %f", persistent.airtimeFactor);
|
|
|
|
sprintf (reply, "> %f", persistent.airtimeFactor);
|
|
|
|
|
|
|
|
/*
|
|
|
|
} else if (memcmp (config, "int.thresh", 10) == 0) {
|
|
|
|
} else if (memcmp (config, "int.thresh", 10) == 0) {
|
|
|
|
sprintf (reply, "> %d", (uint32_t)_prefs->interference_threshold);
|
|
|
|
sprintf (reply, "> %d", (uint32_t)_prefs->interference_threshold);
|
|
|
|
} else if (memcmp (config, "agc.reset.interval", 18) == 0) {
|
|
|
|
} else if (memcmp (config, "agc.reset.interval", 18) == 0) {
|
|
|
@@ -554,7 +542,8 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
} else if (memcmp (config, "flood.advert.interval", 21) == 0) {
|
|
|
|
} else if (memcmp (config, "flood.advert.interval", 21) == 0) {
|
|
|
|
sprintf (reply, "> %d", (uint32_t)_prefs->flood_advert_interval);
|
|
|
|
sprintf (reply, "> %d", (uint32_t)_prefs->flood_advert_interval);
|
|
|
|
} else if (memcmp (config, "advert.interval", 15) == 0) {
|
|
|
|
} else if (memcmp (config, "advert.interval", 15) == 0) {
|
|
|
|
sprintf (reply, "> %d", ((uint32_t)_prefs->advert_interval) * 2);
|
|
|
|
sprintf (reply, "> %d", ((uint32_t)_prefs->advert_interval) * 2);1
|
|
|
|
|
|
|
|
*/
|
|
|
|
} else if (memcmp (config, "guest.password", 14) == 0) {
|
|
|
|
} else if (memcmp (config, "guest.password", 14) == 0) {
|
|
|
|
sprintf (reply, "> %s", persistent.guestPassword);
|
|
|
|
sprintf (reply, "> %s", persistent.guestPassword);
|
|
|
|
} else if (memcmp (config, "name", 4) == 0) {
|
|
|
|
} else if (memcmp (config, "name", 4) == 0) {
|
|
|
@@ -565,6 +554,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
sprintf (reply, "> %d", persistent.latitude);
|
|
|
|
sprintf (reply, "> %d", persistent.latitude);
|
|
|
|
} else if (memcmp (config, "lon", 3) == 0) {
|
|
|
|
} else if (memcmp (config, "lon", 3) == 0) {
|
|
|
|
sprintf (reply, "> %d", persistent.longitude);
|
|
|
|
sprintf (reply, "> %d", persistent.longitude);
|
|
|
|
|
|
|
|
/*
|
|
|
|
} else if (memcmp (config, "radio", 5) == 0) {
|
|
|
|
} else if (memcmp (config, "radio", 5) == 0) {
|
|
|
|
char freq[16], bw[16];
|
|
|
|
char freq[16], bw[16];
|
|
|
|
snprintf(freq, sizeof(freq), "%lf", persistent.frequencyInHz / 1000000.0);
|
|
|
|
snprintf(freq, sizeof(freq), "%lf", persistent.frequencyInHz / 1000000.0);
|
|
|
@@ -582,6 +572,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
sprintf (reply, "> %d", (uint32_t)_prefs->tx_power_dbm);
|
|
|
|
sprintf (reply, "> %d", (uint32_t)_prefs->tx_power_dbm);
|
|
|
|
} else if (memcmp (config, "freq", 4) == 0) {
|
|
|
|
} else if (memcmp (config, "freq", 4) == 0) {
|
|
|
|
sprintf (reply, "> %s", StrHelper::ftoa (_prefs->freq));
|
|
|
|
sprintf (reply, "> %s", StrHelper::ftoa (_prefs->freq));
|
|
|
|
|
|
|
|
*/
|
|
|
|
} else if (memcmp (config, "public.key", 10) == 0) {
|
|
|
|
} else if (memcmp (config, "public.key", 10) == 0) {
|
|
|
|
strcpy (reply, "> ");
|
|
|
|
strcpy (reply, "> ");
|
|
|
|
hexdump_compact(persistent.pubkey, sizeof(persistent.pubkey), &(reply[2]), 70);
|
|
|
|
hexdump_compact(persistent.pubkey, sizeof(persistent.pubkey), &(reply[2]), 70);
|
|
|
@@ -600,6 +591,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
persistent.airtimeFactor = atof (&config[3]);
|
|
|
|
persistent.airtimeFactor = atof (&config[3]);
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
|
|
|
|
/*
|
|
|
|
} else if (memcmp (config, "int.thresh ", 11) == 0) {
|
|
|
|
} else if (memcmp (config, "int.thresh ", 11) == 0) {
|
|
|
|
_prefs->interference_threshold = atoi (&config[11]);
|
|
|
|
_prefs->interference_threshold = atoi (&config[11]);
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
@@ -612,6 +604,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
_prefs->multi_acks = atoi (&config[11]);
|
|
|
|
_prefs->multi_acks = atoi (&config[11]);
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
|
|
|
|
*/
|
|
|
|
} else if (memcmp (config, "allow.read.only ", 16) == 0) {
|
|
|
|
} else if (memcmp (config, "allow.read.only ", 16) == 0) {
|
|
|
|
if (memcmp (&config[16], "on", 2) == 0) {
|
|
|
|
if (memcmp (&config[16], "on", 2) == 0) {
|
|
|
|
persistent.allowReadOnly = 1;
|
|
|
|
persistent.allowReadOnly = 1;
|
|
|
@@ -621,7 +614,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//savePrefs();
|
|
|
|
//savePrefs();
|
|
|
|
|
|
|
|
/*
|
|
|
|
} else if (memcmp (config, "flood.advert.interval ", 22) == 0) {
|
|
|
|
} else if (memcmp (config, "flood.advert.interval ", 22) == 0) {
|
|
|
|
int hours = _atoi (&config[22]);
|
|
|
|
int hours = _atoi (&config[22]);
|
|
|
|
if ((hours > 0 && hours < 3) || (hours > 48)) {
|
|
|
|
if ((hours > 0 && hours < 3) || (hours > 48)) {
|
|
|
@@ -642,6 +635,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
savePrefs();
|
|
|
|
savePrefs();
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
} else if (memcmp (config, "guest.password ", 15) == 0) {
|
|
|
|
} else if (memcmp (config, "guest.password ", 15) == 0) {
|
|
|
|
strncpy (persistent.guestPassword, &config[15], sizeof (persistent.guestPassword));
|
|
|
|
strncpy (persistent.guestPassword, &config[15], sizeof (persistent.guestPassword));
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
@@ -658,12 +652,13 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
|
strcpy (reply, persistent.doRepeat ? "OK - repeat is now ON" : "OK - repeat is now OFF");
|
|
|
|
strcpy (reply, persistent.doRepeat ? "OK - repeat is now ON" : "OK - repeat is now OFF");
|
|
|
|
|
|
|
|
/*
|
|
|
|
} else if (memcmp (config, "radio ", 6) == 0) {
|
|
|
|
} else if (memcmp (config, "radio ", 6) == 0) {
|
|
|
|
strcpy (tmp, &config[6]);
|
|
|
|
strcpy (tmp, &config[6]);
|
|
|
|
const char *parts[4];
|
|
|
|
const char *parts[4];
|
|
|
|
int num = mesh::Utils::parseTextParts (tmp, parts, 4);
|
|
|
|
int num = mesh::Utils::parseTextParts (tmp, parts, 4);
|
|
|
|
float freq = num > 0 ? strtof (parts[0], nullptr) : 0.0f;
|
|
|
|
float freq = num > 0 ? strtof (parts[0], 0) : 0.0f;
|
|
|
|
float bw = num > 1 ? strtof (parts[1], nullptr) : 0.0f;
|
|
|
|
float bw = num > 1 ? strtof (parts[1], 0) : 0.0f;
|
|
|
|
uint8_t sf = num > 2 ? atoi (parts[2]) : 0;
|
|
|
|
uint8_t sf = num > 2 ? atoi (parts[2]) : 0;
|
|
|
|
uint8_t cr = num > 3 ? atoi (parts[3]) : 0;
|
|
|
|
uint8_t cr = num > 3 ? atoi (parts[3]) : 0;
|
|
|
|
if (freq >= 300.0f && freq <= 2500.0f && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f) {
|
|
|
|
if (freq >= 300.0f && freq <= 2500.0f && sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8 && bw >= 7.0f && bw <= 500.0f) {
|
|
|
@@ -676,6 +671,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
strcpy (reply, "Error, invalid radio params");
|
|
|
|
strcpy (reply, "Error, invalid radio params");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
} else if (memcmp (config, "lat ", 4) == 0) {
|
|
|
|
} else if (memcmp (config, "lat ", 4) == 0) {
|
|
|
|
double lat = atof (&config[4]);
|
|
|
|
double lat = atof (&config[4]);
|
|
|
|
lat *= 1000000;
|
|
|
|
lat *= 1000000;
|
|
|
@@ -688,6 +684,7 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
persistent.longitude = lon;
|
|
|
|
persistent.longitude = lon;
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
|
|
|
|
/*
|
|
|
|
} else if (memcmp (config, "rxdelay ", 8) == 0) {
|
|
|
|
} else if (memcmp (config, "rxdelay ", 8) == 0) {
|
|
|
|
float db = atof (&config[8]);
|
|
|
|
float db = atof (&config[8]);
|
|
|
|
if (db >= 0) {
|
|
|
|
if (db >= 0) {
|
|
|
@@ -729,14 +726,16 @@ void processCommand (char *cmd, NodeEntry *remNode) {
|
|
|
|
savePrefs();
|
|
|
|
savePrefs();
|
|
|
|
_callbacks->setTxPower (_prefs->tx_power_dbm);
|
|
|
|
_callbacks->setTxPower (_prefs->tx_power_dbm);
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
strcpy (reply, "OK");
|
|
|
|
|
|
|
|
*/
|
|
|
|
} else if (memcmp (config, "freq ", 5) == 0) {
|
|
|
|
} else if (memcmp (config, "freq ", 5) == 0) {
|
|
|
|
double freq = atof (&config[5]);
|
|
|
|
double freq = atof (&config[5]);
|
|
|
|
uint32_t newFreq = mhzToHzLimited (persistent.frequencyInHz);
|
|
|
|
uint32_t newFreq = mhzToHzLimited (persistent.loraSettings.frequencyInHz);
|
|
|
|
if (newFreq != 0) {
|
|
|
|
if (newFreq != 0) {
|
|
|
|
persistent.frequencyInHz = newFreq;
|
|
|
|
persistent.loraSettings.frequencyInHz = newFreq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// savePrefs();
|
|
|
|
// savePrefs();
|
|
|
|
strcpy (reply, "OK - reboot to apply");
|
|
|
|
strcpy (reply, "OK - reboot to apply");
|
|
|
|
|
|
|
|
|
|
|
|
} else if (memcmp (config, "adc.multiplier ", 15) == 0) {
|
|
|
|
} else if (memcmp (config, "adc.multiplier ", 15) == 0) {
|
|
|
|
persistent.adcMultiplier = atof (&config[15]);
|
|
|
|
persistent.adcMultiplier = atof (&config[15]);
|
|
|
|
if (persistent.adcMultiplier == 0.0f) {
|
|
|
|
if (persistent.adcMultiplier == 0.0f) {
|
|
|
|