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:
126:f37e34daa100
Parent:
125:4bf229bf14a3
--- a/source/TickerResourceObserver.cpp	Thu Jul 13 19:21:28 2017 +0000
+++ b/source/TickerResourceObserver.cpp	Thu Jul 13 20:43:26 2017 +0000
@@ -24,6 +24,9 @@
  #include "mbed-connector-interface/TickerResourceObserver.h"
  
  #ifdef CONNECTOR_USING_TICKER
+ 
+ // our instance
+ static void *_instance = NULL;
   
  // constructor
  TickerResourceObserver::TickerResourceObserver(DynamicResource *resource,int sleep_time) : ResourceObserver(resource,(int)(sleep_time/1000)) {
@@ -31,6 +34,9 @@
      
      // DEBUG
      this->logger()->log("TickerResourceObserver being used for %s (sleep_time: %d ms)",resource->getFullName().c_str(),sleep_time);
+     
+     // our instance
+     _instance = (void *)this;
  }
   
  // destructor
@@ -40,8 +46,9 @@
 
  // observation task method
  void TickerResourceObserver::observation_task() {
-     if (this->isObserving() == true && this->getResource() != NULL) {
-         DynamicResource *res = this->getResource();
+     TickerResourceObserver *me = (TickerResourceObserver *)_instance;
+     if (me != NULL && me->isObserving() == true && me->getResource() != NULL) {
+         DynamicResource *res = me->getResource();
          if (res != NULL && res->isRegistered() == true) {
              res->observe();
          }
@@ -51,7 +58,7 @@
  // begin observing...
  void TickerResourceObserver::beginObservation() {
      if (this->isObserving() == false) {
-        this->m_ticker.attach(this,&TickerResourceObserver::observationNotifier,(float)this->getSleepTime());
+        this->m_ticker.attach(this,&TickerResourceObserver::observation_task,(float)this->getSleepTime());
         this->setObserving(true);
      }
  }