FIAP (IEEE1888) library
Dependents: Fetch_IEEE1888_Storage IEEE1888_MULTI_SENSOR_GW
Fork of FiapV2 by
fiap.h@12:f4e59ab2bab0, 2013-02-22 (annotated)
- Committer:
- strysd
- Date:
- Fri Feb 22 16:41:51 2013 +0000
- Revision:
- 12:f4e59ab2bab0
- Parent:
- 11:db42339d6cce
- Child:
- 13:13cceccf6bfb
refactoring constructors and methods
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 | |
strysd | 12:f4e59ab2bab0 | 20 | // fetch_last_data(struct fiap_element* v) seems to be broken |
strysd | 12:f4e59ab2bab0 | 21 | #define USE_FETCH_ONLY_1 false |
strysd | 11:db42339d6cce | 22 | |
yueee_yt | 0:d34a9148b19e | 23 | /** fiap_element |
strysd | 10:b355957e01f4 | 24 | *@param char* cid Point ID |
strysd | 10:b355957e01f4 | 25 | *@param char* value data |
strysd | 10:b355957e01f4 | 26 | *@param uint16_t year nnnn |
strysd | 10:b355957e01f4 | 27 | *@param uint8_t month 1-12 |
strysd | 10:b355957e01f4 | 28 | *@param uint8_t day 1-31 |
strysd | 10:b355957e01f4 | 29 | *@param uint8_t hour 0-23 |
yueee_yt | 2:2ba00be13585 | 30 | *@param uint8_t minute 0-59 |
yueee_yt | 2:2ba00be13585 | 31 | *@param uint8_t second 0-59 |
strysd | 10:b355957e01f4 | 32 | *@param char* timezone -nn:nn, +nn:nn |
yueee_yt | 0:d34a9148b19e | 33 | */ |
yueee_yt | 0:d34a9148b19e | 34 | struct fiap_element { |
strysd | 10:b355957e01f4 | 35 | char* cid; |
strysd | 10:b355957e01f4 | 36 | char* value; |
strysd | 10:b355957e01f4 | 37 | uint16_t year; |
strysd | 10:b355957e01f4 | 38 | uint8_t month; |
strysd | 10:b355957e01f4 | 39 | uint8_t day; |
strysd | 10:b355957e01f4 | 40 | uint8_t hour; |
strysd | 10:b355957e01f4 | 41 | uint8_t minute; |
strysd | 10:b355957e01f4 | 42 | uint8_t second; |
strysd | 10:b355957e01f4 | 43 | char* timezone; |
yueee_yt | 0:d34a9148b19e | 44 | }; |
yueee_yt | 0:d34a9148b19e | 45 | |
strysd | 10:b355957e01f4 | 46 | /** FIAP Class */ |
yueee_yt | 0:d34a9148b19e | 47 | class FIAP { |
yueee_yt | 0:d34a9148b19e | 48 | public: |
strysd | 10:b355957e01f4 | 49 | /** Create fiap object */ |
strysd | 9:02ae92c06e52 | 50 | FIAP(); |
strysd | 12:f4e59ab2bab0 | 51 | FIAP(char Storage[]); |
strysd | 12:f4e59ab2bab0 | 52 | FIAP(char Storage[], bool _use_fetch); |
strysd | 9:02ae92c06e52 | 53 | |
strysd | 10:b355957e01f4 | 54 | /** Set Storage URL |
yueee_yt | 0:d34a9148b19e | 55 | * @param Storage FIAP Storage Addrees (ie. "http://fiap.org/axis2/services/FIAPStorage") |
yueee_yt | 0:d34a9148b19e | 56 | */ |
strysd | 9:02ae92c06e52 | 57 | void setStorage(char Storage[]); |
yueee_yt | 0:d34a9148b19e | 58 | |
yueee_yt | 0:d34a9148b19e | 59 | /** post |
yueee_yt | 0:d34a9148b19e | 60 | * @param v data vaule |
yueee_yt | 0:d34a9148b19e | 61 | * @param esize number of data |
yueee_yt | 0:d34a9148b19e | 62 | */ |
yueee_yt | 0:d34a9148b19e | 63 | int post(struct fiap_element* v, unsigned int esize); |
yueee_yt | 0:d34a9148b19e | 64 | |
yueee_yt | 0:d34a9148b19e | 65 | /** fetch_maximum |
yueee_yt | 0:d34a9148b19e | 66 | * @param cid Point ID s |
yueee_yt | 0:d34a9148b19e | 67 | * @param v Return Values |
yueee_yt | 0:d34a9148b19e | 68 | * @param esize <=2 |
yueee_yt | 0:d34a9148b19e | 69 | * @return network_error |
yueee_yt | 0:d34a9148b19e | 70 | */ |
strysd | 12:f4e59ab2bab0 | 71 | int fetch_last_data(struct fiap_element* v, unsigned int esize); |
yueee_yt | 0:d34a9148b19e | 72 | |
yueee_yt | 0:d34a9148b19e | 73 | /** debug_mode |
yueee_yt | 0:d34a9148b19e | 74 | * Output XML and Error |
yueee_yt | 0:d34a9148b19e | 75 | */ |
yueee_yt | 0:d34a9148b19e | 76 | bool debug_mode; |
strysd | 12:f4e59ab2bab0 | 77 | |
yueee_yt | 0:d34a9148b19e | 78 | private: |
strysd | 12:f4e59ab2bab0 | 79 | bool _use_fetch; |
yueee_yt | 0:d34a9148b19e | 80 | char _fiap_storage[100]; |
strysd | 11:db42339d6cce | 81 | //char _fiap_id_prefix[100]; |
yueee_yt | 0:d34a9148b19e | 82 | char _soap_header[256]; |
yueee_yt | 0:d34a9148b19e | 83 | char _soap_footer[256]; |
strysd | 11:db42339d6cce | 84 | char _soap_action[32]; |
strysd | 11:db42339d6cce | 85 | char _soap_text[2000]; |
strysd | 11:db42339d6cce | 86 | char _uuid[37]; |
strysd | 11:db42339d6cce | 87 | void xml_initialize(void); |
strysd | 11:db42339d6cce | 88 | void generateUUID(); |
strysd | 10:b355957e01f4 | 89 | char* HTTPStatusText(HTTPResult r); |
strysd | 11:db42339d6cce | 90 | void myprintf(char*); |
yueee_yt | 0:d34a9148b19e | 91 | }; |
yueee_yt | 0:d34a9148b19e | 92 | |
yueee_yt | 0:d34a9148b19e | 93 | #endif |