Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 462d2622 authored by Bill Schilit's avatar Bill Schilit Committed by Gerrit Code Review
Browse files

Merge "Allow specifying address with AddHciConnection." into main

parents 9999e28e 3155bca4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <optional>
#include <type_traits>  // for remove_extent_t
#include <utility>      // for move
#include <optional>

#include "include/phy.h"  // for Phy, Phy::Type
#include "log.h"
@@ -203,8 +204,9 @@ void TestModel::AddRemote(const std::string& server, int port, Phy::Type type) {
}

PhyDevice::Identifier TestModel::AddHciConnection(
    std::shared_ptr<HciDevice> device) {
  device->SetAddress(GenerateBluetoothAddress());
    std::shared_ptr<HciDevice> device, std::optional<Address> address) {
  // clients can specify BD_ADDR or have it set based on device_id.
  device->SetAddress(address.value_or(GenerateBluetoothAddress()));
  AddDevice(std::static_pointer_cast<Device>(device));

  INFO(device->id_, "Initialized device with address {}", device->GetAddress());
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <memory>      // for shared_ptr
#include <string>      // for string
#include <vector>      // for vector
#include <optional>

#include "hci/address.h"                       // for Address
#include "model/devices/hci_device.h"          // for HciDevice
@@ -84,8 +85,8 @@ class TestModel {
  // Handle incoming remote connections
  void AddLinkLayerConnection(std::shared_ptr<Device> dev, Phy::Type phy_type);
  // Add an HCI device, return its index
  PhyDevice::Identifier AddHciConnection(std::shared_ptr<HciDevice> dev);

  PhyDevice::Identifier AddHciConnection(std::shared_ptr<HciDevice> dev,
                                         std::optional<Address> address = {});
  // Handle closed remote connections (both hci & link layer)
  void OnConnectionClosed(PhyDevice::Identifier device_id, AsyncUserId user_id);