Dreamforce Heroku Sample mbed application for the FRDM-K64F. This application uses SocketIO to connect and communicate with Heroku.

Dependencies:   BufferedSerial C12832 EthernetInterface HTTPClient-SSL LM75B MMA7660 SocketIO-k64f WebSocketClient-ThermostatDemo mbed-rtos mbed picojson

Fork of df-2013-minihack-thermostat-complete by MBED_DEMOS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ThermostatSocketIO.h Source File

ThermostatSocketIO.h

00001 /**
00002 * @author Doug Anson
00003 *
00004 * @section LICENSE
00005 *
00006 * Copyright (c) 2013 mbed
00007 *
00008 * Permission is hereby granted, free of charge, to any person obtaining a copy
00009 * of this software and associated documentation files (the "Software"), to deal
00010 * in the Software without restriction, including without limitation the rights
00011 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00012 * copies of the Software, and to permit persons to whom the Software is
00013 * furnished to do so, subject to the following conditions:
00014 *
00015 * The above copyright notice and this permission notice shall be included in
00016 * all copies or substantial portions of the Software.
00017 *
00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00021 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00023 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00024 * THE SOFTWARE.
00025 *
00026 * @section DESCRIPTION
00027 *    SocketIO derivation client library for the Thermostat Demo
00028 *
00029 */
00030 
00031 #ifndef THERMOSTATSOCKETIO_H
00032 #define THERMOSTATSOCKETIO_H
00033 
00034 #include "SocketIO.h"
00035 
00036 /** 
00037  * ThermostatSocketIO client class.
00038  * Derived class from SocketIO library specifically for the ThermostatDemo app
00039  */
00040 
00041 class ThermostatSocketIO : public SocketIO
00042 {
00043     public:
00044         /**
00045         * Constructor
00046         *
00047         * @param devname The device's devname for display in the console
00048         */
00049         ThermostatSocketIO(char *devname);
00050         
00051         /**
00052         * Constructor
00053         *
00054         * @param url The SocketIO url in the form "www.example.com:[port]" (by default: port = 80) - i.e. just the endpoint name
00055         * @param devname The device's devname for display in the console
00056         */
00057         ThermostatSocketIO(char * url, char *devname);
00058         
00059         /**
00060         * Emit (Broadcast) a socket.io message to the SocketIO server - specific to the ThermostatDemo app
00061         *
00062         * @param temp - temperature
00063         * @param latitude - the device latitude
00064         * @param longitude - the device longitude
00065         * @param bat - the battery level
00066         * @param errorState - the devices current error state
00067         * @param t_status - the devices current error state (string - either OK or FAIL)
00068         *
00069         * @returns the number of bytes sent
00070         */
00071         int emit(float temp, float latitude, float longitude, float bat, int errorState, char *t_status);
00072         
00073         /**
00074         * Reset the message counter
00075         */
00076         void resetMessageCounter();
00077         
00078         /**
00079         * Close the SocketIO connection
00080         *
00081         * @return true if the connection has been closed, false otherwise
00082         */
00083         bool close();
00084         
00085    private:
00086         // variables
00087         char *device_name;
00088         
00089         // methods
00090         char *createDeregisterJSON(char *buffer);
00091         char *createJSON(char *buffer, float temp, float latitude, float longitude, float bat, int errorState, char *t_status);
00092 };
00093 
00094 #endif // THERMOSTATSOCKETIO_H