1/* 2 * Copyright (C) Huawei Device Co., Ltd. 2023-2023. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef BLUETOOTH_TIMER_H 17#define BLUETOOTH_TIMER_H 18 19#include "timer.h" 20 21#ifdef __cplusplus 22extern "C" { 23#endif 24 25namespace OHOS { 26namespace Bluetooth { 27 28class BluetoothTimer { 29public: 30 using TimerCallback = std::function<void()>; 31 static constexpr uint32_t DEFAULT_TIMEROUT = 10000; // ms 32 33 static BluetoothTimer *GetInstance(void); 34 35 BluetoothTimer(); 36 ~BluetoothTimer(); 37 38 void Register(const TimerCallback &callback, uint32_t &outTimerId, uint32_t interval = DEFAULT_TIMEROUT); 39 void UnRegister(uint32_t timerId); 40 41private: 42 std::unique_ptr<Utils::Timer> timer_{nullptr}; 43}; 44 45} // namespace Bluetooth 46} // namespace OHOS 47#ifdef __cplusplus 48} 49#endif 50#endif