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 "hci/acl_manager/acl_connection.h" 20 #include "hci/acl_manager/le_connection_management_callbacks.h" 21 #include "hci/address_with_type.h" 22 #include "hci/hci_packets.h" 23 #include "hci/le_acl_connection_interface.h" 24 25 namespace bluetooth { 26 namespace hci { 27 namespace acl_manager { 28 29 class LeAclConnection : public AclConnection { 30 public: 31 LeAclConnection(); 32 LeAclConnection( 33 std::shared_ptr<Queue> queue, 34 LeAclConnectionInterface* le_acl_connection_interface, 35 uint16_t handle, 36 AddressWithType local_address, 37 AddressWithType remote_address, 38 Role role); 39 ~LeAclConnection(); 40 GetLocalAddress()41 virtual AddressWithType GetLocalAddress() const { 42 return local_address_; 43 } 44 UpdateLocalAddress(AddressWithType address)45 virtual void UpdateLocalAddress(AddressWithType address) { 46 local_address_ = address; 47 } 48 GetRemoteAddress()49 virtual AddressWithType GetRemoteAddress() const { 50 return remote_address_; 51 } 52 GetRole()53 virtual Role GetRole() const { 54 return role_; 55 } 56 57 virtual void RegisterCallbacks(LeConnectionManagementCallbacks* callbacks, os::Handler* handler); 58 virtual void Disconnect(DisconnectReason reason); 59 60 virtual bool LeConnectionUpdate(uint16_t conn_interval_min, uint16_t conn_interval_max, uint16_t conn_latency, 61 uint16_t supervision_timeout, uint16_t min_ce_length, uint16_t max_ce_length); 62 63 virtual bool ReadRemoteVersionInformation() override; 64 65 // TODO implement LeRemoteConnectionParameterRequestReply, LeRemoteConnectionParameterRequestNegativeReply 66 67 // Called once before passing the connection to the client 68 virtual LeConnectionManagementCallbacks* GetEventCallbacks(); 69 70 private: 71 virtual bool check_connection_parameters( 72 uint16_t conn_interval_min, 73 uint16_t conn_interval_max, 74 uint16_t expected_conn_latency, 75 uint16_t expected_supervision_timeout); 76 struct impl; 77 struct impl* pimpl_ = nullptr; 78 AddressWithType local_address_; 79 AddressWithType remote_address_; 80 Role role_; 81 DISALLOW_COPY_AND_ASSIGN(LeAclConnection); 82 }; 83 84 } // namespace acl_manager 85 } // namespace hci 86 } // namespace bluetooth 87