mbed Connector Endpoint interface. This interface permits a mbed endpoint to easily setup MDS resources and emit those resources to an MDS server.

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Revision:
61:143beb6d8800
Parent:
60:167e8f021e30
--- a/api/ThreadedResourceObserver.cpp	Sat Sep 05 20:14:22 2015 +0000
+++ b/api/ThreadedResourceObserver.cpp	Sun Sep 06 03:16:02 2015 +0000
@@ -54,7 +54,16 @@
      while(true) {
          Thread::wait(me->getSleepTime());
          if (me->isObserving() == true && me->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
-             me->getResource()->observe(me->getResource()->implementsObservation());
+             //
+             // implementsObservation(): This switch denotes whether this threaded resource generates its own observations or relies on the heartbeat (time-based) mechanism.
+             //   -- if resource itself doesn't implement it, then we can call notify() with the get() on each heartbeat of the threaded resource (see note below)
+             //   -- otherwise, we let the resource itself call observe() as part of its observation implementation
+             //
+             // note: this is independent of whether the resource, when declared, is defined as an observable resource or not.  If not, then notify() wont be called 
+             //       as there will be no observations for this resource regardless of this switch value. 
+             //
+             bool do_notify = !(me->getResource()->implementsObservation());
+             me->getResource()->observe(do_notify);
              //__threaded_led = !__threaded_led;
          }
      }