nsp resources for the mbed nsp lighting endpoint
Dependencies: nsdl_lib
Dependents: mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet mbed_nsp_endpoint_nxp
Diff: nsdl_support.cpp
- Revision:
- 1:9824f99868a3
- Parent:
- 0:b26c3526ee89
- Child:
- 3:30c96bd77160
diff -r b26c3526ee89 -r 9824f99868a3 nsdl_support.cpp --- a/nsdl_support.cpp Wed Sep 17 15:24:11 2014 +0000 +++ b/nsdl_support.cpp Wed Sep 17 16:01:31 2014 +0000 @@ -14,7 +14,6 @@ char _endpoint_name[PERSONALITY_NAME_LEN+1]; uint8_t _ep_type[] = { NSP_NODE_TYPE }; uint8_t _lifetime_ptr[] = { NSP_NODE_LIFETIME }; -sn_nsdl_ep_parameters_s *endpoint_ptr = NULL; #include "MBEDEndpoint.h" extern MBEDEndpoint *endpoint; @@ -96,13 +95,8 @@ static uint8_t tx_cb(sn_nsdl_capab_e protocol, uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr) { //if (error_handler != NULL) error_handler->log("NSP: sending %d bytes...",data_len); -//#ifdef NETWORK_MUTEX -// if (network_mutex != NULL) network_mutex->lock(); -//#endif int sent = server.sendTo(nsp, (char*)data_ptr, data_len); -//#ifdef NETWORK_MUTEX -// if (network_mutex != NULL) network_mutex->unlock(); -//#endif + //if (error_handler != NULL) error_handler->log("NSP: send done. sent %d bytes...",sent); if (sent != data_len) { if (error_handler != NULL) error_handler->log("NSP: send failed!! Attempted: %d Sent: %d", data_len, sent); @@ -121,6 +115,7 @@ } static void register_endpoint(bool init) { + sn_nsdl_ep_parameters_s *endpoint_ptr = NULL; endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)_endpoint_name, _ep_type, _lifetime_ptr); sn_nsdl_update_registration(endpoint_ptr); nsdl_clean_register_endpoint(&endpoint_ptr); @@ -128,7 +123,7 @@ static void registration_update_thread(void const *args) { int count = 0; - int registration_time = 240; // about 1 minute assuming 4 iterations/second RD_UPDATE_PERIOD; + int registration_time = RD_UPDATE_PERIOD; // about 2.5 minutes assuming 4 iterations/second // first we want to wait a bit... let the endpoint crank up... Thread::wait(RD_UPDATE_PERIOD); // wait about 150 seconds, then go ahead and start the re-registration interval... @@ -195,13 +190,8 @@ // FOREVER: main loop for event processing while(true) { //if (error_handler != NULL) error_handler->log("NSP: waiting for data..."); -//#ifdef NETWORK_MUTEX -// if (network_mutex != NULL) network_mutex->lock(); -//#endif int n = server.receiveFrom(from,nsp_buffer,sizeof(nsp_buffer)); -//#ifdef NETWORK_MUTEX -// if (network_mutex != NULL) network_mutex->unlock(); -//#endif + //if (error_handler != NULL) error_handler->log("NSP: received %d bytes... processing...",n); if (n >= 0) sn_nsdl_process_coap((uint8_t*)nsp_buffer,n,&received_packet_address);