mbed Connector Interface simplification API on top of mbed-client

Fork of mbedConnectorInterfaceV3 by Doug Anson

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!

Revision:
29:be035befb437
Parent:
27:b8aaf7dc7023
Child:
38:bb6d2be4d54c
--- a/source/ConnectorEndpoint.cpp	Tue Jun 14 04:22:23 2016 +0000
+++ b/source/ConnectorEndpoint.cpp	Tue Jun 14 05:54:20 2016 +0000
@@ -331,9 +331,24 @@
 
 // resource value updated
 void Endpoint::value_updated(M2MBase *base, M2MBase::BaseType type) {
-	this->logger()->log("Value Updated");
+	// Lookup the resource and invoke process() on it...
 	DynamicResource *target_res = this->lookupDynamicResource(base);
-	target_res->process(base->operation(),type);
+	if (target_res != NULL) {
+		// DEBUG
+		this->logger()->log("Value Updated (Custom Resource)");
+	
+		// its a custom resource...
+		target_res->process(base->operation(),type);
+	}
+	else {
+		// DEBUG
+		this->logger()->log("Value Updated (Device Manager)");
+		
+		// let DeviceManager handle it
+		((DeviceManager *)this->m_device_manager)->process(base,type);
+	}
+	
+	// CSI
 	if (this->m_csi != NULL) {
 		this->m_csi->value_updated((void *)this,(void *)base,(int)type);
 	}
@@ -341,18 +356,14 @@
 
 // lookup which DynamicResource cooresponds to a given M2MBase instance...
 DynamicResource *Endpoint::lookupDynamicResource(M2MBase *base) {
-	DynamicResource *res = NULL;
-	bool found = false;
 	const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
-    for(int i=0; i<(int)dynamic_resources->size() && found == false; ++i) {
-    	M2MBase *t = dynamic_resources->at(i)->getResource();
+    for(int i=0; i<(int)dynamic_resources->size(); ++i) {
+    	M2MBase *t = (M2MBase *)dynamic_resources->at(i)->getResource();
         if (t == base) {
-        	res = dynamic_resources->at(i);
-        	found = true;
+        	return dynamic_resources->at(i);
         }
     }	
-	
-	return res;
+	return NULL;
 }
 
 // build out the endpoint