Umgebaut auf Arduino-interne String-Funktion. Untested!
This commit is contained in:
parent
8e487aa213
commit
cfde48c2b3
|
@ -20,8 +20,21 @@ HomieNode switchNode("switch", "switch");
|
|||
|
||||
bool switchHandler(const HomieRange& range, const String& value) {
|
||||
Homie.getLogger() << "switch " << ": " << value << endl;
|
||||
int localByte = 0;
|
||||
|
||||
if (sscanf(value, "%d %d %d %d", &commandbytes[0], &commandbytes[1], &commandbytes[2], &commandbytes[3]) == 4)
|
||||
int lastspace = 0;
|
||||
int nextspace = 0;
|
||||
while (nextspace < value.length()-1)
|
||||
{
|
||||
// Nur solange wir noch Platz für Inputbytes haben... :)
|
||||
if (localByte <= 3) {
|
||||
nextspace = value.indexOf(' ', lastspace);
|
||||
commandbytes[localByte] = (value.substring(lastspace,nextspace-1)).toInt(); // TEST for sanity
|
||||
localByte++;
|
||||
}
|
||||
}
|
||||
|
||||
if (localByte ==4)
|
||||
{
|
||||
// Nur wenn wirklich 4 Werte übernommen wurden
|
||||
switchNode.setProperty("switch").send(value);
|
||||
|
|
Loading…
Reference in New Issue