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 {
35     return handle_;
36   }
37 
38   virtual bool ReadRemoteVersionInformation() = 0;
39 
40   using Queue = common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder>;
41   using QueueUpEnd = common::BidiQueueEnd<BasePacketBuilder, PacketView<kLittleEndian>>;
42   using QueueDownEnd = common::BidiQueueEnd<PacketView<kLittleEndian>, BasePacketBuilder>;
43   virtual QueueUpEnd* GetAclQueueEnd() const;
44 
45   bool locally_initiated_{false};
46 
47  protected:
AclConnection(QueueUpEnd * queue_up_end,uint16_t handle)48   AclConnection(QueueUpEnd* queue_up_end, uint16_t handle) : queue_up_end_(queue_up_end), handle_(handle) {}
49   QueueUpEnd* queue_up_end_;
50   uint16_t handle_;
51 };
52 
53 }  // namespace acl_manager
54 }  // namespace hci
55 }  // namespace bluetooth
56