leo hendrickson / Mbed OS example-Ethernet-mbed-Cloud-connect
Committer:
leothedragon
Date:
Tue May 04 08:55:12 2021 +0000
Revision:
0:8f0bb79ddd48
nmn

Who changed what in which revision?

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