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.
Fork of mbedConnectorInterfaceV3 by
mbed-connector-interface/EventQueueResourceObserver.h@127:b4a661ff6fb9, 2017-09-26 (annotated)
- Committer:
- ansond
- Date:
- Tue Sep 26 16:01:31 2017 +0000
- Revision:
- 127:b4a661ff6fb9
- Parent:
- 126:f37e34daa100
minor re-ordering of FCC init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 125:4bf229bf14a3 | 1 | /** |
ansond | 125:4bf229bf14a3 | 2 | * @file EventQueueResourceObserver.h |
ansond | 125:4bf229bf14a3 | 3 | * @brief mbed CoAP DynamicResource EventQueue-based observer (header) |
ansond | 125:4bf229bf14a3 | 4 | * @author Doug Anson/Chris Paola |
ansond | 125:4bf229bf14a3 | 5 | * @version 1.0 |
ansond | 125:4bf229bf14a3 | 6 | * @see |
ansond | 125:4bf229bf14a3 | 7 | * |
ansond | 125:4bf229bf14a3 | 8 | * Copyright (c) 2017 |
ansond | 125:4bf229bf14a3 | 9 | * |
ansond | 125:4bf229bf14a3 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ansond | 125:4bf229bf14a3 | 11 | * you may not use this file except in compliance with the License. |
ansond | 125:4bf229bf14a3 | 12 | * You may obtain a copy of the License at |
ansond | 125:4bf229bf14a3 | 13 | * |
ansond | 125:4bf229bf14a3 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
ansond | 125:4bf229bf14a3 | 15 | * |
ansond | 125:4bf229bf14a3 | 16 | * Unless required by applicable law or agreed to in writing, software |
ansond | 125:4bf229bf14a3 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
ansond | 125:4bf229bf14a3 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ansond | 125:4bf229bf14a3 | 19 | * See the License for the specific language governing permissions and |
ansond | 125:4bf229bf14a3 | 20 | * limitations under the License. |
ansond | 125:4bf229bf14a3 | 21 | */ |
ansond | 125:4bf229bf14a3 | 22 | |
ansond | 125:4bf229bf14a3 | 23 | #ifndef __EVENT_QUEUE_RESOURCE_OBSERVER_H__ |
ansond | 125:4bf229bf14a3 | 24 | #define __EVENT_QUEUE_RESOURCE_OBSERVER_H__ |
ansond | 125:4bf229bf14a3 | 25 | |
ansond | 125:4bf229bf14a3 | 26 | // mbedConnectorInterface configuration |
ansond | 125:4bf229bf14a3 | 27 | #include "mbed-connector-interface/mbedConnectorInterface.h" |
ansond | 125:4bf229bf14a3 | 28 | |
ansond | 125:4bf229bf14a3 | 29 | #ifdef CONNECTOR_USING_EVENT_QUEUES |
ansond | 125:4bf229bf14a3 | 30 | |
ansond | 125:4bf229bf14a3 | 31 | // mbed support |
ansond | 125:4bf229bf14a3 | 32 | #include "mbed.h" |
ansond | 125:4bf229bf14a3 | 33 | #include "mbed_events.h" |
ansond | 125:4bf229bf14a3 | 34 | |
ansond | 125:4bf229bf14a3 | 35 | // Base class support |
ansond | 125:4bf229bf14a3 | 36 | #include "mbed-connector-interface/ResourceObserver.h" |
ansond | 125:4bf229bf14a3 | 37 | |
ansond | 125:4bf229bf14a3 | 38 | class EventQueueResourceObserver : public ResourceObserver { |
ansond | 125:4bf229bf14a3 | 39 | public: |
ansond | 125:4bf229bf14a3 | 40 | /** |
ansond | 125:4bf229bf14a3 | 41 | Default Constructor |
ansond | 125:4bf229bf14a3 | 42 | @param resource input the resource to observe |
ansond | 125:4bf229bf14a3 | 43 | @param sleep_time input the time for the observation thread to sleep (in ms) |
ansond | 125:4bf229bf14a3 | 44 | */ |
ansond | 125:4bf229bf14a3 | 45 | EventQueueResourceObserver(DynamicResource *resource,int sleep_time = DEFAULT_OBS_PERIOD); |
ansond | 125:4bf229bf14a3 | 46 | |
ansond | 125:4bf229bf14a3 | 47 | /** |
ansond | 125:4bf229bf14a3 | 48 | Destructor |
ansond | 125:4bf229bf14a3 | 49 | */ |
ansond | 125:4bf229bf14a3 | 50 | virtual ~EventQueueResourceObserver(); |
ansond | 125:4bf229bf14a3 | 51 | |
ansond | 125:4bf229bf14a3 | 52 | /** |
ansond | 125:4bf229bf14a3 | 53 | begin the observation |
ansond | 125:4bf229bf14a3 | 54 | */ |
ansond | 125:4bf229bf14a3 | 55 | virtual void beginObservation(); |
ansond | 125:4bf229bf14a3 | 56 | |
ansond | 125:4bf229bf14a3 | 57 | /** |
ansond | 125:4bf229bf14a3 | 58 | stop the observation |
ansond | 125:4bf229bf14a3 | 59 | */ |
ansond | 125:4bf229bf14a3 | 60 | virtual void stopObservation(); |
ansond | 125:4bf229bf14a3 | 61 | |
ansond | 125:4bf229bf14a3 | 62 | /** |
ansond | 126:f37e34daa100 | 63 | observation task method (static) |
ansond | 125:4bf229bf14a3 | 64 | */ |
ansond | 126:f37e34daa100 | 65 | static void observation_task(); |
ansond | 125:4bf229bf14a3 | 66 | |
ansond | 125:4bf229bf14a3 | 67 | /** |
ansond | 125:4bf229bf14a3 | 68 | halt the underlying observer mechanism |
ansond | 125:4bf229bf14a3 | 69 | */ |
ansond | 125:4bf229bf14a3 | 70 | virtual void halt(); |
ansond | 125:4bf229bf14a3 | 71 | |
ansond | 125:4bf229bf14a3 | 72 | private: |
ansond | 125:4bf229bf14a3 | 73 | EventQueue m_event_queue; |
ansond | 125:4bf229bf14a3 | 74 | int m_id; |
ansond | 125:4bf229bf14a3 | 75 | }; |
ansond | 125:4bf229bf14a3 | 76 | |
ansond | 125:4bf229bf14a3 | 77 | #endif // CONNECTOR_USING_EVENT_QUEUES |
ansond | 125:4bf229bf14a3 | 78 | |
ansond | 125:4bf229bf14a3 | 79 | #endif // __EVENT_QUEUE_RESOURCE_OBSERVER_H__ |