Add whitespace removal

Add whitespace removal from RfRaw and SerialSend5 (#4020)
This commit is contained in:
Theo Arends 2018-10-14 12:53:11 +02:00
parent b7dd0092b7
commit c46ae74067
4 changed files with 20 additions and 21 deletions

View File

@ -1,6 +1,7 @@
/* 6.2.1.15 20181012 /* 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 auto reload of main web page to some web restarts
* Add whitespace removal from RfRaw and SerialSend5 (#4020)
* *
* 6.2.1.14 20181010 * 6.2.1.14 20181010
* Rewrite Webserver page handler for easier extension (thx to Adrian Scillato) * Rewrite Webserver page handler for easier extension (thx to Adrian Scillato)

View File

@ -1002,7 +1002,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
Serial.printf("%s", Unescape(dataBuf, &dat_len)); // "Hello\f" Serial.printf("%s", Unescape(dataBuf, &dat_len)); // "Hello\f"
} }
else if (5 == index) { 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); snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
} }

View File

@ -243,6 +243,22 @@ char* Unescape(char* buffer, uint16_t* size)
return buffer; 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* UpperCase(char* dest, const char* source)
{ {
char* write = dest; char* write = dest;

View File

@ -411,22 +411,6 @@ void SonoffBridgeLearn(uint8_t key)
Serial.write(0x55); // End of Text 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<strlen(in);i++,x++) {
if (in[i] != ' ') {
out[x] = in[i];
} else {
x--;
}
}
out[x] = 0; // null terminate the new char array
return out;
}
/*********************************************************************************************\ /*********************************************************************************************\
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
@ -557,9 +541,7 @@ boolean SonoffBridgeCommand()
break; break;
} }
} else { } else {
char rawsend[XdrvMailbox.data_len+1]; SerialSendRaw(RemoveSpace(XdrvMailbox.data), strlen(XdrvMailbox.data));
sprintf(rawsend,"%s",charclean(XdrvMailbox.data));
SerialSendRaw(rawsend, strlen(rawsend));
sonoff_bridge_receive_raw_flag = 1; sonoff_bridge_receive_raw_flag = 1;
} }
} }