custom for >5 resources

Fork of mbedConnectorInterface by Doug Anson

Revision:
56:aaf84e56c422
Parent:
54:6963bb4d0399
diff -r 3915ac238c5d -r aaf84e56c422 api/DynamicResource.cpp
--- a/api/DynamicResource.cpp	Tue Apr 14 16:59:29 2015 +0000
+++ b/api/DynamicResource.cpp	Tue Apr 14 22:29:53 2015 +0000
@@ -209,17 +209,26 @@
                 if (((Connector::Options *)this->getOptions())->enableGETObservationControl()) {  
                     // ResourceObserver
                     ResourceObserver *observer = (ResourceObserver *)this->m_observer;
-               
-                    // get observe start/stop value from received options list pointer
-                    uint8_t OBS_command = *received_coap_ptr->options_list_ptr->observe_ptr;
-                    if (OBS_command == START_OBS) {
-                        coap_res_ptr->options_list_ptr->observe_ptr = &this->m_obs_number;      // see nullify note below...
+                    
+                    // I think we have to check for a NULl reference first... then process possibly..
+                    if (received_coap_ptr->options_list_ptr->observe_ptr != NULL) {
+                        // get observe start/stop value from received options list pointer
+                        uint8_t OBS_command = *received_coap_ptr->options_list_ptr->observe_ptr;
+                        if (OBS_command == START_OBS) {
+                            coap_res_ptr->options_list_ptr->observe_ptr = &this->m_obs_number;      // see nullify note below...
+                            coap_res_ptr->options_list_ptr->observe_len = 1;
+                            this->m_obs_number++;
+                            if (observer != NULL) observer->beginObservation();
+                        }
+                        if (OBS_command == STOP_OBS) {
+                            if (observer != NULL) observer->stopObservation();
+                        }
+                    }
+                    else {
+                        // non-GET controlled observationing: simply fill in the observation requirements...
+                        coap_res_ptr->options_list_ptr->observe_ptr = &this->m_obs_number;          // see nullify note below...
                         coap_res_ptr->options_list_ptr->observe_len = 1;
                         this->m_obs_number++;
-                        if (observer != NULL) observer->beginObservation();
-                    }
-                    if (OBS_command == STOP_OBS) {
-                        if (observer != NULL) observer->stopObservation();
                     }
                 }
                 else {