6LowPAN mesh-based network support for mbedConnectorInterface. The Atmel-based mbed 6LowPAN shield is the assumed network hardware.

Dependencies:   libnsdl Nanostack_lib

Revision:
8:635a826f1de9
Parent:
7:0e80a25afabc
--- a/NSDL/nsdl_support.cpp	Thu Apr 09 03:07:58 2015 +0000
+++ b/NSDL/nsdl_support.cpp	Tue Apr 14 21:52:31 2015 +0000
@@ -179,21 +179,26 @@
 }
 
 void nsdl_reg_update()
-    {
+{
     sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
     // reg update should be invoked with null parameters if nothing is changing
     endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t *)null_ep_domain, (uint8_t*)null_ep_name, null_ep_type, null_lifetime_ptr);
-    if(sn_nsdl_update_registration(endpoint_ptr) != 0)
+    if(sn_nsdl_update_registration(endpoint_ptr) != 0) {
         DBG("NSP re-registering failed\r\n");
-    else
+        endpoint_registered = false;
+    }
+    else {
         DBG("NSP re-registering OK\r\n");
-    nsdl_clean_register_endpoint(&endpoint_ptr);
+        endpoint_registered = true;
     }
     
+    nsdl_clean_register_endpoint(&endpoint_ptr);
+}
+    
 void nsdl_reg_update_timeout()
-    {
+{
     nsdl_reg_update_needed = true;
-    }
+}
 
 void nsdl_event_loop()
 {
@@ -206,11 +211,18 @@
 
     while(1)
     {
-        //        pc.DBG("checking reg timeout\r\n");
+        //pc.DBG("checking reg timeout\r\n");
         if (nsdl_reg_update_needed)
         {
             nsdl_reg_update_needed = false;
-            nsdl_reg_update();
+            
+            if (nsdl_endpoint_is_registered()) 
+                nsdl_reg_update();
+            else
+                NSP_registration();
+            
+            // wait just a bit...    
+            //wait_ms(1000);
         }
     }
 }