FIAP (IEEE1888) library
Dependents: Fetch_IEEE1888_Storage IEEE1888_MULTI_SENSOR_GW
Fork of FiapV2 by
fiap.h@15:3bd6f70e57e2, 2013-02-27 (annotated)
- Committer:
- strysd
- Date:
- Wed Feb 27 14:19:33 2013 +0000
- Revision:
- 15:3bd6f70e57e2
- Parent:
- 14:a9ec0e6e22c8
- Child:
- 19:101d8775b33d
refactoring
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yueee_yt | 0:d34a9148b19e | 1 | // IEEE1888 / FIAP Uploader Library for Arduino |
yueee_yt | 0:d34a9148b19e | 2 | // |
yueee_yt | 0:d34a9148b19e | 3 | // 2011/09/19 ver.1 H.Inoue & H.Ochiai |
yueee_yt | 0:d34a9148b19e | 4 | // 2011/12/31 Ver.1 for mbed Y.Tauchi |
strysd | 13:13cceccf6bfb | 5 | // 2013/02 inherited repository by S.Yoshida |
yueee_yt | 0:d34a9148b19e | 6 | |
yueee_yt | 0:d34a9148b19e | 7 | // --------- FIAP.h --------- |
yueee_yt | 0:d34a9148b19e | 8 | #ifndef MBED_FIAP_H |
yueee_yt | 0:d34a9148b19e | 9 | #define MBED_FIAP_H |
yueee_yt | 0:d34a9148b19e | 10 | |
yueee_yt | 0:d34a9148b19e | 11 | #include "mbed.h" |
yueee_yt | 0:d34a9148b19e | 12 | #include "HTTPClient.h" |
yueee_yt | 0:d34a9148b19e | 13 | |
yueee_yt | 0:d34a9148b19e | 14 | // return code of post method |
yueee_yt | 0:d34a9148b19e | 15 | #define FIAP_UPLOAD_OK 0 // Succeeded |
yueee_yt | 0:d34a9148b19e | 16 | #define FIAP_UPLOAD_CONNFAIL 1 // Connection faild (Socket I/O error) |
yueee_yt | 0:d34a9148b19e | 17 | #define FIAP_UPLOAD_DNSERR 2 // DNS error |
yueee_yt | 0:d34a9148b19e | 18 | #define FIAP_UPLOAD_HTTPERR 3 // HTTP Server error (The response was not "200 OK") |
yueee_yt | 0:d34a9148b19e | 19 | #define FIAP_UPLOAD_FIAPERR 4 // FIAP Server error |
yueee_yt | 0:d34a9148b19e | 20 | |
strysd | 13:13cceccf6bfb | 21 | // use fetch_last_data(struct fiap_element* v, unsigned int esize) if true |
strysd | 15:3bd6f70e57e2 | 22 | #define USE_FETCH true |
strysd | 11:db42339d6cce | 23 | |
yueee_yt | 0:d34a9148b19e | 24 | /** fiap_element |
strysd | 10:b355957e01f4 | 25 | *@param char* cid Point ID |
strysd | 10:b355957e01f4 | 26 | *@param char* value data |
strysd | 10:b355957e01f4 | 27 | *@param uint16_t year nnnn |
strysd | 10:b355957e01f4 | 28 | *@param uint8_t month 1-12 |
strysd | 10:b355957e01f4 | 29 | *@param uint8_t day 1-31 |
strysd | 10:b355957e01f4 | 30 | *@param uint8_t hour 0-23 |
yueee_yt | 2:2ba00be13585 | 31 | *@param uint8_t minute 0-59 |
yueee_yt | 2:2ba00be13585 | 32 | *@param uint8_t second 0-59 |
strysd | 10:b355957e01f4 | 33 | *@param char* timezone -nn:nn, +nn:nn |
yueee_yt | 0:d34a9148b19e | 34 | */ |
yueee_yt | 0:d34a9148b19e | 35 | struct fiap_element { |
strysd | 10:b355957e01f4 | 36 | char* cid; |
strysd | 10:b355957e01f4 | 37 | char* value; |
strysd | 10:b355957e01f4 | 38 | uint16_t year; |
strysd | 10:b355957e01f4 | 39 | uint8_t month; |
strysd | 10:b355957e01f4 | 40 | uint8_t day; |
strysd | 10:b355957e01f4 | 41 | uint8_t hour; |
strysd | 10:b355957e01f4 | 42 | uint8_t minute; |
strysd | 10:b355957e01f4 | 43 | uint8_t second; |
strysd | 10:b355957e01f4 | 44 | char* timezone; |
yueee_yt | 0:d34a9148b19e | 45 | }; |
yueee_yt | 0:d34a9148b19e | 46 | |
strysd | 10:b355957e01f4 | 47 | /** FIAP Class */ |
yueee_yt | 0:d34a9148b19e | 48 | class FIAP { |
yueee_yt | 0:d34a9148b19e | 49 | public: |
strysd | 13:13cceccf6bfb | 50 | /** Create fiap object |
strysd | 13:13cceccf6bfb | 51 | * @param Storage FIAP Storage Addrees |
strysd | 13:13cceccf6bfb | 52 | * @param _use_fetch use fetch mode if true, write mode if false |
strysd | 13:13cceccf6bfb | 53 | */ |
strysd | 13:13cceccf6bfb | 54 | FIAP(char Storage[], bool _use_fetch); |
strysd | 13:13cceccf6bfb | 55 | FIAP(char Storage[]); |
strysd | 9:02ae92c06e52 | 56 | FIAP(); |
strysd | 9:02ae92c06e52 | 57 | |
strysd | 10:b355957e01f4 | 58 | /** Set Storage URL |
strysd | 13:13cceccf6bfb | 59 | * @param Storage FIAP Storage Addrees |
yueee_yt | 0:d34a9148b19e | 60 | */ |
strysd | 9:02ae92c06e52 | 61 | void setStorage(char Storage[]); |
yueee_yt | 0:d34a9148b19e | 62 | |
strysd | 15:3bd6f70e57e2 | 63 | /* Set mode |
strysd | 15:3bd6f70e57e2 | 64 | * @param _use_fetch use fetch mode if true, write mode if false |
strysd | 15:3bd6f70e57e2 | 65 | */ |
strysd | 15:3bd6f70e57e2 | 66 | void setMode(bool _use_fetch); |
strysd | 15:3bd6f70e57e2 | 67 | |
yueee_yt | 0:d34a9148b19e | 68 | /** post |
yueee_yt | 0:d34a9148b19e | 69 | * @param v data vaule |
yueee_yt | 0:d34a9148b19e | 70 | * @param esize number of data |
yueee_yt | 0:d34a9148b19e | 71 | */ |
yueee_yt | 0:d34a9148b19e | 72 | int post(struct fiap_element* v, unsigned int esize); |
yueee_yt | 0:d34a9148b19e | 73 | |
strysd | 15:3bd6f70e57e2 | 74 | /** fetch last data |
yueee_yt | 0:d34a9148b19e | 75 | * @param cid Point ID s |
yueee_yt | 0:d34a9148b19e | 76 | * @param v Return Values |
yueee_yt | 0:d34a9148b19e | 77 | * @param esize <=2 |
yueee_yt | 0:d34a9148b19e | 78 | * @return network_error |
yueee_yt | 0:d34a9148b19e | 79 | */ |
strysd | 12:f4e59ab2bab0 | 80 | int fetch_last_data(struct fiap_element* v, unsigned int esize); |
strysd | 15:3bd6f70e57e2 | 81 | |
strysd | 15:3bd6f70e57e2 | 82 | /** get status text |
strysd | 15:3bd6f70e57e2 | 83 | * @param r HTTPResult |
strysd | 15:3bd6f70e57e2 | 84 | * @preturn status text |
strysd | 15:3bd6f70e57e2 | 85 | */ |
strysd | 15:3bd6f70e57e2 | 86 | char* HTTPStatusText(HTTPResult r); |
yueee_yt | 0:d34a9148b19e | 87 | |
yueee_yt | 0:d34a9148b19e | 88 | /** debug_mode |
yueee_yt | 0:d34a9148b19e | 89 | * Output XML and Error |
yueee_yt | 0:d34a9148b19e | 90 | */ |
yueee_yt | 0:d34a9148b19e | 91 | bool debug_mode; |
strysd | 15:3bd6f70e57e2 | 92 | |
yueee_yt | 0:d34a9148b19e | 93 | private: |
strysd | 13:13cceccf6bfb | 94 | bool _use_fetch;//use fetch mode if true, write mode if false |
strysd | 13:13cceccf6bfb | 95 | char _fiap_storage[100];//FIAP Storage Addrees |
yueee_yt | 0:d34a9148b19e | 96 | char _soap_header[256]; |
yueee_yt | 0:d34a9148b19e | 97 | char _soap_footer[256]; |
strysd | 11:db42339d6cce | 98 | char _soap_action[32]; |
strysd | 11:db42339d6cce | 99 | char _soap_text[2000]; |
strysd | 11:db42339d6cce | 100 | void myprintf(char*); |
yueee_yt | 0:d34a9148b19e | 101 | }; |
yueee_yt | 0:d34a9148b19e | 102 | |
yueee_yt | 0:d34a9148b19e | 103 | #endif |