mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Consolidate function RemoveSpace
This commit is contained in:
parent
89c690c05d
commit
5ec972376c
@ -359,8 +359,8 @@ char* Unescape(char* buffer, uint32_t* size)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* RemoveSpace(char* p)
|
char* RemoveSpace(char* p) {
|
||||||
{
|
// Remove white-space character (' ','\t','\n','\v','\f','\r')
|
||||||
char* write = p;
|
char* write = p;
|
||||||
char* read = p;
|
char* read = p;
|
||||||
char ch = '.';
|
char ch = '.';
|
||||||
@ -371,12 +371,11 @@ char* RemoveSpace(char* p)
|
|||||||
*write++ = ch;
|
*write++ = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// *write = '\0'; // Removed 20190223 as it buffer overflows on no isspace found - no need either
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* RemoveControlCharacter(char* p)
|
char* RemoveControlCharacter(char* p) {
|
||||||
{
|
// Remove control character (0x00 .. 0x1F and 0x7F)
|
||||||
char* write = p;
|
char* write = p;
|
||||||
char* read = p;
|
char* read = p;
|
||||||
char ch = '.';
|
char ch = '.';
|
||||||
@ -391,8 +390,8 @@ char* RemoveControlCharacter(char* p)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ReplaceCommaWithDot(char* p)
|
char* ReplaceCommaWithDot(char* p) {
|
||||||
{
|
// Replace character ',' with '.'
|
||||||
char* write = (char*)p;
|
char* write = (char*)p;
|
||||||
char* read = (char*)p;
|
char* read = (char*)p;
|
||||||
char ch = '.';
|
char ch = '.';
|
||||||
@ -458,6 +457,7 @@ char* Trim(char* p)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
char* RemoveAllSpaces(char* p)
|
char* RemoveAllSpaces(char* p)
|
||||||
{
|
{
|
||||||
// remove any white space from the base64
|
// remove any white space from the base64
|
||||||
@ -474,6 +474,7 @@ char* RemoveAllSpaces(char* p)
|
|||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
char* NoAlNumToUnderscore(char* dest, const char* source)
|
char* NoAlNumToUnderscore(char* dest, const char* source)
|
||||||
{
|
{
|
||||||
|
@ -1174,7 +1174,7 @@ void CmndTlsKey(void) {
|
|||||||
memcpy_P(spi_buffer, tls_spi_start, tls_spi_len);
|
memcpy_P(spi_buffer, tls_spi_start, tls_spi_len);
|
||||||
|
|
||||||
// remove any white space from the base64
|
// remove any white space from the base64
|
||||||
RemoveAllSpaces(XdrvMailbox.data);
|
RemoveSpace(XdrvMailbox.data);
|
||||||
|
|
||||||
// allocate buffer for decoded base64
|
// allocate buffer for decoded base64
|
||||||
uint32_t bin_len = decode_base64_length((unsigned char*)XdrvMailbox.data);
|
uint32_t bin_len = decode_base64_length((unsigned char*)XdrvMailbox.data);
|
||||||
|
@ -413,7 +413,7 @@ void ZbSendSend(class JsonParserToken val_cmd, uint16_t device, uint16_t groupad
|
|||||||
x = value.getUInt(); // automatic conversion to 0/1
|
x = value.getUInt(); // automatic conversion to 0/1
|
||||||
// if (value.is<bool>()) {
|
// if (value.is<bool>()) {
|
||||||
// // x = value.as<bool>() ? 1 : 0;
|
// // x = value.as<bool>() ? 1 : 0;
|
||||||
// } else if
|
// } else if
|
||||||
// } else if (value.is<unsigned int>()) {
|
// } else if (value.is<unsigned int>()) {
|
||||||
// x = value.as<unsigned int>();
|
// x = value.as<unsigned int>();
|
||||||
} else {
|
} else {
|
||||||
@ -1263,13 +1263,13 @@ bool parseDeviceInnerData(class Z_Device & device, JsonParserObject root) {
|
|||||||
|
|
||||||
// Import generic attributes first
|
// Import generic attributes first
|
||||||
Z_Data & data = device.data.getByType(data_type, endpoint);
|
Z_Data & data = device.data.getByType(data_type, endpoint);
|
||||||
|
|
||||||
// scan through attributes
|
// scan through attributes
|
||||||
for (auto attr : data_values) {
|
for (auto attr : data_values) {
|
||||||
JsonParserToken attr_value = attr.getValue();
|
JsonParserToken attr_value = attr.getValue();
|
||||||
uint8_t conv_zigbee_type;
|
uint8_t conv_zigbee_type;
|
||||||
Z_Data_Type conv_data_type;
|
Z_Data_Type conv_data_type;
|
||||||
uint8_t conv_map_offset;
|
uint8_t conv_map_offset;
|
||||||
if (zigbeeFindAttributeByName(attr.getStr(), nullptr, nullptr, nullptr, &conv_zigbee_type, &conv_data_type, &conv_map_offset) != nullptr) {
|
if (zigbeeFindAttributeByName(attr.getStr(), nullptr, nullptr, nullptr, &conv_zigbee_type, &conv_data_type, &conv_map_offset) != nullptr) {
|
||||||
// found an attribute matching the name, does is fit the type?
|
// found an attribute matching the name, does is fit the type?
|
||||||
if (conv_data_type == data_type) {
|
if (conv_data_type == data_type) {
|
||||||
@ -1340,7 +1340,7 @@ bool parseDeviceInnerData(class Z_Device & device, JsonParserObject root) {
|
|||||||
//
|
//
|
||||||
void CmndZbData(void) {
|
void CmndZbData(void) {
|
||||||
if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
|
if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
|
||||||
RemoveAllSpaces(XdrvMailbox.data);
|
RemoveSpace(XdrvMailbox.data);
|
||||||
if (XdrvMailbox.data[0] == '{') {
|
if (XdrvMailbox.data[0] == '{') {
|
||||||
// JSON input, enter saved data into memory -- essentially for debugging
|
// JSON input, enter saved data into memory -- essentially for debugging
|
||||||
JsonParser parser(XdrvMailbox.data);
|
JsonParser parser(XdrvMailbox.data);
|
||||||
@ -1448,7 +1448,7 @@ void CmndZbConfig(void) {
|
|||||||
int8_t zb_txradio_dbm = Settings.zb_txradio_dbm;
|
int8_t zb_txradio_dbm = Settings.zb_txradio_dbm;
|
||||||
|
|
||||||
// if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
|
// if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
|
||||||
RemoveAllSpaces(XdrvMailbox.data);
|
RemoveSpace(XdrvMailbox.data);
|
||||||
if (strlen(XdrvMailbox.data) > 0) {
|
if (strlen(XdrvMailbox.data) > 0) {
|
||||||
JsonParser parser(XdrvMailbox.data);
|
JsonParser parser(XdrvMailbox.data);
|
||||||
JsonParserObject root = parser.getRootObject();
|
JsonParserObject root = parser.getRootObject();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user