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.
Dependencies: EthernetInterface FiapV2 HTTPClientForSOAP NTPClient mbed-rtos mbed spxml
Fork of FIAPHelloWorld by
Revision 1:e3d31b5dee7a, committed 2015-04-13
- Comitter:
- hogejun
- Date:
- Mon Apr 13 09:15:30 2015 +0000
- Parent:
- 0:0c7f2ea60a75
- Commit message:
- initial revision
Changed in this revision
diff -r 0c7f2ea60a75 -r e3d31b5dee7a EthernetInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Mon Apr 13 09:15:30 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
diff -r 0c7f2ea60a75 -r e3d31b5dee7a EthernetNetIf.lib --- a/EthernetNetIf.lib Sun Jan 01 14:46:02 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
diff -r 0c7f2ea60a75 -r e3d31b5dee7a Fiap/fiap.cpp
--- a/Fiap/fiap.cpp Sun Jan 01 14:46:02 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#include "fiap.h"
-#include "mbed.h"
-FIAP::FIAP(string Storage,string PointSetId) {
- debug_mode=false;
- _fiap_storage=Storage;
- _fiap_id_prefix=PointSetId;
-
- _soap_header ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- _soap_header += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
- _soap_header += "<soapenv:Body>";
- _soap_header += "<ns2:dataRQ xmlns:ns2=\"http://soap.fiap.org/\">";
- _soap_header += "<transport xmlns=\"http://gutp.jp/fiap/2009/11/\">";
- _soap_header += "<body>";
- _soap_header += "<pointSet id=\"" + _fiap_id_prefix +"\">";
-
- _soap_footer ="</pointSet>";
- _soap_footer+="</body>";
- _soap_footer+="</transport>";
- _soap_footer+="</ns2:dataRQ>";
- _soap_footer+="</soapenv:Body>";
- _soap_footer+="</soapenv:Envelope>";
- _soap_footer+="\r\n\r\n";
-}
-
-int FIAP::post(struct fiap_element* v, unsigned int esize) {
- HTTPClient http;
- int i;
- char requestBuffer[50];
- string _date_time;
- string _soap_text=_soap_header;
- for (i=0; i<esize; i++) {
- strftime(&requestBuffer[0],50,"%Y-%m-%dT%H:%M:%S.0000000",v[i].t);
- _soap_text += "<point id=\"";
- _soap_text += _fiap_id_prefix;
- _soap_text += v[i].cid;
- _soap_text += "\">";
- _soap_text += "<value time=\"";
- _soap_text += requestBuffer;
- _soap_text += v[i].timezone;
- _soap_text += "\">";
- _soap_text += v[i].value;
- _soap_text += "</value>";
- _soap_text += "</point>";
- }
- _soap_text += _soap_footer;
-if(debug_mode){
-printf(_soap_text.c_str());
-printf("<<< Request(end)\n");
-}
- http.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
- http.setRequestHeader("SOAPAction","\"http://soap.fiap.org/data\"");
- HTTPText InData;
- InData.set(_soap_text.c_str());
- HTTPText OutData;
- HTTPResult r = http.post(_fiap_storage.c_str(),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;
- }
-
- return 0;
-}
diff -r 0c7f2ea60a75 -r e3d31b5dee7a Fiap/fiap.h
--- a/Fiap/fiap.h Sun Jan 01 14:46:02 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-// IEEE1888 / FIAP Uploader Library for Arduino
-//
-// 2011/09/19 ver.1 H.Inoue & H.Ochiai
-// 2011/12/31 Ver.1 for mbed Y.Tauchi
-
-// --------- FIAP.h ---------
-#ifndef MBED_FIAP_H
-#define MBED_FIAP_H
-
-#include "mbed.h"
-#include "HTTPClient.h"
-
-// return code of post method
-#define FIAP_UPLOAD_OK 0 // Succeeded
-#define FIAP_UPLOAD_CONNFAIL 1 // Connection faild (Socket I/O error)
-#define FIAP_UPLOAD_DNSERR 2 // DNS error
-#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 cid Point ID
- *@param value Data
- *@param t DateTime
- *@param timezone Timezone ie JST="+09:00"
- */
-struct fiap_element {
- const char* cid; // Set PointID
- string value; // Set Value
- struct tm *t; // Set DateTime
- char* timezone; // Set Timezon JST="+09:00"
-};
-
-/** 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
- */
-class FIAP {
-public:
-/** Create fiap object
- * @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(string Storage,string PointSetId);
-
-/** post
- * @param v data vaule
- * @param esize number of data
- */
- int post(struct fiap_element* v, unsigned int esize);
-
-/** debug_mode
- * Output XML and Error
- */
-bool debug_mode;
-
-private:
- string _fiap_storage;
- string _fiap_id_prefix;
- string _soap_header;
- string _soap_footer;
-};
-
-#endif
diff -r 0c7f2ea60a75 -r e3d31b5dee7a FiapV2.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FiapV2.lib Mon Apr 13 09:15:30 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yueee_yt/code/FiapV2/#52e95ea60ec1
diff -r 0c7f2ea60a75 -r e3d31b5dee7a HTTPClient.lib --- a/HTTPClient.lib Sun Jan 01 14:46:02 2012 +0000 +++ b/HTTPClient.lib Mon Apr 13 09:15:30 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/HTTPClient/#d0be6af2d1db +http://mbed.org/users/yueee_yt/code/HTTPClientForSOAP/#e09afb9ca1cd
diff -r 0c7f2ea60a75 -r e3d31b5dee7a NTPClient.lib --- a/NTPClient.lib Sun Jan 01 14:46:02 2012 +0000 +++ b/NTPClient.lib Mon Apr 13 09:15:30 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/NTPClient/#7c3f1199256a +http://mbed.org/users/donatien/code/NTPClient/#881559865a93
diff -r 0c7f2ea60a75 -r e3d31b5dee7a main.cpp
--- a/main.cpp Sun Jan 01 14:46:02 2012 +0000
+++ b/main.cpp Mon Apr 13 09:15:30 2015 +0000
@@ -1,40 +1,49 @@
#include "mbed.h"
-#include "EthernetNetIf.h"
+#include "EthernetInterface.h"
#include "NTPClient.h"
#include "fiap.h"
-#define ntp_server "ntp server address"
+#define NtpServer "ntp.nict.jp"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
-EthernetNetIf eth;
+EthernetInterface eth;
NTPClient ntp;
-FIAP fiap("http://192.168.1.5/axis2/services/FIAPStorage","http://test.fiap.org/mbed_hello/");
+//FIAP fiap("http://192.168.1.5/axis2/services/FIAPStorage","http://test.fiap.org/mbed_hello/");
+FIAP fiap("http://192.168.1.3/axis2/services/FIAPStorage");
char timezone[] = "+09:00"; // JST
-struct fiap_element element[]={
- {"P1",NULL,NULL,timezone},
- {"P2",NULL,NULL,timezone},
+struct fiap_element element[]= {
+ {"P1",NULL,NULL,NULL,NULL,NULL,NULL,NULL,timezone},
+ {"P2",NULL,NULL,NULL,NULL,NULL,NULL,NULL,timezone},
};
+//struct fiap_element element[]={
+// {"P1",NULL,NULL,timezone},
+// {"P2",NULL,NULL,timezone},
+//};
+
int main() {
led1=led2=led3=led4=0;
fiap.debug_mode=true;
//EthernetNetIf initialize
- EthernetErr ethErr = eth.setup();
- if (ethErr) {
+// EthernetErr ethErr = eth.setup();
+ eth.init(); //Use DHCP
+ eth.connect();
+ //if (ethErr) {
// lcd.locate(0,1);
// lcd.printf("Error %d in setup.\n", ethErr);
- return -1;
- }
+ // return -1;
+ //}
led1=1;
//NTPClient initia,lize
- Host server(IpAddr(), 123, ntp_server);
- NTPResult Ntpr=ntp.setTime(server);
+ //Host server(IpAddr(), 123, ntp_server);
+ //NTPResult Ntpr=ntp.setTime(server);
+ ntp.setTime(NtpServer);
//UTC-->JST +9Hour(32400Sec)
time_t ctTime;
ctTime = time(NULL);
@@ -52,7 +61,15 @@
int s=j*pow((double)10,i);
sprintf(data,"%03d",s);
element[i].value=data;
- element[i].t=localtime(&seconds);
+ struct tm t = *localtime(&ctTime);
+ element[0].year=t.tm_year+1900;
+ element[0].month=t.tm_mon+1;
+ element[0].day=t.tm_mday;
+ element[0].hour=t.tm_hour;
+ element[0].minute=t.tm_min;
+ element[0].second=t.tm_sec;
+ fiap.post(element,1);
+// element[i].t=localtime(&seconds);
}
//do post
int ret=fiap.post(element,2);
diff -r 0c7f2ea60a75 -r e3d31b5dee7a mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Mon Apr 13 09:15:30 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#83895f30f8f2
diff -r 0c7f2ea60a75 -r e3d31b5dee7a mbed.bld --- a/mbed.bld Sun Jan 01 14:46:02 2012 +0000 +++ b/mbed.bld Mon Apr 13 09:15:30 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file
diff -r 0c7f2ea60a75 -r e3d31b5dee7a spxml.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spxml.lib Mon Apr 13 09:15:30 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/hlipka/code/spxml/#3fa97f2c0505
