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:
17:8ee737f79492
Parent:
16:b27c9d2b1a98
Child:
18:17bdeb25e0a8
diff -r b27c9d2b1a98 -r 8ee737f79492 main.cpp
--- a/main.cpp	Sun Jun 21 12:42:38 2015 +0000
+++ b/main.cpp	Sun Jun 21 13:06:42 2015 +0000
@@ -13,8 +13,10 @@
 PwmOutResource led2( D12, "led2", "10/0/1" );
 PwmOutResource led3( D13, "led3", "10/0/2" );
 
-char *staticResources[2] [3] = { { "3/0/0", "Manufacturer", "mc-b" },
+char *staticResources[4] [3] = { { "3/0/0", "Manufacturer", "mc-b" },
                                  { "3/0/1", "Model Number", "CoAP mbed device" },
+                                 { "5/0/3", "Firmware", "1" },
+                                 { "6/0/0", "GPS Informationen", "67,21" },
                                };
 
 Serial pc(USBTX, USBRX); // tx, rx
@@ -101,6 +103,11 @@
                                                (uint8_t*) staticResources[0] [2], strlen(staticResources[0] [2]) );
     nsdl_create_static_resource( resource_ptr, strlen(staticResources[1] [0]), (uint8_t*) staticResources[1] [0], 0, 0, 
                                                (uint8_t*) staticResources[1] [2], strlen(staticResources[1] [2]) );
+                                               
+    nsdl_create_static_resource( resource_ptr, strlen(staticResources[2] [0]), (uint8_t*) staticResources[2] [0], 0, 0, 
+                                               (uint8_t*) staticResources[2] [2], strlen(staticResources[2] [2]) );
+    nsdl_create_static_resource( resource_ptr, strlen(staticResources[3] [0]), (uint8_t*) staticResources[3] [0], 0, 0, 
+                                               (uint8_t*) staticResources[3] [2], strlen(staticResources[3] [2]) );                                               
 
     // Dynamic resources
     led1.create( resource_ptr );