From c46ae740673f7c6cfd8e6c0c58c4d2be37943041 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 14 Oct 2018 12:53:11 +0200 Subject: [PATCH] Add whitespace removal Add whitespace removal from RfRaw and SerialSend5 (#4020) --- sonoff/_changelog.ino | 3 ++- sonoff/sonoff.ino | 2 +- sonoff/support.ino | 16 ++++++++++++++++ sonoff/xdrv_06_snfbridge.ino | 20 +------------------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 0cd2d3093..9a81d11bd 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,6 +1,7 @@ /* 6.2.1.15 20181012 - * Fix Color Temperature slider functionality regression from 20180726 (#4037) + * Fix Color Temperature slider functionality regression from 6.2.1.5 (#4037) * Add auto reload of main web page to some web restarts + * Add whitespace removal from RfRaw and SerialSend5 (#4020) * * 6.2.1.14 20181010 * Rewrite Webserver page handler for easier extension (thx to Adrian Scillato) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index d9453e3c4..ca42c2bbf 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1002,7 +1002,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) Serial.printf("%s", Unescape(dataBuf, &dat_len)); // "Hello\f" } else if (5 == index) { - SerialSendRaw(dataBuf, data_len); // "AA004566" + SerialSendRaw(RemoveSpace(dataBuf), strlen(dataBuf)); // "AA004566" } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE); } diff --git a/sonoff/support.ino b/sonoff/support.ino index faf651e96..a81699a8c 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -243,6 +243,22 @@ char* Unescape(char* buffer, uint16_t* size) return buffer; } +char* RemoveSpace(char* p) +{ + char* write = p; + char* read = p; + char ch = '.'; + + while (ch != '\0') { + ch = *read++; + if (!isspace(ch)) { + *write++ = ch; + } + } + *write = '\0'; + return p; +} + char* UpperCase(char* dest, const char* source) { char* write = dest; diff --git a/sonoff/xdrv_06_snfbridge.ino b/sonoff/xdrv_06_snfbridge.ino index caf67186b..0533e2d4a 100644 --- a/sonoff/xdrv_06_snfbridge.ino +++ b/sonoff/xdrv_06_snfbridge.ino @@ -411,22 +411,6 @@ void SonoffBridgeLearn(uint8_t key) Serial.write(0x55); // End of Text } -char* charclean(char *in) -{ - uint8_t i; - uint8_t x; - char *out = in; - for (i=0,x=0;i