mbed Connector Interface simplification API on top of mbed-client
Fork of mbedConnectorInterfaceV3 by
NOTE:
This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!
Diff: source/DynamicResource.cpp
- Revision:
- 45:db754b994deb
- Parent:
- 44:7c73baf9f4c1
- Child:
- 54:dfee8691c83a
diff -r 7c73baf9f4c1 -r db754b994deb source/DynamicResource.cpp --- a/source/DynamicResource.cpp Wed Jun 15 19:40:08 2016 +0000 +++ b/source/DynamicResource.cpp Wed Jun 15 20:51:13 2016 +0000 @@ -121,7 +121,10 @@ // Create our Resource this->m_res = (M2MResource *)oim->createDynamicResourceInstance((char *)this->getObjName().c_str(),(char *)this->getResName().c_str(),(char *)this->m_res_type.c_str(),(int)this->m_type,this->m_observable); - if (this->m_res != NULL) { + if (this->m_res != NULL) { + // Record our Instance Number + this->setInstanceNumber(oim->getLastCreatedInstanceNumber()); + // perform an initial get() to initialize our data value this->setValue(this->get()); @@ -185,7 +188,7 @@ // PUT() check if ((op & M2MBase::PUT_ALLOWED) != 0) { string value = this->coapDataToString(this->m_res->value(),this->m_res->value_length()); - this->logger()->log("%s: Calling resource(PUT) with [%s]=[%s] invoked. type:%d",this->m_res_type.c_str(),this->getFullName().c_str(),value.c_str(),type); + this->logger()->log("%s: put(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),value.c_str()); this->put(value.c_str()); return 0; } @@ -200,12 +203,12 @@ int instance_id = (int)param->get_argument_object_instance_id(); String resource_name = param->get_argument_resource_name(); value = this->coapDataToString(param->get_argument_value(),param->get_argument_value_length()); - this->logger()->log("%s: post() (resource: [%s/%d/%s] value: [%s]) invoked. type: %d",this->m_res_type.c_str(),object_name.c_str(),instance_id,resource_name.c_str(),value.c_str(),type); + this->logger()->log("%s: post(%d) [%s/%d/%s]=[%s]) called.",this->m_res_type.c_str(),type,object_name.c_str(),instance_id,resource_name.c_str(),value.c_str()); } else { // use the resource value itself value = this->coapDataToString(this->m_res->value(),this->m_res->value_length()); - this->logger()->log("%s: post() (resource: [%s] value: [%s] invoked. type: %d",this->m_res_type.c_str(),this->getFullName().c_str(),value.c_str(),type); + this->logger()->log("%s: post(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),value.c_str()); } // invoke @@ -216,12 +219,12 @@ // POST() check if ((op & M2MBase::POST_ALLOWED) != 0) { if (args != NULL) { - this->logger()->log("%s: Calling resource(POST) with [%s]=[%s] invoked. type: %d",this->m_res_type.c_str(),this->getFullName().c_str(),(char *)args,type); + this->logger()->log("%s: post(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),(char *)args); this->post(args); } else { string value = this->coapDataToString(this->m_res->value(),this->m_res->value_length()); - this->logger()->log("%s: Calling resource(POST) with [%s]=[%s] invoked. type: %d",this->m_res_type.c_str(),this->getFullName().c_str(),value.c_str(),type); + this->logger()->log("%s: post(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),value.c_str()); this->post((void *)value.c_str()); } return 0; @@ -237,12 +240,12 @@ int instance_id = (int)param->get_argument_object_instance_id(); String resource_name = param->get_argument_resource_name(); string value = this->coapDataToString(param->get_argument_value(),param->get_argument_value_length()); - this->logger()->log("%s: delete() (resource: [%s/%d/%s] value: [%s]) invoked. type: %d",this->m_res_type.c_str(),object_name.c_str(),instance_id,resource_name.c_str(),value.c_str(),type); + this->logger()->log("%s: delete(%d) [%s/%d/%s]=[%s]) called.",this->m_res_type.c_str(),type,object_name.c_str(),instance_id,resource_name.c_str(),value.c_str()); } else { // use the resource value itself string value = this->coapDataToString(this->m_res->value(),this->m_res->value_length()); - this->logger()->log("%s: delete() (resource: [%s] value: [%s] invoked. type: %d",this->m_res_type.c_str(),this->getFullName().c_str(),value.c_str(),type); + this->logger()->log("%s: delete(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),value.c_str()); } // invoke @@ -253,12 +256,12 @@ // DELETE() check if ((op & M2MBase::DELETE_ALLOWED) != 0) { if (args != NULL) { - this->logger()->log("%s: Calling resource(DELETE) with [%s]=[%s] invoked. type: %d",this->m_res_type.c_str(),this->getFullName().c_str(),(char *)args,type); + this->logger()->log("%s: delete(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),(char *)args); this->del(args); } else { string value = this->coapDataToString(this->m_res->value(),this->m_res->value_length()); - this->logger()->log("%s: Calling resource(DELETE) with [%s]=[%s] invoked. type: %d",this->m_res_type.c_str(),this->getFullName().c_str(),value.c_str(),type); + this->logger()->log("%s: delete(%d) [%s]=[%s] called.",this->m_res_type.c_str(),type,this->getFullName().c_str(),value.c_str()); this->del((void *)value.c_str()); } }