mirror of https://github.com/arendst/Tasmota.git
Add whitespace removal
Add whitespace removal from RfRaw and SerialSend5 (#4020)
This commit is contained in:
parent
b7dd0092b7
commit
c46ae74067
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<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
|
||||
\*********************************************************************************************/
|
||||
|
@ -557,9 +541,7 @@ boolean SonoffBridgeCommand()
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
char rawsend[XdrvMailbox.data_len+1];
|
||||
sprintf(rawsend,"%s",charclean(XdrvMailbox.data));
|
||||
SerialSendRaw(rawsend, strlen(rawsend));
|
||||
SerialSendRaw(RemoveSpace(XdrvMailbox.data), strlen(XdrvMailbox.data));
|
||||
sonoff_bridge_receive_raw_flag = 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue