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

Commit 33018ef6 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Reorder commands in dual mode controller

Better match the declaration order in the specification.

Bug: 279665786
Test: m root-canal
Change-Id: I712212665a7518ed0b8abb1151955fd4005d7dba
parent 9989e262
Loading
Loading
Loading
Loading
+39 −37
Original line number Original line Diff line number Diff line
@@ -87,15 +87,6 @@ void DualModeController::ForwardToLl(CommandView command) {
  link_layer_controller_.ForwardToLl(command);
  link_layer_controller_.ForwardToLl(command);
}
}


void DualModeController::SniffSubrating(CommandView command) {
  auto command_view = bluetooth::hci::SniffSubratingView::Create(command);
  ASSERT(command_view.IsValid());

  send_event_(bluetooth::hci::SniffSubratingCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS,
      command_view.GetConnectionHandle()));
}

void DualModeController::HandleAcl(
void DualModeController::HandleAcl(
    std::shared_ptr<std::vector<uint8_t>> packet) {
    std::shared_ptr<std::vector<uint8_t>> packet) {
  bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(packet);
  bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(packet);
@@ -292,14 +283,13 @@ void DualModeController::RegisterIsoChannel(
void DualModeController::Reset(CommandView command) {
void DualModeController::Reset(CommandView command) {
  auto command_view = bluetooth::hci::ResetView::Create(command);
  auto command_view = bluetooth::hci::ResetView::Create(command);
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
  link_layer_controller_.Reset();
  if (loopback_mode_ == LoopbackMode::ENABLE_LOCAL) {
    loopback_mode_ = LoopbackMode::NO_LOOPBACK;
  }


  DEBUG(id_, "<< Reset");
  DEBUG(id_, "<< Reset");


  link_layer_controller_.Reset();
  loopback_mode_ = LoopbackMode::NO_LOOPBACK;
  controller_reset_ = true;
  controller_reset_ = true;

  send_event_(bluetooth::hci::ResetCompleteBuilder::Create(kNumCommandPackets,
  send_event_(bluetooth::hci::ResetCompleteBuilder::Create(kNumCommandPackets,
                                                           ErrorCode::SUCCESS));
                                                           ErrorCode::SUCCESS));
}
}
@@ -1194,6 +1184,17 @@ void DualModeController::ReadAuthenticationEnable(CommandView command) {
          link_layer_controller_.GetAuthenticationEnable())));
          link_layer_controller_.GetAuthenticationEnable())));
}
}


void DualModeController::ReadClassOfDevice(CommandView command) {
  auto command_view = bluetooth::hci::ReadClassOfDeviceView::Create(command);
  ASSERT(command_view.IsValid());

  DEBUG(id_, "<< Read Class of Device");

  send_event_(bluetooth::hci::ReadClassOfDeviceCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS,
      link_layer_controller_.GetClassOfDevice()));
}

void DualModeController::WriteClassOfDevice(CommandView command) {
void DualModeController::WriteClassOfDevice(CommandView command) {
  auto command_view = bluetooth::hci::WriteClassOfDeviceView::Create(command);
  auto command_view = bluetooth::hci::WriteClassOfDeviceView::Create(command);
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
@@ -1346,6 +1347,18 @@ void DualModeController::WriteDefaultLinkPolicySettings(CommandView command) {
          kNumCommandPackets, status));
          kNumCommandPackets, status));
}
}


void DualModeController::SniffSubrating(CommandView command) {
  auto command_view = bluetooth::hci::SniffSubratingView::Create(command);
  ASSERT(command_view.IsValid());
  uint16_t connection_handle = command_view.GetConnectionHandle();

  DEBUG(id_, "<< Sniff Subrating");
  DEBUG(id_, "   connection_handle=0x{:x}", connection_handle);

  send_event_(bluetooth::hci::SniffSubratingCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, connection_handle));
}

