Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ cc_binary(
"model/controller/acl_connection.h",
"model/controller/acl_connection_handler.cc",
"model/controller/acl_connection_handler.h",
"model/controller/bredr_controller.cc",
"model/controller/bredr_controller.h",
"model/controller/connection_handle.h",
"model/controller/controller_properties.cc",
"model/controller/controller_properties.h",
"model/controller/dual_mode_controller.cc",
"model/controller/dual_mode_controller.h",
"model/controller/le_acl_connection.cc",
"model/controller/le_acl_connection.h",
"model/controller/le_advertiser.cc",
"model/controller/le_advertiser.h",
"model/controller/link_layer_controller.cc",
"model/controller/link_layer_controller.h",
"model/controller/le_controller.cc",
"model/controller/le_controller.h",
"model/controller/sco_connection.cc",
"model/controller/sco_connection.h",
"model/controller/vendor_commands/csr.h",
Expand Down Expand Up @@ -117,14 +122,19 @@ cc_binary(
"model/controller/acl_connection.h",
"model/controller/acl_connection_handler.cc",
"model/controller/acl_connection_handler.h",
"model/controller/bredr_controller.cc",
"model/controller/bredr_controller.h",
"model/controller/connection_handle.h",
"model/controller/controller_properties.cc",
"model/controller/controller_properties.h",
"model/controller/dual_mode_controller.cc",
"model/controller/dual_mode_controller.h",
"model/controller/le_acl_connection.cc",
"model/controller/le_acl_connection.h",
"model/controller/le_advertiser.cc",
"model/controller/le_advertiser.h",
"model/controller/link_layer_controller.cc",
"model/controller/link_layer_controller.h",
"model/controller/le_controller.cc",
"model/controller/le_controller.h",
"model/controller/sco_connection.cc",
"model/controller/sco_connection.h",
"model/controller/vendor_commands/csr.h",
Expand Down
13 changes: 5 additions & 8 deletions model/controller/acl_connection.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The Android Open Source Project
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,16 +20,13 @@
#include <cstdint>

#include "packets/hci_packets.h"
#include "phy.h"

namespace rootcanal {
AclConnection::AclConnection(AddressWithType address, AddressWithType own_address,
AddressWithType resolved_address, Phy::Type phy_type,
AclConnection::AclConnection(uint16_t handle, Address address, Address own_address,
bluetooth::hci::Role role)
: address_(address),
own_address_(own_address),
resolved_address_(resolved_address),
type_(phy_type),
: handle(handle),
address(address),
own_address(own_address),
role_(role),
last_packet_timestamp_(std::chrono::steady_clock::now()),
timeout_(std::chrono::seconds(3)) {}
Expand Down
44 changes: 10 additions & 34 deletions model/controller/acl_connection.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The Android Open Source Project
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,33 +19,28 @@
#include <chrono>
#include <cstdint>

#include "hci/address_with_type.h"
#include "hci/address.h"
#include "packets/hci_packets.h"
#include "phy.h"

namespace rootcanal {

using ::bluetooth::hci::AddressWithType;
using bluetooth::hci::Address;

enum AclConnectionState {
kActiveMode,
kHoldMode,
kSniffMode,
};

// Model the connection of a device to the controller.
class AclConnection {
// Model the BR/EDR connection of a device to the controller.
class AclConnection final {
public:
AclConnection(AddressWithType address, AddressWithType own_address,
AddressWithType resolved_address, Phy::Type phy_type, bluetooth::hci::Role role);
const uint16_t handle;
const Address address;
const Address own_address;

virtual ~AclConnection() = default;

Phy::Type GetPhyType() const { return type_; }

AddressWithType GetAddress() const { return address_; }
AddressWithType GetOwnAddress() const { return own_address_; }
AddressWithType GetResolvedAddress() const { return resolved_address_; }
AclConnection(uint16_t handle, Address address, Address own_address, bluetooth::hci::Role role);
~AclConnection() = default;

void Encrypt();
bool IsEncrypted() const;
Expand All @@ -70,21 +65,7 @@ class AclConnection {
bool IsNearExpiring() const;
bool HasExpired() const;

// LE-ACL state.
void InitiatePhyUpdate() { initiated_phy_update_ = true; }
void PhyUpdateComplete() { initiated_phy_update_ = false; }
bool InitiatedPhyUpdate() const { return initiated_phy_update_; }
bluetooth::hci::PhyType GetTxPhy() const { return tx_phy_; }
bluetooth::hci::PhyType GetRxPhy() const { return rx_phy_; }
void SetTxPhy(bluetooth::hci::PhyType phy) { tx_phy_ = phy; }
void SetRxPhy(bluetooth::hci::PhyType phy) { rx_phy_ = phy; }

private:
AddressWithType address_;
AddressWithType own_address_;
AddressWithType resolved_address_;
Phy::Type type_{Phy::Type::BR_EDR};

// Reports the RSSI measured for the last packet received on
// this connection.
int8_t rssi_{0};
Expand All @@ -96,11 +77,6 @@ class AclConnection {
bluetooth::hci::Role role_{bluetooth::hci::Role::CENTRAL};
std::chrono::steady_clock::time_point last_packet_timestamp_;
std::chrono::steady_clock::duration timeout_;

// LE-ACL state.
bluetooth::hci::PhyType tx_phy_{bluetooth::hci::PhyType::LE_1M};
bluetooth::hci::PhyType rx_phy_{bluetooth::hci::PhyType::LE_1M};
bool initiated_phy_update_{false};
};

} // namespace rootcanal
Loading