spejsiot/switch/app/application.cpp

19 lines
440 B
C++
Raw Normal View History

2016-06-29 15:00:22 +00:00
#include <SpejsNode.h>
2015-12-26 23:29:30 +00:00
2016-06-29 15:00:22 +00:00
SpejsNode node("switch");
2015-12-26 23:29:30 +00:00
2016-06-29 15:00:22 +00:00
void init() {
node.init();
node.registerInput("relay", *[](String value) {
Serial.println("handler");
digitalWrite(5, value == "1" ? HIGH : LOW);
2015-12-26 23:29:30 +00:00
});
2016-06-29 15:00:22 +00:00
pinMode(5, OUTPUT);
digitalWrite(5, LOW);
2015-12-26 23:29:30 +00:00
attachInterrupt(BTN_PIN, *[] {
2016-06-29 15:00:22 +00:00
node.notify("btn", String(digitalRead(BTN_PIN)));
}, CHANGE);
//node.registerInputGPIO("btn", BTN_PIN);
//node.registerOutputGPIO("led", LED_PIN);
2015-12-26 23:29:30 +00:00
}