Initial commit

This commit is contained in:
starcalc 2017-11-27 22:13:38 +01:00
commit 6a0dfea8e8
1 changed files with 55 additions and 0 deletions

55
esp-videoswitcher.ino Normal file
View File

@ -0,0 +1,55 @@
#include <Homie.h>
#include <ArduinoOTA.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
// Timeout, wann die Verbindung als "zurückgesetzt" angesehen werden soll und wieder auf das erste Byte gewartet wird
#define TIMEOUT 500
#define FW_NAME "esp-videoswitcher"
#define FW_VERSION "1.0.0"
SoftwareSerial swSer(D2, D1);
int currentnumber = 0;
HomieNode switchNode("switch", "switch");
bool switchHandler(const HomieRange& range, const String& value) {
Homie.getLogger() << "switch " << ": " << value << endl;
switchNode.setProperty("switch").send(value);
return true;
}
void setup() {
Serial.begin(115200);
swSer.begin(9600);
Serial.println("\nKramer VS-162AV");
Homie_setFirmware(FW_NAME, FW_VERSION);
Homie_setBrand(FW_NAME);
switchNode.advertise("switch").settable(switchHandler);
Homie.setup();
ArduinoOTA.setHostname(Homie.getConfiguration().deviceId);
ArduinoOTA.begin();
}
void loop() {
Homie.loop();
ArduinoOTA.handle();
while (swSer.available() > 0) {
int r1 = swSer.read();
Serial.print(r1);
Serial.print(" ");
switchNode.setProperty("data").send(String(r1, DEC));
}
// while (Serial.available() > 0) {
// swSer.write(Serial.read());
// }
}