Output sinnvoll verarbeitet und zum MQTT übergeben
This commit is contained in:
parent
6a0dfea8e8
commit
272a4fa43f
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
SoftwareSerial swSer(D2, D1);
|
SoftwareSerial swSer(D2, D1);
|
||||||
int currentnumber = 0;
|
int currentnumber = 0;
|
||||||
|
int inputbytes[4];
|
||||||
|
String output = "";
|
||||||
|
String output2 = "";
|
||||||
|
|
||||||
HomieNode switchNode("switch", "switch");
|
HomieNode switchNode("switch", "switch");
|
||||||
|
|
||||||
|
@ -44,9 +47,42 @@ void loop() {
|
||||||
|
|
||||||
while (swSer.available() > 0) {
|
while (swSer.available() > 0) {
|
||||||
int r1 = swSer.read();
|
int r1 = swSer.read();
|
||||||
|
Serial.print(currentnumber);
|
||||||
|
Serial.print(": ");
|
||||||
Serial.print(r1);
|
Serial.print(r1);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
switchNode.setProperty("data").send(String(r1, DEC));
|
inputbytes[currentnumber] = r1;
|
||||||
|
|
||||||
|
output += String(r1, DEC);
|
||||||
|
output += " ";
|
||||||
|
if (currentnumber == 3) {
|
||||||
|
switchNode.setProperty("data").send(output);
|
||||||
|
output2 = "";
|
||||||
|
output2 += "OUTPUT ";
|
||||||
|
output2 += String(inputbytes[2]-128, DEC);
|
||||||
|
output2 += " INPUT ";
|
||||||
|
output2 += String(inputbytes[1]-128, DEC);
|
||||||
|
switchNode.setProperty("switchevent").send(output2);
|
||||||
|
switchNode.setProperty("input").send(String(inputbytes[1]-128, DEC));
|
||||||
|
switchNode.setProperty("output").send(String(inputbytes[2]-128, DEC));
|
||||||
|
// Einfache Interpretation
|
||||||
|
// Serial.print("Von ");
|
||||||
|
// Serial.print(String(inputbytes[2]-128, DEC));
|
||||||
|
// Serial.print(" zu ");
|
||||||
|
// Serial.println(String(inputbytes[1]-128, DEC));
|
||||||
|
currentnumber = 0;
|
||||||
|
inputbytes[0] = 0;
|
||||||
|
inputbytes[1] = 0;
|
||||||
|
inputbytes[2] = 0;
|
||||||
|
inputbytes[3] = 0;
|
||||||
|
output = "";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Serial.print(">");
|
||||||
|
Serial.print(currentnumber);
|
||||||
|
Serial.print("<");
|
||||||
|
currentnumber++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// while (Serial.available() > 0) {
|
// while (Serial.available() > 0) {
|
||||||
// swSer.write(Serial.read());
|
// swSer.write(Serial.read());
|
||||||
|
|
Loading…
Reference in New Issue