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 <cstdint>
20 #include <memory>
21 
22 #include "types/raw_address.h"
23 
24 namespace power_telemetry {
25 
26 struct PowerTelemetryImpl;
27 
28 class PowerTelemetry {
29  public:
30   PowerTelemetry();
31 
32   void RecordLogDataContainer();
33   void LogScanStarted();
34 
35   void LogHciCmdDetail();
36   void LogHciEvtDetail();
37 
38   void LogLinkDetails(uint16_t handle, const RawAddress& bdaddr,
39                       bool isConnected, bool is_acl_link);
40   void LogRxAclPktData(uint16_t len);
41   void LogTxAclPktData(uint16_t len);
42 
43   void LogChannelConnected(uint16_t psm, int32_t src_id, int32_t dst_id,
44                            const RawAddress& bd_addr);
45   void LogChannelDisconnected(uint16_t psm, int32_t src_id, int32_t dst_id,
46                               const RawAddress& bd_addr);
47   void LogRxBytes(uint16_t psm, int32_t src_id, int32_t dst_id,
48                   const RawAddress& bd_addr, int32_t num_bytes);
49   void LogTxBytes(uint16_t psm, int32_t src_id, int32_t dst_id,
50                   const RawAddress& bd_addr, int32_t num_bytes);
51 
52   void LogSniffStarted(uint16_t handle, const RawAddress& bdaddr);
53   void LogSniffStopped(uint16_t handle, const RawAddress& bdaddr);
54   void LogAclTxPowerLevel(uint16_t handle, uint8_t txPower);
55   void LogInqScanStarted();
56   void LogInqScanStopped();
57   void LogBleScan(uint16_t num_resps);
58   void LogBleAdvStarted();
59   void LogBleAdvStopped();
60 
61   void LogTxPower(void* res);
62   void LogTrafficData();
63 
64   void Dumpsys(int32_t fd);
65 
66   std::unique_ptr<PowerTelemetryImpl> pimpl_;
67 };
68 
69 PowerTelemetry& GetInstance();
70 
71 }  // namespace power_telemetry
72