mbed client lightswitch demo
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-client/mbed-client/m2mtimer.h@11:cada08fc8a70, 2016-06-09 (annotated)
- Committer:
- mbedAustin
- Date:
- Thu Jun 09 17:08:36 2016 +0000
- Revision:
- 11:cada08fc8a70
Commit for public Consumption
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedAustin | 11:cada08fc8a70 | 1 | /* |
| mbedAustin | 11:cada08fc8a70 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
| mbedAustin | 11:cada08fc8a70 | 3 | * SPDX-License-Identifier: Apache-2.0 |
| mbedAustin | 11:cada08fc8a70 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| mbedAustin | 11:cada08fc8a70 | 5 | * not use this file except in compliance with the License. |
| mbedAustin | 11:cada08fc8a70 | 6 | * You may obtain a copy of the License at |
| mbedAustin | 11:cada08fc8a70 | 7 | * |
| mbedAustin | 11:cada08fc8a70 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| mbedAustin | 11:cada08fc8a70 | 9 | * |
| mbedAustin | 11:cada08fc8a70 | 10 | * Unless required by applicable law or agreed to in writing, software |
| mbedAustin | 11:cada08fc8a70 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| mbedAustin | 11:cada08fc8a70 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| mbedAustin | 11:cada08fc8a70 | 13 | * See the License for the specific language governing permissions and |
| mbedAustin | 11:cada08fc8a70 | 14 | * limitations under the License. |
| mbedAustin | 11:cada08fc8a70 | 15 | */ |
| mbedAustin | 11:cada08fc8a70 | 16 | #ifndef M2M_TIMER_H |
| mbedAustin | 11:cada08fc8a70 | 17 | #define M2M_TIMER_H |
| mbedAustin | 11:cada08fc8a70 | 18 | |
| mbedAustin | 11:cada08fc8a70 | 19 | #include <stdint.h> |
| mbedAustin | 11:cada08fc8a70 | 20 | #include "mbed-client/m2mtimerobserver.h" |
| mbedAustin | 11:cada08fc8a70 | 21 | |
| mbedAustin | 11:cada08fc8a70 | 22 | class M2MTimerPimpl; |
| mbedAustin | 11:cada08fc8a70 | 23 | |
| mbedAustin | 11:cada08fc8a70 | 24 | /** |
| mbedAustin | 11:cada08fc8a70 | 25 | * @brief M2MTimer. |
| mbedAustin | 11:cada08fc8a70 | 26 | * Timer class for mbed client. |
| mbedAustin | 11:cada08fc8a70 | 27 | */ |
| mbedAustin | 11:cada08fc8a70 | 28 | class M2MTimer |
| mbedAustin | 11:cada08fc8a70 | 29 | { |
| mbedAustin | 11:cada08fc8a70 | 30 | private: |
| mbedAustin | 11:cada08fc8a70 | 31 | // Prevents the use of assignment operator |
| mbedAustin | 11:cada08fc8a70 | 32 | M2MTimer& operator=(const M2MTimer& other); |
| mbedAustin | 11:cada08fc8a70 | 33 | |
| mbedAustin | 11:cada08fc8a70 | 34 | // Prevents the use of copy constructor |
| mbedAustin | 11:cada08fc8a70 | 35 | M2MTimer(const M2MTimer& other); |
| mbedAustin | 11:cada08fc8a70 | 36 | |
| mbedAustin | 11:cada08fc8a70 | 37 | public: |
| mbedAustin | 11:cada08fc8a70 | 38 | |
| mbedAustin | 11:cada08fc8a70 | 39 | /** |
| mbedAustin | 11:cada08fc8a70 | 40 | * Constructor. |
| mbedAustin | 11:cada08fc8a70 | 41 | */ |
| mbedAustin | 11:cada08fc8a70 | 42 | M2MTimer(M2MTimerObserver& observer); |
| mbedAustin | 11:cada08fc8a70 | 43 | |
| mbedAustin | 11:cada08fc8a70 | 44 | /** |
| mbedAustin | 11:cada08fc8a70 | 45 | * Destructor. |
| mbedAustin | 11:cada08fc8a70 | 46 | */ |
| mbedAustin | 11:cada08fc8a70 | 47 | virtual ~M2MTimer(); |
| mbedAustin | 11:cada08fc8a70 | 48 | |
| mbedAustin | 11:cada08fc8a70 | 49 | /** |
| mbedAustin | 11:cada08fc8a70 | 50 | * @brief Starts timer. |
| mbedAustin | 11:cada08fc8a70 | 51 | * @param interval Timer interval in milliseconds. |
| mbedAustin | 11:cada08fc8a70 | 52 | * @param single_shot Defines whether the timer is ticked once or restarted every time at expiry. |
| mbedAustin | 11:cada08fc8a70 | 53 | */ |
| mbedAustin | 11:cada08fc8a70 | 54 | void start_timer(uint64_t interval, M2MTimerObserver::Type type, bool single_shot = true); |
| mbedAustin | 11:cada08fc8a70 | 55 | |
| mbedAustin | 11:cada08fc8a70 | 56 | /** |
| mbedAustin | 11:cada08fc8a70 | 57 | * @brief Starts timer in DTLS manner. |
| mbedAustin | 11:cada08fc8a70 | 58 | * @param intermediate_interval Intermediate interval to use, must be smaller than total (usually 1/4 of total). |
| mbedAustin | 11:cada08fc8a70 | 59 | * @param total_interval Total interval to use; This is the timeout value of a DTLS packet. |
| mbedAustin | 11:cada08fc8a70 | 60 | * @param type Type of the timer. |
| mbedAustin | 11:cada08fc8a70 | 61 | */ |
| mbedAustin | 11:cada08fc8a70 | 62 | void start_dtls_timer(uint64_t intermediate_interval, uint64_t total_interval, M2MTimerObserver::Type type = M2MTimerObserver::Dtls); |
| mbedAustin | 11:cada08fc8a70 | 63 | |
| mbedAustin | 11:cada08fc8a70 | 64 | /** |
| mbedAustin | 11:cada08fc8a70 | 65 | * Stops timer. |
| mbedAustin | 11:cada08fc8a70 | 66 | * This cancels the ongoing timer. |
| mbedAustin | 11:cada08fc8a70 | 67 | */ |
| mbedAustin | 11:cada08fc8a70 | 68 | void stop_timer(); |
| mbedAustin | 11:cada08fc8a70 | 69 | |
| mbedAustin | 11:cada08fc8a70 | 70 | /** |
| mbedAustin | 11:cada08fc8a70 | 71 | * @brief Checks if the intermediate interval has passed. |
| mbedAustin | 11:cada08fc8a70 | 72 | * @return True if interval has passed, else false. |
| mbedAustin | 11:cada08fc8a70 | 73 | */ |
| mbedAustin | 11:cada08fc8a70 | 74 | bool is_intermediate_interval_passed(); |
| mbedAustin | 11:cada08fc8a70 | 75 | |
| mbedAustin | 11:cada08fc8a70 | 76 | /** |
| mbedAustin | 11:cada08fc8a70 | 77 | * @brief Checks if the total interval has passed. |
| mbedAustin | 11:cada08fc8a70 | 78 | * @return True if interval has passed, else false. |
| mbedAustin | 11:cada08fc8a70 | 79 | */ |
| mbedAustin | 11:cada08fc8a70 | 80 | bool is_total_interval_passed(); |
| mbedAustin | 11:cada08fc8a70 | 81 | |
| mbedAustin | 11:cada08fc8a70 | 82 | private: |
| mbedAustin | 11:cada08fc8a70 | 83 | |
| mbedAustin | 11:cada08fc8a70 | 84 | M2MTimerObserver& _observer; |
| mbedAustin | 11:cada08fc8a70 | 85 | M2MTimerPimpl *_private_impl; |
| mbedAustin | 11:cada08fc8a70 | 86 | friend class Test_M2MTimerImpl_linux; |
| mbedAustin | 11:cada08fc8a70 | 87 | }; |
| mbedAustin | 11:cada08fc8a70 | 88 | |
| mbedAustin | 11:cada08fc8a70 | 89 | #endif // M2M_TIMER_H |
Austin Blackstone
