Skip to content

Commit

Permalink
Fix escape of non-JSON received serial data
Browse files Browse the repository at this point in the history
Fix escape of non-JSON received serial data (arendst#8329)
  • Loading branch information
arendst committed May 26, 2020
1 parent ed543d9 commit bacb730
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tasmota/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tasmota/support_tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -1360,7 +1360,7 @@ void SerialInput(void)
}
ResponseAppend_P(PSTR("\""));
}
ResponseAppend_P(PSTR("}"));
ResponseJsonEnd();

MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SERIALRECEIVED));
XdrvRulesProcess();
Expand Down
4 changes: 2 additions & 2 deletions tasmota/xdrv_08_serial_bridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,7 +91,7 @@ void SerialBridgeInput(void)
}
ResponseAppend_P(PSTR("\""));
}
ResponseAppend_P(PSTR("}"));
ResponseJsonEnd();

MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED));
XdrvRulesProcess();
Expand Down

0 comments on commit bacb730

Please sign in to comment.