IEEE1888 GateWay sample that handles only 1 sensor. This is older repository, see IEEE1888_MULTI_SENSOR_GW. The newer version can handle multiple sensors.

Dependencies:   EthernetInterface FiapV2 HTTPClientForSOAP NTPClient mbed-rtos mbed spxml

Fork of temp_FIAP by Yasushi TAUCHI

This program sends only *1* data to FIAP storage with IEEE1888 format.

The data represents temperature degree Celsius taken from LM35 at P20. The LM35 is temperature sensor made by National Semiconductor.

Note 1: Newer repository is available. IEEE1888 (FIAP) multi sensor gateway can handle multiple sensors.

NOTE 2: You should define 2 constants at least before using this program. The constants are FIAP_STORAGE and POINT_ID, contained in main.h file. And You can also define other constants in main.h .

from here, in Japanese. これは、IEEE1888 形式でデータを *1種類だけ* 送信するプログラムです。 このプログラムは、P20 に接続した温度センサー LM35 の値を送信します。

注意: 下記のリポジトリーのプログラムは、複数のセンサーのデータをまとめて送信したい場合を考慮した、新しい Version です。 IEEE1888 (FIAP) multi sensor gateway

また、使用前に、main.h ファイルの定数を定義する必要があります。 (少なくとも FIAP_STORAGE および POINT_ID の2つ )

/media/uploads/strysd/fiap_node.jpg

Revision:
10:51ef659414a9
Parent:
9:0d34968a5de1
Child:
11:6c8e791ea45d
--- a/main.cpp	Wed Feb 13 14:12:44 2013 +0000
+++ b/main.cpp	Thu Feb 14 03:20:38 2013 +0000
@@ -8,7 +8,7 @@
 NTPClient ntp;
 time_t ctTime;
 
-AnalogIn ain(p15);//censor
+AnalogIn ain(p20);//temperature censor
 
 DigitalOut led1(LED1);//NTP error
 DigitalOut led2(LED2);//sendFIAP
@@ -45,10 +45,15 @@
 
 void sendFIAP(void )
 {
-    ftemp=ain*330.0; //(3.3 * 100.0)
-    sprintf(atemp,"%4.1f",ftemp);
+    ftemp=ain*330.0; //(3.3v * 100.0)
     ctTime = time(NULL);
     t = *localtime(&ctTime);
+
+    sprintf(atemp,"%4.1f",ftemp);
+    if (DEBUG_MODE == false){
+        //instead of displaying FIAP protocol
+        printf("Time: %s , Temp: %s\n\r", ctime(&ctTime), atemp);
+    }
     element[0].value=atemp;
     element[0].year=this_year;
     element[0].month=this_month;
@@ -67,43 +72,43 @@
     //interval : 0.1 = 100ms
     //flipper.attach(&myflip, 0.1);
 
-//Ethernet Initialize
     eth.init(); //Use DHCP
     eth.connect();
-    printf("%s\r\n", eth.getIPAddress());
-    printf("Trying to update time...\r\n");
+    printf("IP: %s\r\n", eth.getIPAddress());
+    led1 = 1;
     if (ntp.setTime(NTP_SERVER) != 0) {
         printf("NTP Error\r\n");
-        led1 = 1;
         return -1;
     }
+    led1 = 0;
     time_t ctTime;
     ctTime = time(NULL);
     ctTime+= TIME_ZONE_SECONDS;
     set_time(ctTime);
     ctTime = time(NULL);
-    printf("Time is set to (JST): %s\r\n", ctime(&ctTime));
+    printf("Time: %s\r\n", ctime(&ctTime));
     t = *localtime(&ctTime);
     this_year=t.tm_year+1900;
     this_month=t.tm_mon+1;
     
     fiap.debug_mode=DEBUG_MODE;
-    exitTimer = WAIT_LAN_ERROR;
+    exitTimer = WAIT_LAN_ERROR_TIMES;
     while(exitTimer > 0) {
         led3 = spd;
         led4 = lnk;
         if (led4 == 1 || led3 == 1) {
             exitTimer--;
-            wait(2);
+            wait(WAIT_LAN_ERROR_SECONDS);
         } else {
             led2 = 1;
-            exitTimer = WAIT_LAN_ERROR;
+            exitTimer = WAIT_LAN_ERROR_TIMES;
             sendFIAP();
             led2 = 0;
-            wait(5);
+            wait(WAIT_NEXT_SEND);
         }
     }
     eth.disconnect();
     printf("Disconnected\r\n");
+    led1 = led2 = led3 = led4 = speed = link = 0;
     return -1;
 }
\ No newline at end of file