use TCP to connect to mbed connector
Fork of mbedConnectorInterfaceWithDM by
mbed-connector-interface/TickerResourceObserver.h@90:b738617379a6, 2016-11-28 (annotated)
- Committer:
- Maggie17
- Date:
- Mon Nov 28 15:52:56 2016 +0000
- Revision:
- 90:b738617379a6
- Parent:
- 54:dfee8691c83a
first release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:1f1f55e73248 | 1 | /** |
ansond | 0:1f1f55e73248 | 2 | * @file TickerResourceObserver.h |
ansond | 0:1f1f55e73248 | 3 | * @brief mbed CoAP DynamicResource Ticker-based observer (header) |
ansond | 0:1f1f55e73248 | 4 | * @author Doug Anson/Chris Paola |
ansond | 0:1f1f55e73248 | 5 | * @version 1.0 |
ansond | 0:1f1f55e73248 | 6 | * @see |
ansond | 0:1f1f55e73248 | 7 | * |
ansond | 0:1f1f55e73248 | 8 | * Copyright (c) 2014 |
ansond | 0:1f1f55e73248 | 9 | * |
ansond | 0:1f1f55e73248 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ansond | 0:1f1f55e73248 | 11 | * you may not use this file except in compliance with the License. |
ansond | 0:1f1f55e73248 | 12 | * You may obtain a copy of the License at |
ansond | 0:1f1f55e73248 | 13 | * |
ansond | 0:1f1f55e73248 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
ansond | 0:1f1f55e73248 | 15 | * |
ansond | 0:1f1f55e73248 | 16 | * Unless required by applicable law or agreed to in writing, software |
ansond | 0:1f1f55e73248 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
ansond | 0:1f1f55e73248 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ansond | 0:1f1f55e73248 | 19 | * See the License for the specific language governing permissions and |
ansond | 0:1f1f55e73248 | 20 | * limitations under the License. |
ansond | 0:1f1f55e73248 | 21 | */ |
ansond | 0:1f1f55e73248 | 22 | |
ansond | 0:1f1f55e73248 | 23 | #ifndef __TICKER_RESOURCE_OBSERVER_H__ |
ansond | 0:1f1f55e73248 | 24 | #define __TICKER_RESOURCE_OBSERVER_H__ |
ansond | 0:1f1f55e73248 | 25 | |
ansond | 33:1d0b855df5a5 | 26 | // mbedConnectorInterface configuration |
ansond | 33:1d0b855df5a5 | 27 | #include "mbed-connector-interface/mbedConnectorInterface.h" |
ansond | 0:1f1f55e73248 | 28 | |
ansond | 34:a10d65907549 | 29 | #ifdef CONNECTOR_USING_TICKER |
ansond | 34:a10d65907549 | 30 | |
ansond | 31:2507e64fcc42 | 31 | // mbed support |
ansond | 31:2507e64fcc42 | 32 | #if defined(MCI_USE_YOTTA) |
ansond | 31:2507e64fcc42 | 33 | // mbed support |
ansond | 31:2507e64fcc42 | 34 | #include "mbed-drivers/mbed.h" |
ansond | 31:2507e64fcc42 | 35 | #else |
ansond | 31:2507e64fcc42 | 36 | // mbed support |
ansond | 31:2507e64fcc42 | 37 | #include "mbed.h" |
ansond | 31:2507e64fcc42 | 38 | #endif |
ansond | 0:1f1f55e73248 | 39 | |
ansond | 0:1f1f55e73248 | 40 | // Base class support |
ansond | 31:2507e64fcc42 | 41 | #include "mbed-connector-interface/ResourceObserver.h" |
ansond | 0:1f1f55e73248 | 42 | |
ansond | 0:1f1f55e73248 | 43 | class TickerResourceObserver : public ResourceObserver { |
ansond | 0:1f1f55e73248 | 44 | public: |
ansond | 0:1f1f55e73248 | 45 | /** |
ansond | 0:1f1f55e73248 | 46 | Default Constructor |
ansond | 0:1f1f55e73248 | 47 | @param resource input the resource to observe |
ansond | 0:1f1f55e73248 | 48 | @param timer_id input the id for our timer (can be index value of each resource that is observed...) |
ansond | 0:1f1f55e73248 | 49 | @param sleep_time input the time for the observation tasklet to sleep (in whole seconds...) |
ansond | 0:1f1f55e73248 | 50 | */ |
ansond | 54:dfee8691c83a | 51 | TickerResourceObserver(DynamicResource *resource,int sleep_time = DEFAULT_OBS_PERIOD); |
ansond | 0:1f1f55e73248 | 52 | |
ansond | 0:1f1f55e73248 | 53 | /** |
ansond | 0:1f1f55e73248 | 54 | Copy Constructor |
ansond | 0:1f1f55e73248 | 55 | */ |
ansond | 0:1f1f55e73248 | 56 | TickerResourceObserver(const TickerResourceObserver &observer); |
ansond | 0:1f1f55e73248 | 57 | |
ansond | 0:1f1f55e73248 | 58 | /** |
ansond | 0:1f1f55e73248 | 59 | Destructor |
ansond | 0:1f1f55e73248 | 60 | */ |
ansond | 0:1f1f55e73248 | 61 | virtual ~TickerResourceObserver(); |
ansond | 0:1f1f55e73248 | 62 | |
ansond | 0:1f1f55e73248 | 63 | /** |
ansond | 0:1f1f55e73248 | 64 | begin the observation |
ansond | 0:1f1f55e73248 | 65 | */ |
ansond | 0:1f1f55e73248 | 66 | virtual void beginObservation(); |
ansond | 0:1f1f55e73248 | 67 | |
ansond | 0:1f1f55e73248 | 68 | /** |
ansond | 0:1f1f55e73248 | 69 | stop the observation |
ansond | 0:1f1f55e73248 | 70 | */ |
ansond | 0:1f1f55e73248 | 71 | virtual void stopObservation(); |
ansond | 0:1f1f55e73248 | 72 | |
ansond | 0:1f1f55e73248 | 73 | /** |
ansond | 0:1f1f55e73248 | 74 | tasklet invoke function (static) |
ansond | 0:1f1f55e73248 | 75 | */ |
ansond | 0:1f1f55e73248 | 76 | void observationNotifier(void); |
ansond | 54:dfee8691c83a | 77 | |
ansond | 54:dfee8691c83a | 78 | /** |
ansond | 54:dfee8691c83a | 79 | halt the underlying observer mechanism |
ansond | 54:dfee8691c83a | 80 | */ |
ansond | 54:dfee8691c83a | 81 | virtual void halt(); |
ansond | 0:1f1f55e73248 | 82 | |
ansond | 0:1f1f55e73248 | 83 | private: |
ansond | 0:1f1f55e73248 | 84 | Ticker m_ticker; |
ansond | 0:1f1f55e73248 | 85 | }; |
ansond | 0:1f1f55e73248 | 86 | |
ansond | 34:a10d65907549 | 87 | #endif // CONNECTOR_USING_TICKER |
ansond | 34:a10d65907549 | 88 | |
ansond | 0:1f1f55e73248 | 89 | #endif // __TICKER_RESOURCE_OBSERVER_H__ |