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

Commit e0918375 authored by Myles Watson's avatar Myles Watson
Browse files

Rootcanal: Add SetDeviceAddress

Bug: 138260499
Test: manually run root-canal, open a test channel, set the address of a device
Change-Id: Ib851a9613c9f0ca10172f21a75788056e9968f7d
parent 38757349
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1319,4 +1319,8 @@ void DualModeController::HciWriteLoopbackMode(packets::PacketView<true> args) {
  SendCommandCompleteSuccess(OpCode::WRITE_LOOPBACK_MODE);
}

void DualModeController::SetAddress(Address address) {
  properties_.SetAddress(address);
}

}  // namespace test_vendor_lib
+3 −0
Original line number Diff line number Diff line
@@ -86,6 +86,9 @@ class DualModeController : public Device {

  void RegisterScoChannel(const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& send_sco);

  // Set the device's address.
  void SetAddress(Address address) override;

  // Controller commands. For error codes, see the Bluetooth Core Specification,
  // Version 4.2, Volume 2, Part D (page 370).

+4 −0
Original line number Diff line number Diff line
@@ -70,4 +70,8 @@ void Device::SendLinkLayerPacket(model::packets::LinkLayerPacketView to_send,
  }
}

void Device::SetAddress(Address) {
  LOG_INFO("%s does not implement %s", GetTypeString().c_str(), __func__);
}

}  // namespace test_vendor_lib
+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ class Device {
    return false;
  }

  // Set the device's Bluetooth address.
  virtual void SetAddress(Address address);

  // Set the advertisement interval in milliseconds.
  void SetAdvertisementInterval(std::chrono::milliseconds ms) {
    advertising_interval_ms_ = ms;
+17 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ TestCommandHandler::TestCommandHandler(TestModel& test_model) : model_(test_mode
  SET_HANDLER("add_device_to_phy", AddDeviceToPhy);
  SET_HANDLER("del_device_from_phy", DelDeviceFromPhy);
  SET_HANDLER("list", List);
  SET_HANDLER("set_device_address", SetDeviceAddress);
  SET_HANDLER("set_timer_period", SetTimerPeriod);
  SET_HANDLER("start_timer", StartTimer);
  SET_HANDLER("stop_timer", StopTimer);
@@ -212,6 +213,22 @@ void TestCommandHandler::List(const vector<std::string>& args) {
  send_response_(model_.List());
}

void TestCommandHandler::SetDeviceAddress(const vector<std::string>& args) {
  if (args.size() != 2) {
    response_string_ = "TestCommandHandler 'set_device_address' takes two arguments";
    send_response_(response_string_);
    return;
  }
  size_t device_id = std::stoi(args[0]);
  Address device_address;
  Address::FromString(args[1], device_address);
  model_.SetDeviceAddress(device_id, device_address);
  response_string_ = "set_device_address " + args[0];
  response_string_ += " ";
  response_string_ += args[1];
  send_response_(response_string_);
}

void TestCommandHandler::SetTimerPeriod(const vector<std::string>& args) {
  if (args.size() != 1) {
    LOG_INFO("SetTimerPeriod takes 1 argument");
Loading