CoAP Device Server Client mit leshan Server

Dependencies:   EthernetInterface mbed-rtos mbed nsdl_lib

Fork of COAPmbed by smd.iotkit2.ch

Sandbox Server

Eclipse stellt einen Testserver unter http://leshan.eclipse.org/ zur Verfügung. Das Programm verbindet sich mit diesem und ist unter mbed-k64f... erreichbar.

Installation lokale Version leshan

wget https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar
java -jar ./leshan-server-demo.jar

cURL

Die Funktionen können mittels cURL oder Browser wie folgt getestet werden:

# Alle Clients abfragen (Antwort im JSON Format)
curl -X GET  http://localhost:8080/api/clients
                         
# Wert von LED2 abfragen (Antwort im text/plain Format)                      
curl -X GET  http://localhost:8080/api/clients/mbed-k64f-1234/10/0/2 
 
# Wert für LED2 setzen
curl -X GET -vvv http://localhost:8080/api/clients/mbed-k64f-1234/10/0/2 -H "Content-Type: text/plain" -d "10"
Revision:
19:7830976ac327
Parent:
18:17bdeb25e0a8
Child:
20:0db9b774aeb8
--- a/main.cpp	Fri Aug 07 13:11:37 2015 +0000
+++ b/main.cpp	Wed Aug 26 06:58:27 2015 +0000
@@ -24,9 +24,9 @@
 // ****************************************************************************
 // Server configuration
 /* Change this IP address to that of your NanoService Platform installation */
-static const char* NSP_ADDRESS = "leshan.eclipse.org"; /* Eclipse leshan Server */ 
+static const char* NSP_ADDRESS = "192.168.178.38"; /* Eclipse leshan Server */ 
 static const int NSP_PORT = 5683;
-char endpoint_name[] = "mbed-k64f-1234"; // aendern pro Node
+char endpoint_name[64] = "mbed-k64f-";   // wird ergaenzt um MAC Adresse
 uint8_t ep_type[] = {"mbed_device"};
 uint8_t lifetime_ptr[] = {"1200"};
 
@@ -45,14 +45,16 @@
     if(eth.connect(30000) == 0)
         pc.printf("Connect OK\n\r");
 
-    //mbed_interface_uid(mbed_uid); // -> Fehlt fuer K64F
-    //strcpy( mbed_uid, "k64f-1234" );
-    //mbed_uid[32] = '\0';
-    //strncat(endpoint_name, mbed_uid + 27, 15 - strlen(endpoint_name));
+    // Board Name + MAC = EndPoint Name
+    strcat( endpoint_name, eth.getMACAddress() );
 
-    printf("IP:%s", eth.getIPAddress());
-
-    NSDL_DEBUG("IP Address:%s ", eth.getIPAddress());
+    printf( "IP:%s", eth.getIPAddress() );
+    printf( "NetMask is %s\r\n", eth.getNetworkMask() );
+    printf( "Gateway Address is %s\r\n", eth.getGateway() );
+    printf( "MAC Address is %s\r\n", eth.getMACAddress() );    
+    printf( "Endpoint is %s\r\n", endpoint_name );
+    
+    NSDL_DEBUG("IP Address:%s ", eth.getIPAddress() );
 }
 
 // ****************************************************************************