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 <memory> 20 21 #include "hci/acl_connection_interface.h" 22 #include "hci/acl_manager/acl_connection.h" 23 #include "hci/acl_manager/connection_management_callbacks.h" 24 #include "hci/hci_packets.h" 25 26 namespace bluetooth { 27 namespace hci { 28 namespace acl_manager { 29 30 class ClassicAclConnection : public AclConnection { 31 public: 32 ClassicAclConnection(); 33 ClassicAclConnection(std::shared_ptr<Queue> queue, AclConnectionInterface* acl_connection_interface, uint16_t handle, 34 Address address); 35 ClassicAclConnection(const ClassicAclConnection&) = delete; 36 ClassicAclConnection& operator=(const ClassicAclConnection&) = delete; 37 38 ~ClassicAclConnection(); 39 GetAddress()40 virtual Address GetAddress() const { 41 return address_; 42 } 43 44 virtual void RegisterCallbacks(ConnectionManagementCallbacks* callbacks, os::Handler* handler); 45 virtual bool Disconnect(DisconnectReason reason); 46 virtual bool ChangeConnectionPacketType(uint16_t packet_type); 47 virtual bool AuthenticationRequested(); 48 virtual bool SetConnectionEncryption(Enable enable); 49 virtual bool ChangeConnectionLinkKey(); 50 virtual bool ReadClockOffset(); 51 virtual bool HoldMode(uint16_t max_interval, uint16_t min_interval); 52 virtual bool SniffMode(uint16_t max_interval, uint16_t min_interval, uint16_t attempt, uint16_t timeout); 53 virtual bool ExitSniffMode(); 54 virtual bool QosSetup(ServiceType service_type, uint32_t token_rate, uint32_t peak_bandwidth, uint32_t latency, 55 uint32_t delay_variation); 56 virtual bool RoleDiscovery(); 57 virtual bool ReadLinkPolicySettings(); 58 virtual bool WriteLinkPolicySettings(uint16_t link_policy_settings); 59 virtual bool FlowSpecification(FlowDirection flow_direction, ServiceType service_type, uint32_t token_rate, 60 uint32_t token_bucket_size, uint32_t peak_bandwidth, uint32_t access_latency); 61 virtual bool SniffSubrating(uint16_t maximum_latency, uint16_t minimum_remote_timeout, 62 uint16_t minimum_local_timeout); 63 virtual bool Flush(); 64 virtual bool ReadAutomaticFlushTimeout(); 65 virtual bool WriteAutomaticFlushTimeout(uint16_t flush_timeout); 66 virtual bool ReadTransmitPowerLevel(TransmitPowerLevelType type); 67 virtual bool ReadLinkSupervisionTimeout(); 68 virtual bool WriteLinkSupervisionTimeout(uint16_t link_supervision_timeout); 69 virtual bool ReadFailedContactCounter(); 70 virtual bool ResetFailedContactCounter(); 71 virtual bool ReadLinkQuality(); 72 virtual bool ReadAfhChannelMap(); 73 virtual bool ReadRssi(); 74 virtual bool ReadClock(WhichClock which_clock); 75 virtual bool ReadRemoteVersionInformation() override; 76 virtual bool ReadRemoteSupportedFeatures(); 77 virtual bool ReadRemoteExtendedFeatures(uint8_t page_number); 78 79 // Called once before passing the connection to the client 80 virtual ConnectionManagementCallbacks* GetEventCallbacks(std::function<void(uint16_t)> invalidate_callbacks); 81 82 private: 83 AclConnectionInterface* acl_connection_interface_; 84 85 protected: 86 Address address_; 87 88 private: 89 struct impl; 90 struct impl* pimpl_ = nullptr; 91 }; 92 93 } // namespace acl_manager 94 } // namespace hci 95 } // namespace bluetooth 96