Doug Anson / mbedEndpointNetwork

Dependencies:   libnsdl EthernetInterface mbed-rtos

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Sat Apr 11 21:14:37 2015 +0000
Parent:
15:dace8614ff9e
Child:
17:3bec96f0e572
Commit message:
clean ups

Changed in this revision

NSDL/nsdl_support.cpp Show annotated file Show diff for this revision Revisions of this file
configuration.h Show annotated file Show diff for this revision Revisions of this file
--- a/NSDL/nsdl_support.cpp	Sat Apr 11 17:23:28 2015 +0000
+++ b/NSDL/nsdl_support.cpp	Sat Apr 11 21:14:37 2015 +0000
@@ -117,16 +117,20 @@
             endpoint_registered = false;
         }
         else {
-            DBG("NSP initial registration OK\r\n");
+            //DBG("NSP initial registration OK\r\n");
             endpoint_registered = true;
         }
     }
     else {
+        endpoint_registered = false;
         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)
+        if(sn_nsdl_update_registration(endpoint_ptr) != 0) {
             DBG("NSP re-registration failed\r\n");
-        else
-            DBG("NSP re-registration OK\r\n");
+        }
+        else {
+            //DBG("NSP re-registration OK\r\n");
+            endpoint_registered = true;
+        }
     }
     nsdl_clean_register_endpoint(&endpoint_ptr);
 }
@@ -135,24 +139,10 @@
     return endpoint_registered;
 }
 
-void registration_update_thread(void const *args) {
-    int count = -1;
-    int registration_time = 15;      // about 30 seconds if iteration every 2 seconds
-    
-    // first we want to wait a bit... let the endpoint crank up...
-    Thread::wait(NSP_RD_UPDATE_PERIOD);   // wait about 30 seconds, then go ahead and start the re-registration interval...  
-                
-    // now loop this thread forever sleeping and re-registering at the right iteration.
+void registration_update_thread(void const *args) {    
     while(true) {
-        Thread::wait(MAIN_LOOP_SLEEP);
-        ++count;
-        if (count%registration_time == 0) {
-            // re-registration time!
-            count = 0;
-            DBG("NSP: (re)registering...\r\n");
-            register_endpoint(false);
-            DBG("NSP: (re)registering complete.\r\n");
-        }
+        Thread::wait(NSP_RD_UPDATE_PERIOD);
+        register_endpoint(false);
     }
 }
 
--- a/configuration.h	Sat Apr 11 17:23:28 2015 +0000
+++ b/configuration.h	Sat Apr 11 21:14:37 2015 +0000
@@ -3,6 +3,8 @@
 
 /************** Ethernet CONFIGURATION PARAMETERS  ************************/
 
+// we will use ThreadedResourceObserver
+#define CONNECTOR_USING_THREADS 1
 
 /************** Ethernet CONFIGURATION PARAMETERS  ************************/