FIAP (IEEE1888) library
Dependents: Fetch_IEEE1888_Storage IEEE1888_MULTI_SENSOR_GW
Fork of FiapV2 by
Diff: fiap.h
- Revision:
- 10:b355957e01f4
- Parent:
- 9:02ae92c06e52
- Child:
- 11:db42339d6cce
--- a/fiap.h Wed Feb 20 16:12:27 2013 +0000 +++ b/fiap.h Thu Feb 21 16:43:59 2013 +0000 @@ -17,126 +17,36 @@ #define FIAP_UPLOAD_HTTPERR 3 // HTTP Server error (The response was not "200 OK") #define FIAP_UPLOAD_FIAPERR 4 // FIAP Server error -// point element - /** fiap_element - * - *@param const char* cid Point ID - *@param char* value data - *@param uint16_t year - *@param uint8_t month 1-12 - *@param uint8_t day 1-31 - *@param uint8_t hour 0-23 + *@param char* cid Point ID + *@param char* value data + *@param uint16_t year nnnn + *@param uint8_t month 1-12 + *@param uint8_t day 1-31 + *@param uint8_t hour 0-23 *@param uint8_t minute 0-59 *@param uint8_t second 0-59 - *@param char* timezone Timezone ie JST="+09:00" + *@param char* timezone -nn:nn, +nn:nn */ struct fiap_element { - const char* cid; // Set PointID - char* value; // Set Value - uint16_t year; // Year - uint8_t month; // Month 1 - 12 - uint8_t day; // Day 1 - 31 - uint8_t hour; // Hour 0 - 23 - uint8_t minute; // Minute 0 - 59 - uint8_t second; // Second 0 - 59 - //struct tm *t; // Set DateTime - char* timezone; // Set Timezon JST="+09:00" + char* cid; + char* value; + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + char* timezone; }; -/** FIAP Class - * - * for mbed - * - *Example: - *@code - * #include "mbed.h" - * #include "EthernetNetIf.h" - * #include "NTPClient.h" - * #include "fiap.h" - * - * #define ntp_server "ntp server address" - * - * DigitalOut led1(LED1); - * DigitalOut led2(LED2); - * DigitalOut led3(LED3); - * DigitalOut led4(LED4); - * - * EthernetNetIf eth; - * NTPClient ntp; - * FIAP ieee1888("http://192.168.1.5/axis2/services/FIAPStorage","http://test.fiap.org/mbed_hello/"); - * - * char timezone[] = "+09:00"; // JST - * - * struct fiap_element element[]={ - * {"P1",NULL,NULL,timezone}, - * {"P2",NULL,NULL,timezone}, - * }; - * - * int main() { - * led1=led2=led3=led4=0; - * ieee1888.debug_mode=true; - * //EthernetNetIf initialize - * EthernetErr ethErr = eth.setup(); - * if (ethErr) { - * // lcd.locate(0,1); - * // lcd.printf("Error %d in setup.\n", ethErr); - * return -1; - * } - * led1=1; - * //NTPClient initia,lize - * Host server(IpAddr(), 123, ntp_server); - * NTPResult Ntpr=ntp.setTime(server); - * //UTC-->JST +9Hour(32400Sec) - * time_t ctTime; - * ctTime = time(NULL); - * ctTime+=32400; - * set_time(ctTime); - * led2=1; - * - * //post - * int i,j; - * for (j=0; j<10; j++) { - * //data initialize - * time_t seconds = time(NULL); - * for (i=0; i<2; i++) { - * char data[5]; - * int s=j*pow((double)10,i); - * sprintf(data,"%03d",s); - * element[i].value=data; - * element[i].t=localtime(&seconds); - * } - * //do post - * int ret=ieee1888.post(element,2); - * if(ret!=0){ - * while (1) { - * led3=!led3; - * wait(0.5); - * } - * return 0; - * } - * wait(1); - * } - * //finish - * while (1) { - * led4=!led4; - * wait(0.5); - * } - * } - *@endcode - */ +/** FIAP Class */ class FIAP { public: - /** Create fiap object(for WRITE) - * @param Storage FIAP Storage Addrees (ie. "http://fiap.org/axis2/services/FIAPStorage") - * @param PointSetId Point Set ID(ie. http://test.fiap.jp/bldg_1/3F/) - */ - //FIAP(char Storage[],char PointSetId[]); - /** Create fiap object(for FETCH) - */ + /** Create fiap object */ FIAP(); - /** + /** Set Storage URL * @param Storage FIAP Storage Addrees (ie. "http://fiap.org/axis2/services/FIAPStorage") */ void setStorage(char Storage[]); @@ -154,7 +64,7 @@ * @return network_error */ int fetch_last_data(struct fiap_element* v,unsigned int esize); - int fetch_last_data(struct fiap_element * v); + int fetch_last_data(struct fiap_element * v); /** debug_mode * Output XML and Error @@ -169,6 +79,7 @@ char _soap_action[100]; void post_xml_initialize(void); void fetch_xml_initialize(void); + char* HTTPStatusText(HTTPResult r); }; #endif