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

Commit 8c8df120 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Reorganize vendor command specification" into main

parents 5908f073 152ee713
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -63,10 +63,6 @@ class PcapFilter final {
      bluetooth::hci::CommandView& command);
  std::vector<uint8_t> FilterLeSetPeriodicAdvertisingData(
      bluetooth::hci::CommandView& command);
  std::vector<uint8_t> FilterLeMultiAdvtSetData(
      bluetooth::hci::LeMultiAdvtView& command);
  std::vector<uint8_t> FilterLeMultiAdvtSetScanResp(
      bluetooth::hci::LeMultiAdvtView& command);

  // Specific filters for HCI events.
  std::vector<uint8_t> FilterReadLocalNameComplete(
+0 −39
Original line number Diff line number Diff line
@@ -74,19 +74,6 @@ std::vector<uint8_t> PcapFilter::FilterHciCommand(
      return FilterLeSetExtendedScanResponseData(command);
    case OpCode::LE_SET_PERIODIC_ADVERTISING_DATA:
      return FilterLeSetPeriodicAdvertisingData(command);
    case OpCode::LE_MULTI_ADVT: {
      auto le_multi_advt_command = LeMultiAdvtView::Create(command);
      ASSERT(le_multi_advt_command.IsValid());
      switch (le_multi_advt_command.GetSubCmd()) {
        case SubOcf::SET_DATA:
          return FilterLeMultiAdvtSetData(le_multi_advt_command);
        case SubOcf::SET_SCAN_RESP:
          return FilterLeMultiAdvtSetScanResp(le_multi_advt_command);
        default:
          break;
      }
      break;
    }
    default:
      break;
  }
@@ -301,32 +288,6 @@ std::vector<uint8_t> PcapFilter::FilterLeSetPeriodicAdvertisingData(
      ->SerializeToBytes();
}

// Replace the device names in the GAP entries of the advertising data.
std::vector<uint8_t> PcapFilter::FilterLeMultiAdvtSetData(
    bluetooth::hci::LeMultiAdvtView& command) {
  auto parameters = LeMultiAdvtSetDataView::Create(command);
  ASSERT(parameters.IsValid());

  std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData();
  FilterGapData(advertising_data);
  return LeMultiAdvtSetDataBuilder::Create(advertising_data,
                                           parameters.GetAdvertisingInstance())
      ->SerializeToBytes();
}

// Replace the device names in the GAP entries of the scan response data.
std::vector<uint8_t> PcapFilter::FilterLeMultiAdvtSetScanResp(
    bluetooth::hci::LeMultiAdvtView& command) {
  auto parameters = LeMultiAdvtSetScanRespView::Create(command);
  ASSERT(parameters.IsValid());

  std::vector<uint8_t> advertising_data = parameters.GetAdvertisingData();
  FilterGapData(advertising_data);
  return LeMultiAdvtSetScanRespBuilder::Create(
             advertising_data, parameters.GetAdvertisingInstance())
      ->SerializeToBytes();
}

// Replace the local device name in the read local name complete event.
std::vector<uint8_t> PcapFilter::FilterReadLocalNameComplete(
    bluetooth::hci::CommandCompleteView& command_complete) {
+41 −24
Original line number Diff line number Diff line
@@ -2772,8 +2772,8 @@ void DualModeController::LeRemoteConnectionParameterRequestNegativeReply(
}

void DualModeController::LeGetVendorCapabilities(CommandView command) {
  auto command_view = bluetooth::hci::LeGetVendorCapabilitiesView::Create(
      bluetooth::hci::VendorCommandView::Create(command));
  auto command_view =
      bluetooth::hci::LeGetVendorCapabilitiesView::Create(command);
  ASSERT(command_view.IsValid());

  if (!properties_.supports_le_get_vendor_capabilities_command) {
@@ -2796,23 +2796,43 @@ void DualModeController::LeGetVendorCapabilities(CommandView command) {
      std::move(return_parameters)));
}

void DualModeController::LeMultiAdv(CommandView command) {
  auto command_view = bluetooth::hci::LeMultiAdvtView::Create(command);
void DualModeController::LeBatchScan(CommandView command) {
  auto command_view = bluetooth::hci::LeBatchScanView::Create(command);
  ASSERT(command_view.IsValid());
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_MULTI_ADVT);
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_BATCH_SCAN);
}

void DualModeController::LeAdvertisingFilter(CommandView command) {
  auto command_view = bluetooth::hci::LeAdvFilterView::Create(command);
void DualModeController::LeApcf(CommandView command) {
  auto command_view = bluetooth::hci::LeApcfView::Create(command);
  ASSERT(command_view.IsValid());
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_ADV_FILTER);
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_APCF);
}

