1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "hci_hal.h" 20 #include "module.h" 21 22 namespace bluetooth::hal { 23 24 class ReadClockHandler { 25 public: 26 virtual ~ReadClockHandler() = default; 27 28 /// Report a measurement of the BT clock. 29 /// `timestamp` is the local time measured in microseconds, 30 /// `bt_clock` is the local BT clock measured @ 51.2 KHz (32 times the 31 /// BR/EDR packets rate), with precision 1/3200 Hz. 32 virtual void OnEvent(uint32_t timestamp, uint32_t bt_clock) = 0; 33 }; 34 35 class LinkClocker : public ::bluetooth::Module { 36 public: 37 static const ModuleFactory Factory; 38 39 void OnHciEvent(const HciPacket& packet); 40 41 static void Register(ReadClockHandler*); 42 static void Unregister(); 43 44 protected: 45 LinkClocker() = default; 46 ListDependencies(ModuleList *)47 void ListDependencies(ModuleList*) const override {} Start()48 void Start() override {} Stop()49 void Stop() override {} 50 ToString()51 std::string ToString() const override { 52 return std::string("LinkClocker"); 53 } 54 }; 55 56 } // namespace bluetooth::hal 57