FIAPライブラリ 構造体の内容が変わっています
Dependents: temp_FIAP temp_FIAP_fetch tepco_demand BlueUSB_f_IEEE1888 ... more
fiap.h
00001 // IEEE1888 / FIAP Uploader Library for Arduino 00002 // 00003 // 2011/09/19 ver.1 H.Inoue & H.Ochiai 00004 // 2011/12/31 Ver.1 for mbed Y.Tauchi 00005 00006 // --------- FIAP.h --------- 00007 #ifndef MBED_FIAP_H 00008 #define MBED_FIAP_H 00009 00010 #include "mbed.h" 00011 #include "HTTPClient.h" 00012 00013 // return code of post method 00014 #define FIAP_UPLOAD_OK 0 // Succeeded 00015 #define FIAP_UPLOAD_CONNFAIL 1 // Connection faild (Socket I/O error) 00016 #define FIAP_UPLOAD_DNSERR 2 // DNS error 00017 #define FIAP_UPLOAD_HTTPERR 3 // HTTP Server error (The response was not "200 OK") 00018 #define FIAP_UPLOAD_FIAPERR 4 // FIAP Server error 00019 00020 // point element 00021 00022 /** fiap_element 00023 * 00024 *@param const char* cid Point ID 00025 *@param char* value data 00026 *@param uint16_t year 00027 *@param uint8_t month 1-12 00028 *@param uint8_t day 1-31 00029 *@param uint8_t hour 0-23 00030 *@param uint8_t minute 0-59 00031 *@param uint8_t second 0-59 00032 *@param char* timezone Timezone ie JST="+09:00" 00033 */ 00034 struct fiap_element { 00035 const char* cid; // Set PointID 00036 char* value; // Set Value 00037 uint16_t year; // Year 00038 uint8_t month; // Month 1 - 12 00039 uint8_t day; // Day 1 - 31 00040 uint8_t hour; // Hour 0 - 23 00041 uint8_t minute; // Minute 0 - 59 00042 uint8_t second; // Second 0 - 59 00043 //struct tm *t; // Set DateTime 00044 char* timezone; // Set Timezon JST="+09:00" 00045 }; 00046 00047 /** FIAP Class 00048 * 00049 * for mbed 00050 * 00051 *Example: 00052 *@code 00053 * #include "mbed.h" 00054 * #include "EthernetNetIf.h" 00055 * #include "NTPClient.h" 00056 * #include "fiap.h" 00057 * 00058 * #define ntp_server "ntp server address" 00059 * 00060 * DigitalOut led1(LED1); 00061 * DigitalOut led2(LED2); 00062 * DigitalOut led3(LED3); 00063 * DigitalOut led4(LED4); 00064 * 00065 * EthernetNetIf eth; 00066 * NTPClient ntp; 00067 * FIAP ieee1888("http://192.168.1.5/axis2/services/FIAPStorage","http://test.fiap.org/mbed_hello/"); 00068 * 00069 * char timezone[] = "+09:00"; // JST 00070 * 00071 * struct fiap_element element[]={ 00072 * {"P1",NULL,NULL,timezone}, 00073 * {"P2",NULL,NULL,timezone}, 00074 * }; 00075 * 00076 * int main() { 00077 * led1=led2=led3=led4=0; 00078 * ieee1888.debug_mode=true; 00079 * //EthernetNetIf initialize 00080 * EthernetErr ethErr = eth.setup(); 00081 * if (ethErr) { 00082 * // lcd.locate(0,1); 00083 * // lcd.printf("Error %d in setup.\n", ethErr); 00084 * return -1; 00085 * } 00086 * led1=1; 00087 * //NTPClient initia,lize 00088 * Host server(IpAddr(), 123, ntp_server); 00089 * NTPResult Ntpr=ntp.setTime(server); 00090 * //UTC-->JST +9Hour(32400Sec) 00091 * time_t ctTime; 00092 * ctTime = time(NULL); 00093 * ctTime+=32400; 00094 * set_time(ctTime); 00095 * led2=1; 00096 * 00097 * //post 00098 * int i,j; 00099 * for (j=0; j<10; j++) { 00100 * //data initialize 00101 * time_t seconds = time(NULL); 00102 * for (i=0; i<2; i++) { 00103 * char data[5]; 00104 * int s=j*pow((double)10,i); 00105 * sprintf(data,"%03d",s); 00106 * element[i].value=data; 00107 * element[i].t=localtime(&seconds); 00108 * } 00109 * //do post 00110 * int ret=ieee1888.post(element,2); 00111 * if(ret!=0){ 00112 * while (1) { 00113 * led3=!led3; 00114 * wait(0.5); 00115 * } 00116 * return 0; 00117 * } 00118 * wait(1); 00119 * } 00120 * //finish 00121 * while (1) { 00122 * led4=!led4; 00123 * wait(0.5); 00124 * } 00125 * } 00126 *@endcode 00127 */ 00128 class FIAP { 00129 public: 00130 /** Create fiap object(for WRITE) 00131 * @param Storage FIAP Storage Addrees (ie. "http://fiap.org/axis2/services/FIAPStorage") 00132 * @param PointSetId Point Set ID(ie. http://test.fiap.jp/bldg_1/3F/) 00133 */ 00134 FIAP(char Storage[],char PointSetId[]); 00135 /** Create fiap object(for FETCH) 00136 * @param Storage FIAP Storage Addrees (ie. "http://fiap.org/axis2/services/FIAPStorage") 00137 */ 00138 FIAP(char Storage[]); 00139 00140 /** post 00141 * @param v data vaule 00142 * @param esize number of data 00143 */ 00144 int post(struct fiap_element* v, unsigned int esize); 00145 00146 /** fetch_maximum 00147 * @param cid Point ID s 00148 * @param v Return Values 00149 * @param esize <=2 00150 * @return network_error 00151 */ 00152 int fetch_last_data(struct fiap_element* v,unsigned int esize); 00153 int fetch_last_data(struct fiap_element * v); 00154 00155 /** debug_mode 00156 * Output XML and Error 00157 */ 00158 bool debug_mode; 00159 00160 private: 00161 char _fiap_storage[100]; 00162 char _fiap_id_prefix[100]; 00163 char _soap_header[256]; 00164 char _soap_footer[256]; 00165 char _soap_action[100]; 00166 void post_xml_initialize(void); 00167 void fetch_xml_initialize(void); 00168 }; 00169 00170 #endif
Generated on Thu Jul 14 2022 19:12:45 by 1.7.2