void DualModeController::LeEnergyInfo(CommandView command) {
  auto command_view = bluetooth::hci::LeEnergyInfoView::Create(
      bluetooth::hci::VendorCommandView::Create(command));
void DualModeController::LeGetControllerActivityEnergyInfo(
    CommandView command) {
  auto command_view =
      bluetooth::hci::LeGetControllerActivityEnergyInfoView::Create(command);
  ASSERT(command_view.IsValid());
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_ENERGY_INFO);
  SendCommandCompleteUnknownOpCodeEvent(
      OpCode::LE_GET_CONTROLLER_ACTIVITY_ENERGY_INFO);
}

void DualModeController::LeExSetScanParameters(CommandView command) {
  auto command_view =
      bluetooth::hci::LeExSetScanParametersView::Create(command);
  ASSERT(command_view.IsValid());
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_EX_SET_SCAN_PARAMETERS);
}

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

  DEBUG(id_, "<< Get Controller Debug Info");

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

// CSR vendor command.
@@ -3142,12 +3162,6 @@ void DualModeController::LeClearAdvertisingSets(CommandView command) {
      kNumCommandPackets, status));
}

void DualModeController::LeExtendedScanParams(CommandView command) {
  auto command_view = bluetooth::hci::LeExtendedScanParamsView::Create(command);
  ASSERT(command_view.IsValid());
  SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_EXTENDED_SCAN_PARAMS);
}

void DualModeController::LeStartEncryption(CommandView command) {
  auto command_view = bluetooth::hci::LeStartEncryptionView::Create(command);
  ASSERT(command_view.IsValid());
@@ -4289,12 +4303,15 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>

        // VENDOR
        {OpCode(CSR_VENDOR), &DualModeController::CsrVendorCommand},
        {OpCode::LE_MULTI_ADVT, &DualModeController::LeMultiAdv},
        {OpCode::LE_ADV_FILTER, &DualModeController::LeAdvertisingFilter},
        {OpCode::LE_EXTENDED_SCAN_PARAMS,
         &DualModeController::LeExtendedScanParams},
        {OpCode::LE_ENERGY_INFO, &DualModeController::LeEnergyInfo},
        {OpCode::LE_GET_VENDOR_CAPABILITIES,
         &DualModeController::LeGetVendorCapabilities}};
         &DualModeController::LeGetVendorCapabilities},
        {OpCode::LE_BATCH_SCAN, &DualModeController::LeBatchScan},
        {OpCode::LE_APCF, &DualModeController::LeApcf},
        {OpCode::LE_GET_CONTROLLER_ACTIVITY_ENERGY_INFO,
         &DualModeController::LeGetControllerActivityEnergyInfo},
        {OpCode::LE_EX_SET_SCAN_PARAMETERS,
         &DualModeController::LeExSetScanParameters},
        {OpCode::GET_CONTROLLER_DEBUG_INFO,
         &DualModeController::GetControllerDebugInfo}};

}  // namespace rootcanal
+5 −4
Original line number Diff line number Diff line
@@ -501,10 +501,11 @@ class DualModeController : public Device {

  // Vendor-specific Commands
  void LeGetVendorCapabilities(CommandView command);
  void LeEnergyInfo(CommandView command);
  void LeMultiAdv(CommandView command);
  void LeAdvertisingFilter(CommandView command);
  void LeExtendedScanParams(CommandView command);
  void LeBatchScan(CommandView command);
  void LeApcf(CommandView command);
  void LeGetControllerActivityEnergyInfo(CommandView command);
  void LeExSetScanParameters(CommandView command);
  void GetControllerDebugInfo(CommandView command);

  // CSR vendor command.
  // Implement the command specific to the CSR controller
+982 −1195

File changed.

Preview size limit exceeded, changes collapsed.