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:
Thu Apr 09 03:00:47 2015 +0000
Parent:
12:f3f176463e7a
Child:
14:8655dff00fbf
Commit message:
updates

Changed in this revision

NSDL/nsdl_support.cpp Show annotated file Show diff for this revision Revisions of this file
NSDL/nsdl_support.h Show annotated file Show diff for this revision Revisions of this file
--- a/NSDL/nsdl_support.cpp	Wed Apr 08 23:08:58 2015 +0000
+++ b/NSDL/nsdl_support.cpp	Thu Apr 09 03:00:47 2015 +0000
@@ -22,6 +22,7 @@
 char null_domain[] = "";
 uint8_t null_ep_type[] = "";
 uint8_t null_lifetime_ptr[] = "";
+bool endpoint_registered = false;
 
 void *nsdl_alloc(uint16_t size) {
     void *chunk = NULL;
@@ -111,10 +112,14 @@
     sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
     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)
+        if(sn_nsdl_register_endpoint(endpoint_ptr) != 0) {
             DBG("NSP initial registration failed\r\n");
-        else
+            endpoint_registered = false;
+        }
+        else {
             DBG("NSP initial registration OK\r\n");
+            endpoint_registered = true;
+        }
     }
     else {
         endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t *)null_domain, (uint8_t*)null_endpoint_name, null_ep_type, null_lifetime_ptr);
@@ -126,6 +131,10 @@
     nsdl_clean_register_endpoint(&endpoint_ptr);
 }
 
+bool nsdl_endpoint_is_registered(void) {
+    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
--- a/NSDL/nsdl_support.h	Wed Apr 08 23:08:58 2015 +0000
+++ b/NSDL/nsdl_support.h	Thu Apr 09 03:00:47 2015 +0000
@@ -21,6 +21,7 @@
 extern int nsp_port;                                        // our MDS UDP port number
 extern uint8_t ep_type[NSP_ENDPOINT_TYPE_LENGTH];           // our NODE type
 extern uint8_t lifetime_ptr[NSP_LIFE_TIME_LENGTH];          // MDS lifetime
+extern bool    endpoint_registered;                         // endpoint has been registered
 
 // ************************* MDS CONFIGURATION *********************************
 
@@ -45,5 +46,6 @@
 extern "C" void register_endpoint(bool init);
 extern void registration_update_thread(void const *args);
 extern "C" void nsdl_set_nsp_address(void);
+extern "C" bool nsdl_endpoint_is_registered(void);
 
 #endif // __NSDL_SUPPORT_H__