Merge pull request #8937 from grob6000/serialsend6

Serialsend6 - comma-separated decimal send as binary
This commit is contained in:
Theo Arends 2020-07-21 12:23:53 +02:00 committed by GitHub
commit ac780d5e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -906,6 +906,17 @@ void SerialSendRaw(char *codes)
}
}
// values is a comma-delimited string: e.g. "72,101,108,108,111,32,87,111,114,108,100,33,10"
void SerialSendDecimal(char *values)
{
char *p;
uint8_t code;
for (char* str = strtok_r(values, ",", &p); str; str = strtok_r(nullptr, ",", &p)) {
code = (uint8_t)atoi(str);
Serial.write(code);
}
}
uint32_t GetHash(const char *buffer, size_t size)
{
uint32_t hash = 0;

View File

@ -1333,7 +1333,7 @@ void CmndSerialConfig(void)
void CmndSerialSend(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 5)) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 6)) {
SetSeriallog(LOG_LEVEL_NONE);
Settings.flag.mqtt_serial = 1; // CMND_SERIALSEND and CMND_SERIALLOG
Settings.flag.mqtt_serial_raw = (XdrvMailbox.index > 3) ? 1 : 0; // CMND_SERIALSEND3
@ -1353,6 +1353,9 @@ void CmndSerialSend(void)
else if (5 == XdrvMailbox.index) {
SerialSendRaw(RemoveSpace(XdrvMailbox.data)); // "AA004566" as hex values
}
else if (6 == XdrvMailbox.index) {
SerialSendDecimal(XdrvMailbox.data);
}
ResponseCmndDone();
}
}