1 /*
2  * Copyright 2020 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 
21 #include "hci/hci_packets.h"
22 
23 namespace bluetooth {
24 namespace hci {
25 namespace acl_manager {
26 
27 class ConnectionManagementCallbacks {
28 public:
29   virtual ~ConnectionManagementCallbacks() = default;
30   // Invoked when controller sends Connection Packet Type Changed event with Success error code
31   virtual void OnConnectionPacketTypeChanged(uint16_t packet_type) = 0;
32   // Invoked when controller sends Authentication Complete event with Success error code
33   virtual void OnAuthenticationComplete(hci::ErrorCode hci_status) = 0;
34   // Invoked when controller sends Encryption Change event with Success error code
35   virtual void OnEncryptionChange(EncryptionEnabled enabled) = 0;
36   // Invoked when controller sends Change Connection Link Key Complete event with Success error code
37   virtual void OnChangeConnectionLinkKeyComplete() = 0;
38   // Invoked when controller sends Read Clock Offset Complete event with Success error code
39   virtual void OnReadClockOffsetComplete(uint16_t clock_offset) = 0;
40   // Invoked when controller sends Mode Change event with Success error code
41   virtual void OnModeChange(ErrorCode status, Mode current_mode, uint16_t interval) = 0;
42   // Invoked when controller sends Sniff Subrating event with Success error code
43   virtual void OnSniffSubrating(hci::ErrorCode hci_status, uint16_t maximum_transmit_latency,
44                                 uint16_t maximum_receive_latency, uint16_t minimum_remote_timeout,
45                                 uint16_t minimum_local_timeout) = 0;
46   // Invoked when controller sends QoS Setup Complete event with Success error code
47   virtual void OnQosSetupComplete(ServiceType service_type, uint32_t token_rate,
48                                   uint32_t peak_bandwidth, uint32_t latency,
49                                   uint32_t delay_variation) = 0;
50   // Invoked when controller sends Flow Specification Complete event with Success error code
51   virtual void OnFlowSpecificationComplete(FlowDirection flow_direction, ServiceType service_type,
52                                            uint32_t token_rate, uint32_t token_bucket_size,
53                                            uint32_t peak_bandwidth, uint32_t access_latency) = 0;
54   // Invoked when controller sends Flush Occurred event
55   virtual void OnFlushOccurred() = 0;
56   // Invoked when controller sends Command Complete event for Role Discovery command with Success
57   // error code
58   virtual void OnRoleDiscoveryComplete(Role current_role) = 0;
59   // Invoked when controller sends Command Complete event for Read Link Policy Settings command with
60   // Success error code
61   virtual void OnReadLinkPolicySettingsComplete(uint16_t link_policy_settings) = 0;
62   // Invoked when controller sends Command Complete event for Read Automatic Flush Timeout command
63   // with Success error code
64   virtual void OnReadAutomaticFlushTimeoutComplete(uint16_t flush_timeout) = 0;
65   // Invoked when controller sends Command Complete event for Read Transmit Power Level command with
66   // Success error code
67   virtual void OnReadTransmitPowerLevelComplete(uint8_t transmit_power_level) = 0;
68   // Invoked when controller sends Command Complete event for Read Link Supervision Time out command
69   // with Success error code
70   virtual void OnReadLinkSupervisionTimeoutComplete(uint16_t link_supervision_timeout) = 0;
71   // Invoked when controller sends Command Complete event for Read Failed Contact Counter command
72   // with Success error code
73   virtual void OnReadFailedContactCounterComplete(uint16_t failed_contact_counter) = 0;
74   // Invoked when controller sends Command Complete event for Read Link Quality command with Success
75   // error code
76   virtual void OnReadLinkQualityComplete(uint8_t link_quality) = 0;
77   // Invoked when controller sends Command Complete event for Read AFH Channel Map command with
78   // Success error code
79   virtual void OnReadAfhChannelMapComplete(AfhMode afh_mode,
80                                            std::array<uint8_t, 10> afh_channel_map) = 0;
81   // Invoked when controller sends Command Complete event for Read RSSI command with Success error
82   // code
83   virtual void OnReadRssiComplete(uint8_t rssi) = 0;
84   // Invoked when controller sends Command Complete event for Read Clock command with Success error
85   // code
86   virtual void OnReadClockComplete(uint32_t clock, uint16_t accuracy) = 0;
87   // Invoked when controller sends Central Link Key Complete event
88   virtual void OnCentralLinkKeyComplete(KeyFlag key_flag) = 0;
89   // Invoked when controller sends Role Change event
90   virtual void OnRoleChange(hci::ErrorCode hci_status, Role new_role) = 0;
91   // Invoked when controller sends DisconnectComplete
92   virtual void OnDisconnection(ErrorCode reason) = 0;
93   // Invoked when controller sends Read Remote Version Information Complete
94   virtual void OnReadRemoteVersionInformationComplete(hci::ErrorCode hci_status,
95                                                       uint8_t lmp_version,
96                                                       uint16_t manufacturer_name,
97                                                       uint16_t sub_version) = 0;
98   // Invoked when controller sends Read Remote Supported Features Complete
99   virtual void OnReadRemoteSupportedFeaturesComplete(uint64_t features) = 0;
100   // Invoked when controller sends Read Remote Extended Features Complete
101   virtual void OnReadRemoteExtendedFeaturesComplete(uint8_t page_number, uint8_t max_page_number,
102                                                     uint64_t features) = 0;
103 };
104 
105 }  // namespace acl_manager
106 }  // namespace hci
107 }  // namespace bluetooth
108