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