Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: temp_FIAP temp_FIAP_fetch tepco_demand BlueUSB_f_IEEE1888 ... more
Revision 3:7b144e1a52db, committed 2012-08-20
- Comitter:
- yueee_yt
- Date:
- Mon Aug 20 12:47:43 2012 +0000
- Parent:
- 2:2ba00be13585
- Child:
- 4:edbcc1833b58
- Commit message:
- fixed
Changed in this revision
| fiap.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/fiap.cpp Mon Aug 20 11:50:07 2012 +0000
+++ b/fiap.cpp Mon Aug 20 12:47:43 2012 +0000
@@ -83,53 +83,58 @@
//HTTPText InData("text/html", 800);
//InData.set(_soap_text);
HTTPText InData(_soap_text);
- char str[800];
- HTTPText stream(str,800);
+ char rstr[800];
+ HTTPText stream(rstr,800);
//stream.readNext((byte*)outBuffer,1500);
printf("post.start \n\r");
HTTPResult r = http.postXML(_fiap_storage,"http://soap.fiap.org/query",InData,&stream);
printf("post.end \n\r");
- if (r==HTTP_PROCESSING) {
- if (debug_mode)printf("Processing \n");
- return -1;
- }
- if (r==HTTP_PARSE) {
- if (debug_mode) printf("URI Parse error \n");
- return -1;
- }
- if (r==HTTP_DNS) {
- if (debug_mode) printf("Could not resolve name\n");
- return -1;
- }
- if (r==HTTP_PRTCL) {
- if (debug_mode)printf("Protocol error\n");
- return -1;
- }
- if (r==HTTP_NOTFOUND) {
- if (debug_mode)printf("HTTP 404 Error\n");
- return -1;
- }
- if (r==HTTP_REFUSED) {
- if (debug_mode) printf("HTTP 403 Error \n");
- return -1;
- }
- if (r==HTTP_ERROR) {
- if (debug_mode)printf("HTTP xxx error %d \n ",r);
- return -1;
- }
- if (r==HTTP_TIMEOUT) {
- if (debug_mode)printf("Connection timeout\n");
- return -1;
- }
- if (r==HTTP_CONN) {
- if (debug_mode)printf("Connection error\n");
- return -1;
+ if(!r) {
+ if (debug_mode)printf("Success \n");
+ } else {
+
+ if (r==HTTP_PROCESSING) {
+ if (debug_mode)printf("Processing \n");
+ return -1;
+ }
+ if (r==HTTP_PARSE) {
+ if (debug_mode) printf("URI Parse error \n");
+ return -1;
+ }
+ if (r==HTTP_DNS) {
+ if (debug_mode) printf("Could not resolve name\n");
+ return -1;
+ }
+ if (r==HTTP_PRTCL) {
+ if (debug_mode)printf("Protocol error\n");
+ return -1;
+ }
+ if (r==HTTP_NOTFOUND) {
+ if (debug_mode)printf("HTTP 404 Error\n");
+ return -1;
+ }
+ if (r==HTTP_REFUSED) {
+ if (debug_mode) printf("HTTP 403 Error \n");
+ return -1;
+ }
+ if (r==HTTP_ERROR) {
+ if (debug_mode)printf("HTTP xxx error %d \n ",r);
+ return -1;
+ }
+ if (r==HTTP_TIMEOUT) {
+ if (debug_mode)printf("Connection timeout\n");
+ return -1;
+ }
+ if (r==HTTP_CONN) {
+ if (debug_mode)printf("Connection error\n");
+ return -1;
+ }
}
SP_XmlNodeList * points;
- if (strlen(str)>0) {
+ if (strlen(rstr)>0) {
if (debug_mode)printf("\n\r data Get Ok\n\r");
SP_XmlDomParser parser;
- parser.append(str,strlen(str));
+ parser.append(rstr,strlen(rstr));
//stream.readNext((byte*)outBuffer,4096);
SP_XmlHandle rootHandle(parser.getDocument()->getRootElement());
SP_XmlHandle transport = rootHandle.getChild(0).getChild(0).getChild(0);
@@ -152,7 +157,6 @@
if (debug_mode) printf("PointID=%s \r\n",data_point_node->getAttrValue("id"));
if (debug_mode) printf("date=%s \r\n",data_value_node->getAttrValue("time"));
if (debug_mode) printf("data=%s \r\n",data_value_cnode->getText());
- //time_t second[50]={0};
for (ii=0; ii<esize; ii++) {
if (strcmp(v[ii].cid,data_point_node->getAttrValue("id"))==0) {
sprintf(str,"%s",data_value_node->getAttrValue("time"));
@@ -181,7 +185,7 @@
{
HTTPClient http;
int ll;
- char str[800];
+ char rstr[800];
fetch_xml_initialize();
strcpy(_soap_text, _soap_header);
sprintf(uuid,"%04x%04x-%04x-%04x-%04x-%04x%04x%04x",rand()%0x10000,rand()%0x10000,rand()%0x10000,rand()%1000|0x4000,rand()%0x1000|0x8000,rand()%0x10000,rand()%10000,(rand()+1)%0x10000);
@@ -203,55 +207,59 @@
// http.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
// http.setRequestHeader("SOAPAction","\"http://soap.fiap.org/query\"");
HTTPText InData(_soap_text);
- HTTPText stream(str,800);
+ HTTPText stream(rstr,800);
// stream.readNext((byte*)outBuffer,strlen(outBuffer));
printf("post.start \n\r");
HTTPResult r = http.postXML(_fiap_storage,"http://soap.fiap.org/query",InData,&stream);
printf("post.end \n\r");
- if (r==HTTP_PROCESSING) {
- if (debug_mode)printf("Processing \n");
- return -1;
- }
- if (r==HTTP_PARSE) {
- if (debug_mode) printf("URI Parse error \n");
- return -1;
- }
- if (r==HTTP_DNS) {
- if (debug_mode) printf("Could not resolve name\n");
- return -1;
- }
- if (r==HTTP_PRTCL) {
- if (debug_mode)printf("Protocol error\n");
- return -1;
- }
- if (r==HTTP_NOTFOUND) {
- if (debug_mode)printf("HTTP 404 Error\n");
- return -1;
- }
- if (r==HTTP_REFUSED) {
- if (debug_mode) printf("HTTP 403 Error \n");
- return -1;
- }
- if (r==HTTP_ERROR) {
- if (debug_mode)printf("HTTP xxx error %d \n ",r);
- return -1;
- }
- if (r==HTTP_TIMEOUT) {
- if (debug_mode)printf("Connection timeout\n");
- return -1;
- }
- if (r==HTTP_CONN) {
- if (debug_mode)printf("Connection error\n");
- return -1;
+ if(!r) {
+ if (debug_mode)printf("Success \n");
+ } else {
+ if (r==HTTP_PROCESSING) {
+ if (debug_mode)printf("Processing \n");
+ return -1;
+ }
+ if (r==HTTP_PARSE) {
+ if (debug_mode) printf("URI Parse error \n");
+ return -1;
+ }
+ if (r==HTTP_DNS) {
+ if (debug_mode) printf("Could not resolve name\n");
+ return -1;
+ }
+ if (r==HTTP_PRTCL) {
+ if (debug_mode)printf("Protocol error\n");
+ return -1;
+ }
+ if (r==HTTP_NOTFOUND) {
+ if (debug_mode)printf("HTTP 404 Error\n");
+ return -1;
+ }
+ if (r==HTTP_REFUSED) {
+ if (debug_mode) printf("HTTP 403 Error \n");
+ return -1;
+ }
+ if (r==HTTP_ERROR) {
+ if (debug_mode)printf("HTTP xxx error %d \n ",r);
+ return -1;
+ }
+ if (r==HTTP_TIMEOUT) {
+ if (debug_mode)printf("Connection timeout\n");
+ return -1;
+ }
+ if (r==HTTP_CONN) {
+ if (debug_mode)printf("Connection error\n");
+ return -1;
+ }
}
SP_XmlNodeList * points;
- if (strlen(str)>0) {
+ if (strlen(rstr)>0) {
if (debug_mode)printf("\n\r data Get Ok\n\r");
SP_XmlDomParser parser;
- // if (debug_mode)printf("stream readlen = %d \n\r",stream.readLen());
- // outBuffer[stream.readLen()]=0;
+ // if (debug_mode)printf("stream readlen = %d \n\r",stream.readLen());
+ // outBuffer[stream.readLen()]=0;
printf("check0\n\r");
- parser.append(str,strlen(str));
+ parser.append(rstr,strlen(rstr));
printf("check1\n\r");
SP_XmlHandle rootHandle(parser.getDocument()->getRootElement());
SP_XmlHandle transport = rootHandle.getChild(0).getChild(0).getChild(0);
@@ -328,41 +336,45 @@
HTTPText InData(_soap_text);
HTTPText OutData(str,800);
HTTPResult r = http.postXML(_fiap_storage,"http://soap.fiap.org/data",InData,&OutData);
- if (r==HTTP_PROCESSING) {
- if (debug_mode)printf("Processing \n");
- return -1;
- }
- if (r==HTTP_PARSE) {
- if (debug_mode) printf("URI Parse error \n");
- return -1;
- }
- if (r==HTTP_DNS) {
- if (debug_mode) printf("Could not resolve name\n");
- return -1;
- }
- if (r==HTTP_PRTCL) {
- if (debug_mode)printf("Protocol error\n");
- return -1;
- }
- if (r==HTTP_NOTFOUND) {
- if (debug_mode)printf("HTTP 404 Error\n");
- return -1;
- }
- if (r==HTTP_REFUSED) {
- if (debug_mode) printf("HTTP 403 Error \n");
- return -1;
- }
- if (r==HTTP_ERROR) {
- if (debug_mode)printf("HTTP xxx error \n");
- return -1;
- }
- if (r==HTTP_TIMEOUT) {
- if (debug_mode)printf("Connection timeout\n");
- return -1;
- }
- if (r==HTTP_CONN) {
- if (debug_mode)printf("Connection error\n");
- return -1;
+ if(!r) {
+ if (debug_mode)printf("Success \n");
+ } else {
+ if (r==HTTP_PROCESSING) {
+ if (debug_mode)printf("Processing \n");
+ return -1;
+ }
+ if (r==HTTP_PARSE) {
+ if (debug_mode) printf("URI Parse error \n");
+ return -1;
+ }
+ if (r==HTTP_DNS) {
+ if (debug_mode) printf("Could not resolve name\n");
+ return -1;
+ }
+ if (r==HTTP_PRTCL) {
+ if (debug_mode)printf("Protocol error\n");
+ return -1;
+ }
+ if (r==HTTP_NOTFOUND) {
+ if (debug_mode)printf("HTTP 404 Error\n");
+ return -1;
+ }
+ if (r==HTTP_REFUSED) {
+ if (debug_mode) printf("HTTP 403 Error \n");
+ return -1;
+ }
+ if (r==HTTP_ERROR) {
+ if (debug_mode)printf("HTTP xxx error \n");
+ return -1;
+ }
+ if (r==HTTP_TIMEOUT) {
+ if (debug_mode)printf("Connection timeout\n");
+ return -1;
+ }
+ if (r==HTTP_CONN) {
+ if (debug_mode)printf("Connection error\n");
+ return -1;
+ }
}
return 0;
}
\ No newline at end of file