custom for >5 resources

Fork of mbedConnectorInterface by Doug Anson

Revision:
40:bb551b9f4522
Parent:
38:96d15287b6f9
Child:
41:fb12c88260ad
diff -r ecd93f60bd6a -r bb551b9f4522 api/TickerResourceObserver.cpp
--- a/api/TickerResourceObserver.cpp	Sat Apr 11 18:14:36 2015 +0000
+++ b/api/TickerResourceObserver.cpp	Sat Apr 11 18:33:21 2015 +0000
@@ -26,8 +26,9 @@
  extern "C" bool nsdl_endpoint_is_registered(void);
  
  // constructor
- TickerResourceObserver::TickerResourceObserver(DynamicResource *resource,uint8_t timer_id,int sleep_time) : 
-                                    ResourceObserver(resource,(int)(sleep_time/1000)), m_ticker_active(false) {
+ TickerResourceObserver::TickerResourceObserver(DynamicResource *resource,int sleep_time) : 
+                                    ResourceObserver(resource,(int)(sleep_time/1000)) {
+     this->setObserving(false);
  }
   
  // destructor
@@ -37,21 +38,20 @@
 
  // notifier
  void TickerResourceObserver::observationNotifier() {
-     if (this->isObserving() == true && this->getResource() != NULL && nsdl_endpoint_is_registered() == true && this->m_ticker_active == true) {
-         std::printf("Calling observe()...\r\n");
+     if (this->isObserving() == true && this->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
          this->getResource()->observe();
      }
  }
  
  // begin observing...
  void TickerResourceObserver::beginObservation() {
-     if (this->m_ticker_active == false) {
+     if (this->isObserving() == false) {
         this->m_ticker.attach(this,&TickerResourceObserver::observationNotifier,(float)this->getSleepTime());
-        this->m_ticker_active = true;
+        this->setObserving(true);
      }
  }
  
  // begin observing...
  void TickerResourceObserver::stopObservation() {
-     this->m_ticker_active = false;
+     this->setObserving(false);
  }
\ No newline at end of file