Refactor serial raw data representation

This commit is contained in:
Theo Arends 2022-11-10 16:02:00 +01:00
parent e83882b655
commit 986a9d10ae
2 changed files with 3 additions and 5 deletions

View File

@ -1854,8 +1854,7 @@ void SerialInput(void)
} else {
ResponseAppend_P(PSTR("\""));
if (Settings->flag.mqtt_serial_raw) {
char hex_char[(TasmotaGlobal.serial_in_byte_counter * 2) + 2];
ResponseAppend_P(ToHex_P((unsigned char*)TasmotaGlobal.serial_in_buffer, TasmotaGlobal.serial_in_byte_counter, hex_char, sizeof(hex_char)));
ResponseAppend_P(PSTR("%*_H"), TasmotaGlobal.serial_in_byte_counter, TasmotaGlobal.serial_in_buffer);
} else {
ResponseAppend_P(EscapeJSONString(TasmotaGlobal.serial_in_buffer).c_str());
}

View File

@ -158,8 +158,7 @@ void SerialBridgeInput(void) {
} else {
ResponseAppend_P(PSTR("\""));
if (serial_bridge_raw) {
char hex_char[(serial_bridge_in_byte_counter * 2) + 2];
ResponseAppend_P(ToHex_P((unsigned char*)serial_bridge_buffer, serial_bridge_in_byte_counter, hex_char, sizeof(hex_char)));
ResponseAppend_P(PSTR("%*_H"), serial_bridge_in_byte_counter, serial_bridge_buffer);
} else {
ResponseAppend_P(EscapeJSONString(serial_bridge_buffer).c_str());
}
@ -171,7 +170,7 @@ void SerialBridgeInput(void) {
XdrvRulesProcess(0);
} else {
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED));
}
}
serial_bridge_in_byte_counter = 0;
}
}