Dreamforce 2013 MiniHack Thermostat Challenge - remotes
Dependencies: C12832_lcd EthernetInterface-ansond-patched HTTPClient-thermostat-remotes LM75B MMA7660 SocketIO WebSocketClient-ThermostatDemo mbed-rtos mbed picojson
Fork of df-2013-minihack-thermostat-complete by
Diff: Thermostat.cpp
- Revision:
- 4:379e9ad21486
- Parent:
- 1:3faa003ad6e6
- Child:
- 5:9866322ed225
--- a/Thermostat.cpp Fri Nov 08 20:10:52 2013 +0000 +++ b/Thermostat.cpp Sun Nov 10 16:38:24 2013 +0000 @@ -44,17 +44,26 @@ // DreamForce 2013 Tunables START -// -// Our default Latitude and Longitude -// -#define DEFAULT_LATITUDE 37.7842 -#define DEFAULT_LONGITUDE -122.4016 +// set our location +int location_index = 0; -// -// Name our endpoint something unique -// -#define DEFAULT_ENDPOINT_NAME "DreamForce Thermostat" - +// Remoted Thermostats +// Thermostat 1: Austin TX 30.2500 –97.7500 +// Thermostat 2: Phoenix AZ 33.4500 -112.0667 +// Thermostat 3: Dallas TX 32.7758 -96.7967 +// Thermostat 4: Miami FL 25.7877 -80.2241 +// Thermostat 5: Chicago IL 41.8819 –87.6278 +// Thermostat 6: Memphis TN 35.1174 -89.9711 +// Thermostat 7: Seattle WA 47.6097 –122.3331 +// Thermostat 8: New York NY 40.6700 –73.9400 +// Thermostat 9: Raleigh NC 35.8189 –78.6447 +// Thermostat 10: Moscone 37.7842 –122.4016 +float latitudes[10] = { 30.2500, 33.4500, 32.7758, 25.7877, 41.8819, 35.1174, 47.6097, 40.6700, 35.8189, 37.7842}; +float longitudes[10] = { -97.7500, -112.0667, -96.7967, -80.2241, -87.6278, -89.9711, -122.3331, -73.9400, -78.6447, -122.4016}; +char *locations[10] = { "DF Thermostat-Austin TX", "DF Thermostat-Phoenix AZ", "DF Thermostat-Dallas TX", "DF Thermostat-Miami FL", + "DF Thermostat-Chicago IL", "DF Thermostat-Memphis TN", "DF Thermostat-Seattle WA", + "DF Thermostat-New York NY", "DF Thermostat-Raleigh NC", "DF Thermostat-Moscone Center"}; + // DreamForce 2013 Tunables END // Wait Loop default sleep per iteration @@ -85,7 +94,7 @@ // Thermostat SocketIO Support // #include "ThermostatSocketIO.h" -ThermostatSocketIO socketio(DEFAULT_ENDPOINT_NAME); +ThermostatSocketIO socketio(locations[location_index]); // Include LED Utils #include "Thermostat-LEDUtils.h" @@ -363,6 +372,29 @@ // announce our position this->updateCoordinates(); + + // if not connected... reconnect + if (!socketio.is_connected()){ + // announce + this->display("Re-connecting..."); + this->display_lcd("Re-connecting..."); + + // re-connect + if (this->connectWebSocketService()) { + // announce + this->display("Reconnect success"); + this->display_lcd("Reconnect: SUCCESS"); + this->turnRGBLEDGreen(); + this->resetAllLEDs(); + } + else { + // announce + this->display("Reconnect failure"); + this->display_lcd("Reconnect: FAILED"); + this->gracefullyDisconnect(); + this->turnRGBLEDRed(); + } + } // check and react to the joystick button press if (joystick_pressed) {