Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IoT_LED_demo ServoTest uWater_Project hackathon ... more
Revision 60:167e8f021e30, committed 2015-09-05
- Comitter:
- ansond
- Date:
- Sat Sep 05 20:14:22 2015 +0000
- Parent:
- 59:3b99f4901e85
- Child:
- 61:143beb6d8800
- Commit message:
- update to enable the Threaded (RTOS) based resources that are setup as time-based observers to control their own observation events...
Changed in this revision
--- a/api/DynamicResource.cpp Sat Jul 25 06:04:40 2015 +0000
+++ b/api/DynamicResource.cpp Sat Sep 05 20:14:22 2015 +0000
@@ -404,8 +404,20 @@
// default observe behavior
void DynamicResource::observe() {
+ this->observe(true);
+}
+
+// behavior controlled observe behavior
+void DynamicResource::observe(bool do_notify) {
if (this->m_observable == true) {
- this->notify(this->get());
+ if (do_notify) {
+ // get() and notify() --> time-based observationing
+ this->notify(this->get());
+ }
+ else {
+ // get() only (resource controls whether each iteration results in an observation or not...)
+ this->get();
+ }
}
}
--- a/api/DynamicResource.h Sat Jul 25 06:04:40 2015 +0000
+++ b/api/DynamicResource.h Sat Sep 05 20:14:22 2015 +0000
@@ -157,10 +157,15 @@
void setDataWrapper(DataWrapper *data_wrapper) { this->m_data_wrapper = data_wrapper; }
/**
- observe the resource
+ observe the resource (default)
*/
virtual void observe();
+ /**
+ observe the resource (controlled observing)
+ */
+ virtual void observe(bool do_notify);
+
protected:
int notify(uint8_t *data,int data_length);
DataWrapper *getDataWrapper() { return this->m_data_wrapper; }
--- a/api/ThreadedResourceObserver.cpp Sat Jul 25 06:04:40 2015 +0000
+++ b/api/ThreadedResourceObserver.cpp Sat Sep 05 20:14:22 2015 +0000
@@ -54,7 +54,7 @@
while(true) {
Thread::wait(me->getSleepTime());
if (me->isObserving() == true && me->getResource() != NULL && nsdl_endpoint_is_registered() == true) {
- me->getResource()->observe();
+ me->getResource()->observe(me->getResource()->implementsObservation());
//__threaded_led = !__threaded_led;
}
}
