Relay updated to new api

This commit is contained in:
Henrik Ekblad
2014-05-14 00:26:52 +02:00
parent 26ef9c81c2
commit 4b18f9fbf4
@@ -18,8 +18,7 @@ MySensor gw;
void setup() void setup()
{ {
// Initialize library and add callback for incoming messages // Initialize library and add callback for incoming messages
gw.begin(incomingMessage); gw.begin(incomingMessage, false);
// Send the sketch version information to the gateway and Controller // Send the sketch version information to the gateway and Controller
gw.sketchInfo("Relay", "1.0"); gw.sketchInfo("Relay", "1.0");
@@ -49,8 +48,10 @@ void loop()
void incomingMessage(MyMessage message) { void incomingMessage(MyMessage message) {
// We only expect one type of message from controller. But we better check anyway. // We only expect one type of message from controller. But we better check anyway.
Serial.println("hej");
if (message.getType()==V_LIGHT) { if (message.getType()==V_LIGHT) {
bool status = message.getBool(); bool status = message.getBool();
// Change relay state // Change relay state
digitalWrite(message.getSensor(), status?RELAY_ON:RELAY_OFF); digitalWrite(message.getSensor(), status?RELAY_ON:RELAY_OFF);
@@ -61,3 +62,4 @@ void incomingMessage(MyMessage message) {
Serial.println(status); Serial.println(status);
} }
} }