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
Diff: api/TickerResourceObserver.cpp
- Revision:
- 61:143beb6d8800
- Parent:
- 44:dac601597b0e
diff -r 167e8f021e30 -r 143beb6d8800 api/TickerResourceObserver.cpp --- a/api/TickerResourceObserver.cpp Sat Sep 05 20:14:22 2015 +0000 +++ b/api/TickerResourceObserver.cpp Sun Sep 06 03:16:02 2015 +0000 @@ -44,7 +44,16 @@ // notifier void TickerResourceObserver::observationNotifier() { if (this->isObserving() == true && this->getResource() != NULL && nsdl_endpoint_is_registered() == true) { - this->getResource()->observe(); + // + // implementsObservation(): This switch denotes whether this ticker resource generates its own observations or relies on the ticker (time-based) mechanism. + // -- if resource itself doesn't implement it, then we can call notify() with the get() on each heartbeat of the tickered 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 = !(this->getResource()->implementsObservation()); + this->getResource()->observe(do_notify); //__ticker_led = !__ticker_led; } }