Ethernet-based network support for mbedConnectorInterface.

Dependencies:   libnsdl EthernetInterface mbed-rtos

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Revision:
4:c1fd1d5f18a1
Parent:
3:3e1ad8ab5071
Child:
7:ee88023ff81e
--- a/NSDL/nsdl_support.cpp	Mon Feb 02 07:02:04 2015 +0000
+++ b/NSDL/nsdl_support.cpp	Tue Feb 03 06:51:47 2015 +0000
@@ -14,6 +14,11 @@
 Endpoint nsp;
 UDPSocket server;
 
+char null_endpoint_name[] = "";
+char null_domain[] = "";
+uint8_t null_ep_type[] = "";
+uint8_t null_lifetime_ptr[] = "";
+
 void *nsdl_alloc(uint16_t size) {
     void *chunk = NULL;
     if (size > 0) chunk = malloc(size);
@@ -100,15 +105,16 @@
 
 void register_endpoint(bool init) {
     sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
-    endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t *)domain_name, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
     if (init) {
+        endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t *)domain_name, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
         if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
             DBG("NSP initial registration failed\r\n");
         else
             DBG("NSP initial registration OK\r\n");
     }
     else {
-        if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
+        endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t *)null_domain, (uint8_t*)null_endpoint_name, null_ep_type, null_lifetime_ptr);
+        if(sn_nsdl_update_registration(endpoint_ptr) != 0)
             DBG("NSP re-registration failed\r\n");
         else
             DBG("NSP re-registration OK\r\n");
@@ -157,9 +163,13 @@
 }
 
 void nsdl_set_nsp_address(void) {
+    char NSP_address_str[16];
+    
     /* Set nsp address for library */
-    DBG("NSP: libNsdl NSP_ADDRESS: %d.%d.%d.%d port: %d\r\n",NSP_address_bytes[0],NSP_address_bytes[1],NSP_address_bytes[2],NSP_address_bytes[3],nsp_port);
+    sprintf(NSP_address_str,"%d.%d.%d.%d",NSP_address_bytes[0],NSP_address_bytes[1],NSP_address_bytes[2],NSP_address_bytes[3]);
+    DBG("NSP: libNsdl NSP_ADDRESS: %s port: %d\r\n",NSP_address_str,nsp_port);
     set_NSP_address(NSP_address_bytes, nsp_port, SN_NSDL_ADDRESS_TYPE_IPV4);
+    nsp.set_address(NSP_address_str,nsp_port);
 }
 
 // NSP event loop - spawn a re-registration thread AFTER we have initially registered and begun event processing...