void DualModeController::FlowSpecification(CommandView command) {
void DualModeController::FlowSpecification(CommandView command) {
  auto command_view = bluetooth::hci::FlowSpecificationView::Create(command);
  auto command_view = bluetooth::hci::FlowSpecificationView::Create(command);
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
@@ -1451,8 +1464,8 @@ void DualModeController::WriteExtendedInquiryResponse(CommandView command) {


  DEBUG(id_, "<< Write Extended Inquiry Response");
  DEBUG(id_, "<< Write Extended Inquiry Response");


  link_layer_controller_.SetExtendedInquiryResponse(std::vector<uint8_t>(
  link_layer_controller_.SetExtendedInquiryResponse(
      command_view.GetPayload().begin() + 1, command_view.GetPayload().end()));
      command_view.GetExtendedInquiryResponse());
  send_event_(
  send_event_(
      bluetooth::hci::WriteExtendedInquiryResponseCompleteBuilder::Create(
      bluetooth::hci::WriteExtendedInquiryResponseCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS));
          kNumCommandPackets, ErrorCode::SUCCESS));
@@ -1473,6 +1486,17 @@ void DualModeController::RefreshEncryptionKey(CommandView command) {
      ErrorCode::SUCCESS, handle));
      ErrorCode::SUCCESS, handle));
}
}


void DualModeController::ReadVoiceSetting(CommandView command) {
  auto command_view = bluetooth::hci::ReadVoiceSettingView::Create(command);
  ASSERT(command_view.IsValid());

  DEBUG(id_, "<< Read Voice Setting");

  send_event_(bluetooth::hci::ReadVoiceSettingCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS,
      link_layer_controller_.GetVoiceSetting()));
}

void DualModeController::WriteVoiceSetting(CommandView command) {
void DualModeController::WriteVoiceSetting(CommandView command) {
  auto command_view = bluetooth::hci::WriteVoiceSettingView::Create(command);
  auto command_view = bluetooth::hci::WriteVoiceSettingView::Create(command);
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
@@ -3150,28 +3174,6 @@ void DualModeController::LeLongTermKeyRequestNegativeReply(
          kNumCommandPackets, status, handle));
          kNumCommandPackets, status, handle));
}
}


void DualModeController::ReadClassOfDevice(CommandView command) {
  auto command_view = bluetooth::hci::ReadClassOfDeviceView::Create(command);
  ASSERT(command_view.IsValid());

  DEBUG(id_, "<< Read Class of Device");

  send_event_(bluetooth::hci::ReadClassOfDeviceCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS,
      link_layer_controller_.GetClassOfDevice()));
}

void DualModeController::ReadVoiceSetting(CommandView command) {
  auto command_view = bluetooth::hci::ReadVoiceSettingView::Create(command);
  ASSERT(command_view.IsValid());

  DEBUG(id_, "<< Read Voice Setting");

  send_event_(bluetooth::hci::ReadVoiceSettingCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS,
      link_layer_controller_.GetVoiceSetting()));
}

void DualModeController::ReadConnectionAcceptTimeout(CommandView command) {
void DualModeController::ReadConnectionAcceptTimeout(CommandView command) {
  auto command_view =
  auto command_view =
      bluetooth::hci::ReadConnectionAcceptTimeoutView::Create(command);
      bluetooth::hci::ReadConnectionAcceptTimeoutView::Create(command);
+30 −87
Original line number Original line Diff line number Diff line
@@ -134,9 +134,6 @@ class DualModeController : public Device {
  // 7.1.19
  // 7.1.19
  void RemoteNameRequest(CommandView command);
  void RemoteNameRequest(CommandView command);


  // 7.2.8
  void SwitchRole(CommandView command);

  // 7.1.21
  // 7.1.21
  void ReadRemoteSupportedFeatures(CommandView command);
  void ReadRemoteSupportedFeatures(CommandView command);


@@ -182,6 +179,9 @@ class DualModeController : public Device {
  // 7.2.7
  // 7.2.7
  void RoleDiscovery(CommandView command);
  void RoleDiscovery(CommandView command);


  // 7.2.8
  void SwitchRole(CommandView command);

  // 7.2.9
  // 7.2.9
  void ReadLinkPolicySettings(CommandView command);
  void ReadLinkPolicySettings(CommandView command);


@@ -221,49 +221,43 @@ class DualModeController : public Device {
  // 7.3.12
  // 7.3.12
  void ReadLocalName(CommandView command);
  void ReadLocalName(CommandView command);


  // 7.3.15
  // 7.3.13 - 7.3.14
  void ReadPageTimeout(CommandView command);
  void ReadConnectionAcceptTimeout(CommandView command);
  void WriteConnectionAcceptTimeout(CommandView command);


  // 7.3.16
  // 7.3.15 - 7.3.16
  void ReadPageTimeout(CommandView command);
  void WritePageTimeout(CommandView command);
  void WritePageTimeout(CommandView command);


  // 7.3.17
  // 7.3.17 - 7.3.18
  void ReadScanEnable(CommandView command);
  void ReadScanEnable(CommandView command);

  // 7.3.18
  void WriteScanEnable(CommandView command);
  void WriteScanEnable(CommandView command);


  // 7.3.19
  // 7.3.19 - 7.3.20
  void ReadPageScanActivity(CommandView command);
  void ReadPageScanActivity(CommandView command);

  // 7.3.20
  void WritePageScanActivity(CommandView command);
  void WritePageScanActivity(CommandView command);


  // 7.3.21
  // 7.3.21 - 7.3.22
  void ReadInquiryScanActivity(CommandView command);
  void ReadInquiryScanActivity(CommandView command);

  // 7.3.22
  void WriteInquiryScanActivity(CommandView command);
  void WriteInquiryScanActivity(CommandView command);


  // 7.3.23
  // 7.3.23 - 7.3.24
  void ReadAuthenticationEnable(CommandView command);
  void ReadAuthenticationEnable(CommandView command);

  // 7.3.24
  void WriteAuthenticationEnable(CommandView command);
  void WriteAuthenticationEnable(CommandView command);


  // 7.3.26
  // 7.3.25 - 7.3.26
  void ReadClassOfDevice(CommandView command);
  void WriteClassOfDevice(CommandView command);
  void WriteClassOfDevice(CommandView command);


  // 7.3.28
  // 7.3.27 - 7.3.28
  void ReadVoiceSetting(CommandView command);
  void WriteVoiceSetting(CommandView command);
  void WriteVoiceSetting(CommandView command);


  // 7.3.35
  // 7.3.35
  void ReadTransmitPowerLevel(CommandView command);
  void ReadTransmitPowerLevel(CommandView command);


  // 7.3.36
  // 7.3.36 - 7.3.37
  void ReadSynchronousFlowControlEnable(CommandView command);
  void ReadSynchronousFlowControlEnable(CommandView command);

  // 7.3.37
  void WriteSynchronousFlowControlEnable(CommandView command);
  void WriteSynchronousFlowControlEnable(CommandView command);


  // 7.3.39
  // 7.3.39
@@ -275,10 +269,8 @@ class DualModeController : public Device {
  // 7.3.43
  // 7.3.43
  void ReadNumberOfSupportedIac(CommandView command);
  void ReadNumberOfSupportedIac(CommandView command);


  // 7.3.44
  // 7.3.44 - 7.3.45
  void ReadCurrentIacLap(CommandView command);
  void ReadCurrentIacLap(CommandView command);

  // 7.3.45
  void WriteCurrentIacLap(CommandView command);
  void WriteCurrentIacLap(CommandView command);


  // 7.3.47
  // 7.3.47
@@ -384,7 +376,7 @@ class DualModeController : public Device {
  // 7.8.1
  // 7.8.1
  void LeSetEventMask(CommandView command);
  void LeSetEventMask(CommandView command);


  // 7.8.2 and 7.8.93
  // 7.8.2 - 7.8.93
  void LeReadBufferSizeV1(CommandView command);
  void LeReadBufferSizeV1(CommandView command);
  void LeReadBufferSizeV2(CommandView command);
  void LeReadBufferSizeV2(CommandView command);


@@ -394,43 +386,25 @@ class DualModeController : public Device {
  // 7.8.4
  // 7.8.4
  void LeSetRandomAddress(CommandView command);
  void LeSetRandomAddress(CommandView command);


  // 7.8.5
  // 7.8.5 - 7.8.9
  void LeSetAdvertisingParameters(CommandView command);
  void LeSetAdvertisingParameters(CommandView command);

  // 7.8.6
  void LeReadAdvertisingPhysicalChannelTxPower(CommandView command);
  void LeReadAdvertisingPhysicalChannelTxPower(CommandView command);

  // 7.8.7
  void LeSetAdvertisingData(CommandView command);
  void LeSetAdvertisingData(CommandView command);

  // 7.8.8
  void LeSetScanResponseData(CommandView command);
  void LeSetScanResponseData(CommandView command);

  // 7.8.9
  void LeSetAdvertisingEnable(CommandView command);
  void LeSetAdvertisingEnable(CommandView command);


  // 7.8.10
  // 7.8.10 - 7.8.11
  void LeSetScanParameters(CommandView command);
  void LeSetScanParameters(CommandView command);

  // 7.8.11
  void LeSetScanEnable(CommandView command);
  void LeSetScanEnable(CommandView command);


  // 7.8.12
  // 7.8.12 - 7.8.13
  void LeCreateConnection(CommandView command);
  void LeCreateConnection(CommandView command);

  // 7.8.13
  void LeCreateConnectionCancel(CommandView command);
  void LeCreateConnectionCancel(CommandView command);


  // 7.8.14
  // 7.8.14 - 7.8.17
  void LeReadFilterAcceptListSize(CommandView command);
  void LeReadFilterAcceptListSize(CommandView command);

  // 7.8.15
  void LeClearFilterAcceptList(CommandView command);
  void LeClearFilterAcceptList(CommandView command);

  // 7.8.16
  void LeAddDeviceToFilterAcceptList(CommandView command);
  void LeAddDeviceToFilterAcceptList(CommandView command);

  // 7.8.17
  void LeRemoveDeviceFromFilterAcceptList(CommandView command);
  void LeRemoveDeviceFromFilterAcceptList(CommandView command);


  // 7.8.18
  // 7.8.18
@@ -448,25 +422,19 @@ class DualModeController : public Device {
  // 7.8.24
  // 7.8.24
  void LeStartEncryption(CommandView command);
  void LeStartEncryption(CommandView command);


  // 7.8.25
  // 7.8.25 - 7.8.26
  void LeLongTermKeyRequestReply(CommandView command);
  void LeLongTermKeyRequestReply(CommandView command);

  // 7.8.26
  void LeLongTermKeyRequestNegativeReply(CommandView command);
  void LeLongTermKeyRequestNegativeReply(CommandView command);


  // 7.8.27
  // 7.8.27
  void LeReadSupportedStates(CommandView command);
  void LeReadSupportedStates(CommandView command);


  // 7.8.31
  // 7.8.31 - 7.8.32
  void LeRemoteConnectionParameterRequestReply(CommandView command);
  void LeRemoteConnectionParameterRequestReply(CommandView command);

  // 7.8.32
  void LeRemoteConnectionParameterRequestNegativeReply(CommandView command);
  void LeRemoteConnectionParameterRequestNegativeReply(CommandView command);


  // 7.8.34
  // 7.8.34 - 7.8.35
  void LeReadSuggestedDefaultDataLength(CommandView command);
  void LeReadSuggestedDefaultDataLength(CommandView command);

  // 7.8.35
  void LeWriteSuggestedDefaultDataLength(CommandView command);
  void LeWriteSuggestedDefaultDataLength(CommandView command);


  // 7.8.38 - 7.8.41
  // 7.8.38 - 7.8.41
@@ -479,44 +447,27 @@ class DualModeController : public Device {
  void LeReadPeerResolvableAddress(CommandView command);
  void LeReadPeerResolvableAddress(CommandView command);
  void LeReadLocalResolvableAddress(CommandView command);
  void LeReadLocalResolvableAddress(CommandView command);


  // 7.8.44
  // 7.8.44 - 7.8.45
  void LeSetAddressResolutionEnable(CommandView command);
  void LeSetAddressResolutionEnable(CommandView command);

  // 7.8.45
  void LeSetResolvablePrivateAddressTimeout(CommandView command);
  void LeSetResolvablePrivateAddressTimeout(CommandView command);


  // 7.8.46
  // 7.8.46
  void LeReadMaximumDataLength(CommandView command);
  void LeReadMaximumDataLength(CommandView command);


  // 7.8.47 - 7.8.49
  void LeReadPhy(CommandView command);
  void LeReadPhy(CommandView command);
  void LeSetDefaultPhy(CommandView command);
  void LeSetDefaultPhy(CommandView command);
  void LeSetPhy(CommandView command);
  void LeSetPhy(CommandView command);


  // 7.8.52
  // 7.8.52 - 7.8.60
  void LeSetAdvertisingSetRandomAddress(CommandView command);
  void LeSetAdvertisingSetRandomAddress(CommandView command);

  // 7.8.53
  void LeSetExtendedAdvertisingParameters(CommandView command);
  void LeSetExtendedAdvertisingParameters(CommandView command);

  // 7.8.54
  void LeSetExtendedAdvertisingData(CommandView command);
  void LeSetExtendedAdvertisingData(CommandView command);

  // 7.8.55
  void LeSetExtendedScanResponseData(CommandView command);
  void LeSetExtendedScanResponseData(CommandView command);

  // 7.8.56
  void LeSetExtendedAdvertisingEnable(CommandView command);
  void LeSetExtendedAdvertisingEnable(CommandView command);

  // 7.8.57
  void LeReadMaximumAdvertisingDataLength(CommandView command);
  void LeReadMaximumAdvertisingDataLength(CommandView command);

  // 7.8.58
  void LeReadNumberOfSupportedAdvertisingSets(CommandView command);
  void LeReadNumberOfSupportedAdvertisingSets(CommandView command);

  // 7.8.59
  void LeRemoveAdvertisingSet(CommandView command);
  void LeRemoveAdvertisingSet(CommandView command);

  // 7.8.60
  void LeClearAdvertisingSets(CommandView command);
  void LeClearAdvertisingSets(CommandView command);


  // 7.8.61 - 7.8.63
  // 7.8.61 - 7.8.63
@@ -535,10 +486,8 @@ class DualModeController : public Device {
  void LeClearPeriodicAdvertiserList(CommandView command);
  void LeClearPeriodicAdvertiserList(CommandView command);
  void LeReadPeriodicAdvertiserListSize(CommandView command);
  void LeReadPeriodicAdvertiserListSize(CommandView command);


  // 7.8.64
  // 7.8.64 - 7.8.65
  void LeSetExtendedScanParameters(CommandView command);
  void LeSetExtendedScanParameters(CommandView command);

  // 7.8.65
  void LeSetExtendedScanEnable(CommandView command);
  void LeSetExtendedScanEnable(CommandView command);


  // 7.8.66
  // 7.8.66
@@ -550,12 +499,6 @@ class DualModeController : public Device {
  // 7.8.115
  // 7.8.115
  void LeSetHostFeature(CommandView command);
  void LeSetHostFeature(CommandView command);


  // Required commands for handshaking with hci driver
  void ReadClassOfDevice(CommandView command);
  void ReadVoiceSetting(CommandView command);
  void ReadConnectionAcceptTimeout(CommandView command);
  void WriteConnectionAcceptTimeout(CommandView command);

  // Vendor-specific Commands
  // Vendor-specific Commands
  void LeGetVendorCapabilities(CommandView command);
  void LeGetVendorCapabilities(CommandView command);
  void LeEnergyInfo(CommandView command);
  void LeEnergyInfo(CommandView command);
+5 −0
Original line number Original line Diff line number Diff line
@@ -1958,6 +1958,11 @@ void LinkLayerController::SetLocalName(std::vector<uint8_t> const& local_name) {
  std::copy(local_name.begin(), local_name.end(), local_name_.begin());
  std::copy(local_name.begin(), local_name.end(), local_name_.begin());
}
}


void LinkLayerController::SetExtendedInquiryResponse(
    std::array<uint8_t, 240> const& extended_inquiry_response) {
  extended_inquiry_response_ = extended_inquiry_response;
}

void LinkLayerController::SetExtendedInquiryResponse(
void LinkLayerController::SetExtendedInquiryResponse(
    std::vector<uint8_t> const& extended_inquiry_response) {
    std::vector<uint8_t> const& extended_inquiry_response) {
  ASSERT(extended_inquiry_response.size() <= extended_inquiry_response_.size());
  ASSERT(extended_inquiry_response.size() <= extended_inquiry_response_.size());
+3 −0
Original line number Original line Diff line number Diff line
@@ -727,6 +727,9 @@ class LinkLayerController {


  void SetLocalName(std::vector<uint8_t> const& local_name);
  void SetLocalName(std::vector<uint8_t> const& local_name);
  void SetLocalName(std::array<uint8_t, kLocalNameSize> const& local_name);
  void SetLocalName(std::array<uint8_t, kLocalNameSize> const& local_name);

  void SetExtendedInquiryResponse(
      std::array<uint8_t, 240> const& extended_inquiry_response);
  void SetExtendedInquiryResponse(
  void SetExtendedInquiryResponse(
      std::vector<uint8_t> const& extended_inquiry_response);
      std::vector<uint8_t> const& extended_inquiry_response);