Sample program showing how to connect GR-PEACH into Watson IoT through mbed Connector and Watson's Connector Bridge

Dependencies:   AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ThreadedResourceObserver.h Source File

ThreadedResourceObserver.h

Go to the documentation of this file.
00001 /**
00002  * @file    ThreadedResourceObserver.h
00003  * @brief   mbed CoAP DynamicResource Thread-based observer (header)
00004  * @author  Doug Anson/Chris Paola
00005  * @version 1.0
00006  * @see
00007  *
00008  * Copyright (c) 2014
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  *
00014  *     http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022 
00023 #ifndef __THREADED_RESOURCE_OBSERVER_H__
00024 #define __THREADED_RESOURCE_OBSERVER_H__
00025 
00026 // mbedConnectorInterface configuration
00027 #include "mbed-connector-interface/mbedConnectorInterface.h"
00028 
00029 #ifdef CONNECTOR_USING_THREADS
00030 
00031 // mbed support
00032 #if defined(MCI_USE_YOTTA)
00033     // mbed support
00034     #include "mbed-drivers/mbed.h"
00035 #else
00036     // mbed support
00037     #include "mbed.h"
00038     #include "rtos.h"
00039 #endif
00040 
00041 // Base class support
00042 #include "mbed-connector-interface/ResourceObserver.h"
00043 
00044 class ThreadedResourceObserver : public ResourceObserver {
00045     public:
00046         /**
00047         Default Constructor
00048         @param resource input the resource to observe
00049         @param sleep_time input the time for the observation thread to sleep (in ms)
00050         */
00051         ThreadedResourceObserver(DynamicResource *resource,int sleep_time = DEFAULT_OBS_PERIOD);
00052                 
00053         /**
00054         Destructor
00055         */
00056         virtual ~ThreadedResourceObserver();
00057         
00058         /**
00059         begin the observation
00060         */
00061         virtual void beginObservation();
00062         
00063         /**
00064         stop the observation
00065         */
00066         virtual void stopObservation();
00067         
00068         /**
00069         thread task method
00070         */
00071         void observation_task();
00072         
00073         /**
00074         halt the underlying observer mechanism
00075         */
00076         virtual void halt();
00077         
00078     private: 
00079         Thread  m_observation_thread;
00080 };
00081 
00082 #endif // CONNECTOR_USING_THREADS
00083 
00084 #endif // __THREADED_RESOURCE_OBSERVER_H__