use TCP to connect to mbed connector
Fork of mbedConnectorInterfaceWithDM by
Diff: source/DynamicResource.cpp
- Revision:
- 15:c11dbe4d354c
- Parent:
- 13:9edad7677211
- Child:
- 16:dffa38c3340f
diff -r d9ce4e56684e -r c11dbe4d354c source/DynamicResource.cpp --- a/source/DynamicResource.cpp Thu Jun 09 19:05:18 2016 +0000 +++ b/source/DynamicResource.cpp Fri Jun 10 17:09:56 2016 +0000 @@ -136,18 +136,18 @@ // For POST-enabled RESOURCES (only...), we must add a callback if ((this->m_res_mask & M2MBase::POST_ALLOWED) != 0) { - // add a callback for the execute function...we will just direct through process()... - //this->logger()->log("DynamicResource::bind(): Setting up POST execute callback function"); - this->m_res->set_execute_function(execute_callback(this, &DynamicResource::process_resource_post)); + // add a callback for the execute function...we will just direct through process()... + //this->logger()->log("DynamicResource::bind(): Setting up POST execute callback function"); + this->m_res->set_execute_function(execute_callback(this, &DynamicResource::process_resource_post)); } // DISABLE for now... #if 0 // For DELETE-enabled RESOURCES (only...), we must add a callback if ((this->m_res_mask & M2MBase::DELETE_ALLOWED) != 0) { - // add a callback for the execute function...we will just direct through process()... - //this->logger()->log("DynamicResource::bind(): Setting up DELETE execute callback function"); - this->m_res->set_execute_function(execute_callback(this, &DynamicResource::process_resource_delete)); + // add a callback for the execute function...we will just direct through process()... + //this->logger()->log("DynamicResource::bind(): Setting up DELETE execute callback function"); + this->m_res->set_execute_function(execute_callback(this, &DynamicResource::process_resource_delete)); } #endif } @@ -346,7 +346,7 @@ // default observe behavior void DynamicResource::observe() { - if (this->m_observable == true) { + if (this->m_observable == true /* && this->isRegistered() == true */) { this->notify(this->get()); } } @@ -401,3 +401,19 @@ return is_connected; } +// Determine if we are registered or not +bool DynamicResource::isRegistered() { + bool is_registered = false; + + if (this->isConnected() == true) { + // get our Endpoint + Connector::Endpoint *ep = (Connector::Endpoint *)this->m_endpoint; + if (ep != NULL) { + is_registered = ep->isRegistered(); + } + } + + // return our endpoint registration state + return is_registered; +} +