mirror of https://github.com/arendst/Tasmota.git
nicer solution skipping loracommand header
This commit is contained in:
parent
08afd40823
commit
140e4791aa
|
@ -200,6 +200,7 @@ void LoraInput(void) {
|
|||
#endif // USE_LORAWAN_BRIDGE
|
||||
Lora->receive_time = 0;
|
||||
|
||||
char *rcvd_data = data;
|
||||
if (TAS_LORA_REMOTE_COMMAND == data[0]) {
|
||||
char *payload = data +1; // Skip TAS_LORA_REMOTE_COMMAND
|
||||
char *command_part;
|
||||
|
@ -212,7 +213,8 @@ void LoraInput(void) {
|
|||
}
|
||||
} else {
|
||||
*--command_part = ' '; // Restore strtok_r '/0'
|
||||
data[0] = ' '; // Remove TAS_LORA_REMOTE_COMMAND header
|
||||
rcvd_data++; // Remove TAS_LORA_REMOTE_COMMAND header
|
||||
packet_size--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,21 +222,21 @@ void LoraInput(void) {
|
|||
bool raw = Lora->raw;
|
||||
// Set raw mode if zeroes within data
|
||||
for (uint32_t i = 0; i < packet_size; i++) {
|
||||
if (0 == data[i]) {
|
||||
if (0 == rcvd_data[i]) {
|
||||
raw = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool assume_json = (!raw && (data[0] == '{'));
|
||||
bool assume_json = (!raw && (rcvd_data[0] == '{'));
|
||||
Response_P(PSTR("{\"LoRaReceived\":"));
|
||||
if (assume_json) {
|
||||
ResponseAppend_P(data);
|
||||
ResponseAppend_P(rcvd_data);
|
||||
} else {
|
||||
ResponseAppend_P(PSTR("\""));
|
||||
if (raw) {
|
||||
ResponseAppend_P(PSTR("%*_H"), packet_size, data);
|
||||
ResponseAppend_P(PSTR("%*_H"), packet_size, rcvd_data);
|
||||
} else {
|
||||
ResponseAppend_P(EscapeJSONString(data).c_str());
|
||||
ResponseAppend_P(EscapeJSONString(rcvd_data).c_str());
|
||||
}
|
||||
ResponseAppend_P(PSTR("\""));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue