Doug Anson / mbedConnectorInterface

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Revision:
31:bacc63106754
Parent:
30:113c2a1d8db2
Child:
34:03a8cc428b8b
--- a/api/TaskletResourceObserver.h	Tue Apr 07 21:30:03 2015 +0000
+++ b/api/TaskletResourceObserver.h	Wed Apr 08 15:49:56 2015 +0000
@@ -26,13 +26,20 @@
 // Base class support
 #include "ResourceObserver.h"
 
+// Tasklet support under network_stubs.h in mbedEndpointNetwork
+#ifdef CONNECTOR_USING_TASKLETS
+    #include "network_stubs.h"
+#endif
+
 class TaskletResourceObserver : public ResourceObserver {
     public:
         /**
         Default Constructor
         @param resource input the resource to observe
+        @param timer_id input the id for our timer (can be index value of each resource that is observed...)
+        @param sleep_time input the time for the observation tasklet to sleep (in ms)
         */
-        TaskletResourceObserver(DynamicResource *resource);
+        TaskletResourceObserver(DynamicResource *resource,uint8_t timer_id, int sleep_time = NSP_RD_UPDATE_PERIOD);
         
         /**
         Copy Constructor
@@ -48,9 +55,43 @@
         begin the observation
         */
         virtual void beginObservation();
-    
+        
+        /**
+        stop the observation
+        */
+        virtual void stopObservation();
+        
+#ifdef CONNECTOR_USING_TASKLETS              
+        /**
+        tasklet invoke function (static)
+        */
+        static void _observation_notifier(arm_event_s *event);
+  
+        /**
+        set the current event
+        @param event input the current event
+        */
+        void setEvent(arm_event_s *event);
+#endif
+        
+        /**
+        start the tasklet timer
+        */
+        void startTimer();
+        
+        /**
+        get the tasklet timer ID
+        @return timer id
+        */
+        uint8_t getTimerID();
+
     private:
-        
+        int          m_tasklet_id;
+#ifdef CONNECTOR_USING_TASKLETS
+        arm_event_s *m_event;
+#endif
+        uint8_t      m_timer_id;
+        bool         m_timer_active;
 };
 
 #endif // __TASKLET_RESOURCE_OBSERVER_H__
\ No newline at end of file