Fix escape of non-JSON received serial data

Fix escape of non-JSON received serial data (#8329)
This commit is contained in:
Theo Arends 2020-05-26 12:35:21 +02:00
parent ed543d93c3
commit bacb730b53
4 changed files with 7 additions and 5 deletions

View File

@ -58,6 +58,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Change Adafruit_SGP30 library from v1.0.3 to v1.2.0 (#8519)
- Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]``
- Change Energy JSON ExportActive field from ``"ExportActive":[33.736,11.717,16.978]`` to ``"ExportActive":33.736,"ExportTariff":[11.717,16.978]``
- Fix escape of non-JSON received serial data (#8329)
- Add command ``Rule0`` to change global rule parameters
- Add command ``Time 4`` to display timestamp using milliseconds (#8537)
- Add commands ``LedPwmOn 0..255``, ``LedPwmOff 0..255`` and ``LedPwmMode1 0/1`` to control led brightness by George (#8491)

View File

@ -5,6 +5,7 @@
- Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]``
- Change Energy JSON ExportActive field from ``"ExportActive":[33.736,11.717,16.978]`` to ``"ExportActive":33.736,"ExportTariff":[11.717,16.978]``
- Change Adafruit_SGP30 library from v1.0.3 to v1.2.0 (#8519)
- Fix escape of non-JSON received serial data (#8329)
- Add command ``Time 4`` to display timestamp using milliseconds (#8537)
- Add commands ``LedPwmOn 0..255``, ``LedPwmOff 0..255`` and ``LedPwmMode1 0/1`` to control led brightness by George (#8491)
- Add Three Phase Export Active Energy to SDM630 driver

View File

@ -1300,7 +1300,7 @@ void SerialInput(void)
!in_byte_is_delimiter) { // Char is not a delimiter
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
}
if ((serial_in_byte_counter >= INPUT_BUFFER_SIZE -1) || // Send message when buffer is full or ...
in_byte_is_delimiter) { // Char is delimiter
serial_polling_window = 0; // Reception done - send mqtt
@ -1346,7 +1346,7 @@ void SerialInput(void)
if (Settings.flag.mqtt_serial && serial_in_byte_counter && (millis() > (serial_polling_window + SERIAL_POLLING))) { // CMND_SERIALSEND and CMND_SERIALLOG
serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed
bool assume_json = (!Settings.flag.mqtt_serial_raw && (serial_in_buffer[0] == '{'));
Response_P(PSTR("{\"" D_JSON_SERIALRECEIVED "\":"));
if (assume_json) {
ResponseAppend_P(serial_in_buffer);
@ -1360,7 +1360,7 @@ void SerialInput(void)
}
ResponseAppend_P(PSTR("\""));
}
ResponseAppend_P(PSTR("}"));
ResponseJsonEnd();
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED));
XdrvRulesProcess();

View File

@ -63,7 +63,7 @@ void SerialBridgeInput(void)
!in_byte_is_delimiter) { // Char is not a delimiter
serial_bridge_buffer[serial_bridge_in_byte_counter++] = serial_in_byte;
}
if ((serial_bridge_in_byte_counter >= SERIAL_BRIDGE_BUFFER_SIZE -1) || // Send message when buffer is full or ...
in_byte_is_delimiter) { // Char is delimiter
serial_bridge_polling_window = 0; // Publish now
@ -91,7 +91,7 @@ void SerialBridgeInput(void)
}
ResponseAppend_P(PSTR("\""));
}
ResponseAppend_P(PSTR("}"));
ResponseJsonEnd();
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED));
XdrvRulesProcess();