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 "common/bidi_queue.h"
20 #include "hci/hci_packets.h"
21 
22 namespace bluetooth {
23 namespace hci {
24 namespace acl_manager {
25 
26 class AclConnection {
27 public:
AclConnection()28   AclConnection() : queue_up_end_(nullptr), handle_(0) {}
29   AclConnection(const AclConnection&) = delete;
30   AclConnection& operator=(const AclConnection&) = delete;
31 
32   virtual ~AclConnection() = default;
33 
GetHandle()34   uint16_t GetHandle() const { return handle_; }
35 
36   virtual bool ReadRemoteVersionInformation() = 0;
37 
38   using Queue = common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder>;
39   using QueueUpEnd = common::BidiQueueEnd<BasePacketBuilder, PacketView<kLittleEndian>>;
40   using QueueDownEnd = common::BidiQueueEnd<PacketView<kLittleEndian>, BasePacketBuilder>;
41   virtual QueueUpEnd* GetAclQueueEnd() const;
42 
43   bool locally_initiated_{false};
44 
45 protected:
AclConnection(QueueUpEnd * queue_up_end,uint16_t handle)46   AclConnection(QueueUpEnd* queue_up_end, uint16_t handle)
47       : queue_up_end_(queue_up_end), handle_(handle) {}
48   QueueUpEnd* queue_up_end_;
49   uint16_t handle_;
50 };
51 
52 }  // namespace acl_manager
53 }  // namespace hci
54 }  // namespace bluetooth
55