FIAP (IEEE1888) library
Dependents: Fetch_IEEE1888_Storage IEEE1888_MULTI_SENSOR_GW
Fork of FiapV2 by
fiap.h@10:b355957e01f4, 2013-02-21 (annotated)
- Committer:
- strysd
- Date:
- Thu Feb 21 16:43:59 2013 +0000
- Revision:
- 10:b355957e01f4
- Parent:
- 9:02ae92c06e52
- Child:
- 11:db42339d6cce
refactering message texts for HTTP status
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 |
yueee_yt | 0:d34a9148b19e | 5 | |
yueee_yt | 0:d34a9148b19e | 6 | // --------- FIAP.h --------- |
yueee_yt | 0:d34a9148b19e | 7 | #ifndef MBED_FIAP_H |
yueee_yt | 0:d34a9148b19e | 8 | #define MBED_FIAP_H |
yueee_yt | 0:d34a9148b19e | 9 | |
yueee_yt | 0:d34a9148b19e | 10 | #include "mbed.h" |
yueee_yt | 0:d34a9148b19e | 11 | #include "HTTPClient.h" |
yueee_yt | 0:d34a9148b19e | 12 | |
yueee_yt | 0:d34a9148b19e | 13 | // return code of post method |
yueee_yt | 0:d34a9148b19e | 14 | #define FIAP_UPLOAD_OK 0 // Succeeded |
yueee_yt | 0:d34a9148b19e | 15 | #define FIAP_UPLOAD_CONNFAIL 1 // Connection faild (Socket I/O error) |
yueee_yt | 0:d34a9148b19e | 16 | #define FIAP_UPLOAD_DNSERR 2 // DNS error |
yueee_yt | 0:d34a9148b19e | 17 | #define FIAP_UPLOAD_HTTPERR 3 // HTTP Server error (The response was not "200 OK") |
yueee_yt | 0:d34a9148b19e | 18 | #define FIAP_UPLOAD_FIAPERR 4 // FIAP Server error |
yueee_yt | 0:d34a9148b19e | 19 | |
yueee_yt | 0:d34a9148b19e | 20 | /** fiap_element |
strysd | 10:b355957e01f4 | 21 | *@param char* cid Point ID |
strysd | 10:b355957e01f4 | 22 | *@param char* value data |
strysd | 10:b355957e01f4 | 23 | *@param uint16_t year nnnn |
strysd | 10:b355957e01f4 | 24 | *@param uint8_t month 1-12 |
strysd | 10:b355957e01f4 | 25 | *@param uint8_t day 1-31 |
strysd | 10:b355957e01f4 | 26 | *@param uint8_t hour 0-23 |
yueee_yt | 2:2ba00be13585 | 27 | *@param uint8_t minute 0-59 |
yueee_yt | 2:2ba00be13585 | 28 | *@param uint8_t second 0-59 |
strysd | 10:b355957e01f4 | 29 | *@param char* timezone -nn:nn, +nn:nn |
yueee_yt | 0:d34a9148b19e | 30 | */ |
yueee_yt | 0:d34a9148b19e | 31 | struct fiap_element { |
strysd | 10:b355957e01f4 | 32 | char* cid; |
strysd | 10:b355957e01f4 | 33 | char* value; |
strysd | 10:b355957e01f4 | 34 | uint16_t year; |
strysd | 10:b355957e01f4 | 35 | uint8_t month; |
strysd | 10:b355957e01f4 | 36 | uint8_t day; |
strysd | 10:b355957e01f4 | 37 | uint8_t hour; |
strysd | 10:b355957e01f4 | 38 | uint8_t minute; |
strysd | 10:b355957e01f4 | 39 | uint8_t second; |
strysd | 10:b355957e01f4 | 40 | char* timezone; |
yueee_yt | 0:d34a9148b19e | 41 | }; |
yueee_yt | 0:d34a9148b19e | 42 | |
strysd | 10:b355957e01f4 | 43 | /** FIAP Class */ |
yueee_yt | 0:d34a9148b19e | 44 | class FIAP { |
yueee_yt | 0:d34a9148b19e | 45 | public: |
strysd | 10:b355957e01f4 | 46 | /** Create fiap object */ |
strysd | 9:02ae92c06e52 | 47 | FIAP(); |
strysd | 9:02ae92c06e52 | 48 | |
strysd | 10:b355957e01f4 | 49 | /** Set Storage URL |
yueee_yt | 0:d34a9148b19e | 50 | * @param Storage FIAP Storage Addrees (ie. "http://fiap.org/axis2/services/FIAPStorage") |
yueee_yt | 0:d34a9148b19e | 51 | */ |
strysd | 9:02ae92c06e52 | 52 | void setStorage(char Storage[]); |
yueee_yt | 0:d34a9148b19e | 53 | |
yueee_yt | 0:d34a9148b19e | 54 | /** post |
yueee_yt | 0:d34a9148b19e | 55 | * @param v data vaule |
yueee_yt | 0:d34a9148b19e | 56 | * @param esize number of data |
yueee_yt | 0:d34a9148b19e | 57 | */ |
yueee_yt | 0:d34a9148b19e | 58 | int post(struct fiap_element* v, unsigned int esize); |
yueee_yt | 0:d34a9148b19e | 59 | |
yueee_yt | 0:d34a9148b19e | 60 | /** fetch_maximum |
yueee_yt | 0:d34a9148b19e | 61 | * @param cid Point ID s |
yueee_yt | 0:d34a9148b19e | 62 | * @param v Return Values |
yueee_yt | 0:d34a9148b19e | 63 | * @param esize <=2 |
yueee_yt | 0:d34a9148b19e | 64 | * @return network_error |
yueee_yt | 0:d34a9148b19e | 65 | */ |
yueee_yt | 0:d34a9148b19e | 66 | int fetch_last_data(struct fiap_element* v,unsigned int esize); |
strysd | 10:b355957e01f4 | 67 | int fetch_last_data(struct fiap_element * v); |
yueee_yt | 0:d34a9148b19e | 68 | |
yueee_yt | 0:d34a9148b19e | 69 | /** debug_mode |
yueee_yt | 0:d34a9148b19e | 70 | * Output XML and Error |
yueee_yt | 0:d34a9148b19e | 71 | */ |
yueee_yt | 0:d34a9148b19e | 72 | bool debug_mode; |
yueee_yt | 0:d34a9148b19e | 73 | |
yueee_yt | 0:d34a9148b19e | 74 | private: |
yueee_yt | 0:d34a9148b19e | 75 | char _fiap_storage[100]; |
yueee_yt | 0:d34a9148b19e | 76 | char _fiap_id_prefix[100]; |
yueee_yt | 0:d34a9148b19e | 77 | char _soap_header[256]; |
yueee_yt | 0:d34a9148b19e | 78 | char _soap_footer[256]; |
yueee_yt | 0:d34a9148b19e | 79 | char _soap_action[100]; |
yueee_yt | 2:2ba00be13585 | 80 | void post_xml_initialize(void); |
yueee_yt | 2:2ba00be13585 | 81 | void fetch_xml_initialize(void); |
strysd | 10:b355957e01f4 | 82 | char* HTTPStatusText(HTTPResult r); |
yueee_yt | 0:d34a9148b19e | 83 | }; |
yueee_yt | 0:d34a9148b19e | 84 | |
yueee_yt | 0:d34a9148b19e | 85 | #endif |