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

Commit f451333a authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Support Suggested Default Length"

parents 51d9d220 4eb260b5
Loading
Loading
Loading
Loading
+28 −2
Original line number Original line Diff line number Diff line
@@ -265,6 +265,8 @@ DualModeController::DualModeController(const std::string& properties_filename, u
  SET_SUPPORTED(LE_SET_PRIVACY_MODE, LeSetPrivacyMode);
  SET_SUPPORTED(LE_SET_PRIVACY_MODE, LeSetPrivacyMode);
  SET_SUPPORTED(LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH,
  SET_SUPPORTED(LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH,
                LeReadSuggestedDefaultDataLength);
                LeReadSuggestedDefaultDataLength);
  SET_SUPPORTED(LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH,
                LeWriteSuggestedDefaultDataLength);
  // ISO Commands
  // ISO Commands
  SET_SUPPORTED(LE_READ_ISO_TX_SYNC, LeReadIsoTxSync);
  SET_SUPPORTED(LE_READ_ISO_TX_SYNC, LeReadIsoTxSync);
  SET_SUPPORTED(LE_SET_CIG_PARAMETERS, LeSetCigParameters);
  SET_SUPPORTED(LE_SET_CIG_PARAMETERS, LeSetCigParameters);
@@ -1947,8 +1949,32 @@ void DualModeController::LeReadSuggestedDefaultDataLength(CommandView command) {
      gd_hci::LeConnectionManagementCommandView::Create(
      gd_hci::LeConnectionManagementCommandView::Create(
          gd_hci::AclCommandView::Create(command)));
          gd_hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
  send_event_(bluetooth::hci::LeReadSuggestedDefaultDataLengthCompleteBuilder::Create(
  send_event_(
      kNumCommandPackets, ErrorCode::SUCCESS, kLeMaximumDataLength, kLeMaximumDataTime));
      bluetooth::hci::LeReadSuggestedDefaultDataLengthCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS,
          le_suggested_default_data_bytes_, le_suggested_default_data_time_));
}

void DualModeController::LeWriteSuggestedDefaultDataLength(
    CommandView command) {
  auto command_view = gd_hci::LeWriteSuggestedDefaultDataLengthView::Create(
      gd_hci::LeConnectionManagementCommandView::Create(
          gd_hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  uint16_t bytes = command_view.GetTxOctets();
  uint16_t time = command_view.GetTxTime();
  if (bytes > 0xFB || bytes < 0x1B || time < 0x148 || time > 0x4290) {
    send_event_(
        bluetooth::hci::LeWriteSuggestedDefaultDataLengthCompleteBuilder::
            Create(kNumCommandPackets,
                   ErrorCode::INVALID_HCI_COMMAND_PARAMETERS));
    return;
  }
  le_suggested_default_data_bytes_ = bytes;
  le_suggested_default_data_time_ = time;
  send_event_(
      bluetooth::hci::LeWriteSuggestedDefaultDataLengthCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS));
}
}


void DualModeController::LeAddDeviceToResolvingList(CommandView command) {
void DualModeController::LeAddDeviceToResolvingList(CommandView command) {
+7 −0
Original line number Original line Diff line number Diff line
@@ -468,6 +468,9 @@ class DualModeController : public Device {
  // 7.8.34
  // 7.8.34
  void LeReadSuggestedDefaultDataLength(CommandView args);
  void LeReadSuggestedDefaultDataLength(CommandView args);


  // 7.8.35
  void LeWriteSuggestedDefaultDataLength(CommandView args);

  // 7.8.38
  // 7.8.38
  void LeAddDeviceToResolvingList(CommandView args);
  void LeAddDeviceToResolvingList(CommandView args);


@@ -575,6 +578,10 @@ class DualModeController : public Device {


  void SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const;
  void SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const;


  // Unused state to maintain consistency for the Host
  uint16_t le_suggested_default_data_bytes_{0x20};
  uint16_t le_suggested_default_data_time_{0x148};

  // Callbacks to send packets back to the HCI.
  // Callbacks to send packets back to the HCI.
  std::function<void(std::shared_ptr<bluetooth::hci::AclBuilder>)> send_acl_;
  std::function<void(std::shared_ptr<bluetooth::hci::AclBuilder>)> send_acl_;
  std::function<void(std::shared_ptr<bluetooth::hci::EventBuilder>)>
  std::function<void(std::shared_ptr<bluetooth::hci::EventBuilder>)>