Created
April 12, 2016 15:21
-
-
Save LosantGists/7d5d6a8e545aa3826148de5f431aa5b8 to your computer and use it in GitHub Desktop.
losant-sneak-preview-2-m2m-communication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void toggle() { | |
Serial.println("Toggling LED."); | |
ledState = !ledState; | |
digitalWrite(LED_PIN, ledState ? HIGH : LOW); | |
} | |
// Called whenever the device receives a command from the Losant platform. | |
void handleCommand(LosantCommand *command) { | |
Serial.print("Command received: "); | |
Serial.println(command->name); | |
if(strcmp(command->name, "toggle") == 0) { | |
toggle(); | |
} | |
} | |
// Register the command handler to be called when a command is received | |
// from the Losant platform. | |
device.onCommand(&handleCommand); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment