TVZ Mechatronics Team / Mbed 2 deprecated PMS5003

Dependencies:   NetServices ThingSpeakEthernet mbed

Committer:
mpuric
Date:
Mon Jun 05 08:12:57 2017 +0000
Revision:
9:07f9279c30f7
Init commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mpuric 9:07f9279c30f7 1 #ifndef THINGSPEAK_H
mpuric 9:07f9279c30f7 2 #define THINGSPEAK_H
mpuric 9:07f9279c30f7 3 #define HOSTNAME "mbed"
mpuric 9:07f9279c30f7 4 #include "mbed.h"
mpuric 9:07f9279c30f7 5 #include "EthernetNetIf.h"
mpuric 9:07f9279c30f7 6 #include "HTTPClient.h"
mpuric 9:07f9279c30f7 7
mpuric 9:07f9279c30f7 8 /** Class for sending data to ThingSpeak over ethernet,
mpuric 9:07f9279c30f7 9 * Class is using old mbed library revision and EthernetNetIf from
mpuric 9:07f9279c30f7 10 * https://developer.mbed.org/users/okini3939/notebook/TCPSocket_jp/
mpuric 9:07f9279c30f7 11 * Example:
mpuric 9:07f9279c30f7 12 * @code
mpuric 9:07f9279c30f7 13 * #include "mbed.h"
mpuric 9:07f9279c30f7 14 * #include "ThingSpeak.h"
mpuric 9:07f9279c30f7 15 *
mpuric 9:07f9279c30f7 16 * ThingSpeak thingSpeak("XXXXXXXXXXXXXXXX");
mpuric 9:07f9279c30f7 17 *
mpuric 9:07f9279c30f7 18 * int main() {
mpuric 9:07f9279c30f7 19 * int i = 1;
mpuric 9:07f9279c30f7 20 * flot value = 3.14;
mpuric 9:07f9279c30f7 21 * thingSpeak.connect();
mpuric 9:07f9279c30f7 22 * thingSpeak.setField(value,i)
mpuric 9:07f9279c30f7 23 * thingSpeak.putUp();
mpuric 9:07f9279c30f7 24 * }
mpuric 9:07f9279c30f7 25 * @endcode
mpuric 9:07f9279c30f7 26 */
mpuric 9:07f9279c30f7 27 class ThingSpeak
mpuric 9:07f9279c30f7 28 {
mpuric 9:07f9279c30f7 29
mpuric 9:07f9279c30f7 30 public:
mpuric 9:07f9279c30f7 31 /**
mpuric 9:07f9279c30f7 32 * @param: write api key provided from ThingSpeak chanell
mpuric 9:07f9279c30f7 33 */
mpuric 9:07f9279c30f7 34 ThingSpeak(char*);
mpuric 9:07f9279c30f7 35 /**
mpuric 9:07f9279c30f7 36 * Establishing ethernet connection until connected
mpuric 9:07f9279c30f7 37 *
mpuric 9:07f9279c30f7 38 */
mpuric 9:07f9279c30f7 39 void connect();
mpuric 9:07f9279c30f7 40
mpuric 9:07f9279c30f7 41 float pull(long int, int);
mpuric 9:07f9279c30f7 42
mpuric 9:07f9279c30f7 43 /**
mpuric 9:07f9279c30f7 44 * Should be added
mpuric 9:07f9279c30f7 45 */
mpuric 9:07f9279c30f7 46 /**
mpuric 9:07f9279c30f7 47 * void getIP();
mpuric 9:07f9279c30f7 48 */
mpuric 9:07f9279c30f7 49 /**
mpuric 9:07f9279c30f7 50 * Put up data to thing speak when all fields are set
mpuric 9:07f9279c30f7 51 */
mpuric 9:07f9279c30f7 52 void putUp();
mpuric 9:07f9279c30f7 53 /**
mpuric 9:07f9279c30f7 54 *Setting values to the field, they should be set in order.
mpuric 9:07f9279c30f7 55 * It's not required to set them all (example: you can set 1, 2, 3 or 1, 3)
mpuric 9:07f9279c30f7 56 * @param field value to store on
mpuric 9:07f9279c30f7 57 * @param i number of a field
mpuric 9:07f9279c30f7 58 */
mpuric 9:07f9279c30f7 59 void setField(float field, int i);
mpuric 9:07f9279c30f7 60 private:
mpuric 9:07f9279c30f7 61
mpuric 9:07f9279c30f7 62 char* thingSpeakUrl;
mpuric 9:07f9279c30f7 63 char* thingSpeakRead;
mpuric 9:07f9279c30f7 64 char* thingSpeakKey;
mpuric 9:07f9279c30f7 65 char urlBuffer[1023];
mpuric 9:07f9279c30f7 66 char fieldBuffer[1023];
mpuric 9:07f9279c30f7 67 EthernetNetIf eth;
mpuric 9:07f9279c30f7 68 EthernetErr ethErr;
mpuric 9:07f9279c30f7 69 HTTPClient http;
mpuric 9:07f9279c30f7 70 IpAddr ethIp;
mpuric 9:07f9279c30f7 71 HTTPText resp;
mpuric 9:07f9279c30f7 72 HTTPResult res;
mpuric 9:07f9279c30f7 73 };
mpuric 9:07f9279c30f7 74
mpuric 9:07f9279c30f7 75 #endif