#include #include #include #include #include /* Temperature Function example Exposes a function for getting the current temperature from Altair's integrated temperature sensor. For more information on how to use the service from the Hub, see: http://docs.aquila2.apiary.io/ */ float temperature(uint8_t method, char *data, uint8_t dataSize) { float temp = getTempC(); return temp; } /* Example_ButtonEvent In this example we will use Altair's internal button for triggering an event that can be connected to other devices via interactions. */ // Altair's internal button #define BUTTON 33 // Event that will be emited when the button is pressed Event buttonPressed; // Simple button status check routine bool buttonLastState = HIGH; bool buttonIsPressed() { bool actualState = digitalRead(BUTTON); if(actualState == LOW && buttonLastState == HIGH) { buttonLastState = LOW; return true; } else if(actualState == HIGH) { buttonLastState = HIGH; } return false; } void setup() { Serial.begin(9600); Mesh.begin(); Aquila.begin(); Services.begin(); Services.function("temperature", temperature); Aquila.setClass("mx.makerlab.tempexample"); Aquila.setName("PcDeMaNo"); // Button setup pinMode(BUTTON, INPUT); // Aquila setup //Mesh.begin(); //Aquila.begin(); Aquila.setClass("mx.makerlab.button"); Aquila.setName("PcDeMaNo"); // Registering event buttonPressed = Aquila.addEvent("Button Pressed"); // Anouncing device Mesh.announce(HUB); } void loop() { Mesh.loop(); Aquila.loop(); Services.loop(); // Checking button if(buttonIsPressed()) { Aquila.emit(buttonPressed); } }