mbed based IoT Gateway More details http://blog.thiseldo.co.uk/wp-filez/IoTGateway.pdf

Dependencies:   NetServices FatFileSystem csv_parser mbed MQTTClient RF12B DNSResolver SDFileSystem

Committer:
SomeRandomBloke
Date:
Wed May 09 20:29:30 2012 +0000
Revision:
5:0dbc27a7af55
Parent:
4:d460406ac780
Reduced debug output

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 4:d460406ac780 1 /** IoT Gateway Output definition for Open Energy Monitor emonCms
SomeRandomBloke 4:d460406ac780 2 *
SomeRandomBloke 4:d460406ac780 3 * @author Andrew Lindsay
SomeRandomBloke 4:d460406ac780 4 *
SomeRandomBloke 4:d460406ac780 5 * @section LICENSE
SomeRandomBloke 4:d460406ac780 6 *
SomeRandomBloke 4:d460406ac780 7 * Copyright (c) 2012 Andrew Lindsay (andrew [at] thiseldo [dot] co [dot] uk)
SomeRandomBloke 4:d460406ac780 8 *
SomeRandomBloke 4:d460406ac780 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
SomeRandomBloke 4:d460406ac780 10 * of this software and associated documentation files (the "Software"), to deal
SomeRandomBloke 4:d460406ac780 11 * in the Software without restriction, including without limitation the rights
SomeRandomBloke 4:d460406ac780 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
SomeRandomBloke 4:d460406ac780 13 * copies of the Software, and to permit persons to whom the Software is
SomeRandomBloke 4:d460406ac780 14 * furnished to do so, subject to the following conditions:
SomeRandomBloke 4:d460406ac780 15
SomeRandomBloke 4:d460406ac780 16 * The above copyright notice and this permission notice shall be included in
SomeRandomBloke 4:d460406ac780 17 * all copies or substantial portions of the Software.
SomeRandomBloke 4:d460406ac780 18 *
SomeRandomBloke 4:d460406ac780 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
SomeRandomBloke 4:d460406ac780 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
SomeRandomBloke 4:d460406ac780 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
SomeRandomBloke 4:d460406ac780 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
SomeRandomBloke 4:d460406ac780 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
SomeRandomBloke 4:d460406ac780 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
SomeRandomBloke 4:d460406ac780 25 * THE SOFTWARE.
SomeRandomBloke 4:d460406ac780 26 *
SomeRandomBloke 4:d460406ac780 27 * @section DESCRIPTION
SomeRandomBloke 4:d460406ac780 28 *
SomeRandomBloke 4:d460406ac780 29 *
SomeRandomBloke 4:d460406ac780 30 */
SomeRandomBloke 4:d460406ac780 31
SomeRandomBloke 4:d460406ac780 32 #ifndef _OUTPUTEMONCMS_H
SomeRandomBloke 4:d460406ac780 33 #define _OUTPUTEMONCMS_H
SomeRandomBloke 4:d460406ac780 34
SomeRandomBloke 5:0dbc27a7af55 35 #include "iotgateway.h"
SomeRandomBloke 4:d460406ac780 36 #include "mbed.h"
SomeRandomBloke 4:d460406ac780 37 #include "HTTPClient.h"
SomeRandomBloke 4:d460406ac780 38 #include "HTTPText.h"
SomeRandomBloke 4:d460406ac780 39
SomeRandomBloke 4:d460406ac780 40 /** Output definition class for sending readings to OpenEnergyMonitor emonCms
SomeRandomBloke 4:d460406ac780 41 */
SomeRandomBloke 4:d460406ac780 42 class OutputEmonCms {
SomeRandomBloke 4:d460406ac780 43 public:
SomeRandomBloke 4:d460406ac780 44 /** Default Constructor
SomeRandomBloke 4:d460406ac780 45 */
SomeRandomBloke 4:d460406ac780 46 OutputEmonCms();
SomeRandomBloke 4:d460406ac780 47
SomeRandomBloke 4:d460406ac780 48 /** Alternative Constructor
SomeRandomBloke 4:d460406ac780 49 *
SomeRandomBloke 4:d460406ac780 50 * @param internalBufferStart An internal buffer used to build up requests.
SomeRandomBloke 4:d460406ac780 51 * @param url Pointer to API Url
SomeRandomBloke 4:d460406ac780 52 * @param key Pointer to API key
SomeRandomBloke 4:d460406ac780 53 */
SomeRandomBloke 4:d460406ac780 54 OutputEmonCms( char *internalBufferStart, char *url, char *key );
SomeRandomBloke 4:d460406ac780 55
SomeRandomBloke 4:d460406ac780 56 /** Set the API Key to use for sending readings to Pachube
SomeRandomBloke 4:d460406ac780 57 *
SomeRandomBloke 4:d460406ac780 58 * @param key Pointer to API key
SomeRandomBloke 4:d460406ac780 59 */
SomeRandomBloke 4:d460406ac780 60 // void setApiKey( char *key );
SomeRandomBloke 4:d460406ac780 61
SomeRandomBloke 4:d460406ac780 62 /** Initialise output definition object
SomeRandomBloke 4:d460406ac780 63 */
SomeRandomBloke 4:d460406ac780 64 virtual void init();
SomeRandomBloke 4:d460406ac780 65
SomeRandomBloke 4:d460406ac780 66 /** Add a character pointer reading to output
SomeRandomBloke 4:d460406ac780 67 *
SomeRandomBloke 4:d460406ac780 68 * @param dataFeed The feed to update
SomeRandomBloke 4:d460406ac780 69 * @param dataStream The data stream within the feed to update or null if no feed
SomeRandomBloke 4:d460406ac780 70 * @param reading The new value
SomeRandomBloke 4:d460406ac780 71 */
SomeRandomBloke 4:d460406ac780 72 virtual void addReading(char *dataFeed, char *dataStream, char *reading );
SomeRandomBloke 4:d460406ac780 73
SomeRandomBloke 4:d460406ac780 74 /** Send any collected readings to the api
SomeRandomBloke 4:d460406ac780 75 *
SomeRandomBloke 4:d460406ac780 76 * @returns -1 for fail, 1 for success
SomeRandomBloke 4:d460406ac780 77 */
SomeRandomBloke 4:d460406ac780 78 virtual int send();
SomeRandomBloke 4:d460406ac780 79
SomeRandomBloke 5:0dbc27a7af55 80 /** Get the send count
SomeRandomBloke 5:0dbc27a7af55 81 *
SomeRandomBloke 5:0dbc27a7af55 82 * @returns mumber of API calls made
SomeRandomBloke 5:0dbc27a7af55 83 */
SomeRandomBloke 5:0dbc27a7af55 84 virtual int getSendCount( );
SomeRandomBloke 5:0dbc27a7af55 85
SomeRandomBloke 4:d460406ac780 86 protected:
SomeRandomBloke 4:d460406ac780 87 int sendCount;
SomeRandomBloke 4:d460406ac780 88 // OEM config
SomeRandomBloke 4:d460406ac780 89 char *apiUrl;
SomeRandomBloke 4:d460406ac780 90 char *apiKey;
SomeRandomBloke 4:d460406ac780 91 char *dataBuffer;
SomeRandomBloke 4:d460406ac780 92 char *dbufPtr;
SomeRandomBloke 4:d460406ac780 93 bool hasData;
SomeRandomBloke 4:d460406ac780 94
SomeRandomBloke 4:d460406ac780 95 };
SomeRandomBloke 4:d460406ac780 96
SomeRandomBloke 4:d460406ac780 97 #endif /* _OUTPUTEMONCMS_H */