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

Commit 56019551 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

GD: Set LE Event Mask

After this patch we enable LE Set Event Mask. Thanks to it we would
receive Extended Create Connection Complete, and Extended Advertising
Reports from real controllers.

Tag: #gd-refactor
Test: run GD on real device, verify extended events are received
Bug: 147086339
Change-Id: I678f3349f624da94042a7d954322398bb0d18f98
parent a9975185
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      case SubeventCode::CONNECTION_UPDATE_COMPLETE:
        on_le_connection_update_complete(event_packet);
        break;
      case SubeventCode::PHY_UPDATE_COMPLETE:
        LOG_INFO("PHY_UPDATE_COMPLETE");
        break;
      default:
        LOG_ALWAYS_FATAL("Unhandled event code %s", SubeventCodeText(code).c_str());
    }
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct Controller::impl {
          EventCode::NUMBER_OF_COMPLETED_PACKETS, handler->BindOn(this, &Controller::impl::NumberOfCompletedPackets));
    }

    le_set_event_mask(kDefaultLeEventMask);
    set_event_mask(kDefaultEventMask);
    write_simple_pairing_mode(Enable::ENABLED);
    // TODO(b/159927452): Legacy stack set SimultaneousLeHost = 1. Revisit if this causes problem.
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ class Controller : public Module {
  static const ModuleFactory Factory;

  static constexpr uint64_t kDefaultEventMask = 0x3dbfffffffffffff;
  static constexpr uint64_t kDefaultLeEventMask = 0x0000000000021e7f;

 protected:
  void ListDependencies(ModuleList* list) override;
+14 −6
Original line number Diff line number Diff line
@@ -174,10 +174,16 @@ class TestHciLayer : public HciLayer {
        event_mask = view.GetEventMask();
        event_builder = SetEventMaskCompleteBuilder::Create(num_packets, ErrorCode::SUCCESS);
      } break;
      case (OpCode::LE_SET_EVENT_MASK): {
        auto view = LeSetEventMaskView::Create(command);
        ASSERT_TRUE(view.IsValid());
        le_event_mask = view.GetLeEventMask();
        event_builder = LeSetEventMaskCompleteBuilder::Create(num_packets, ErrorCode::SUCCESS);
      } break;

      case (OpCode::RESET):
      case (OpCode::SET_EVENT_FILTER):
      case (OpCode::HOST_BUFFER_SIZE):
      case (OpCode::LE_SET_EVENT_MASK):
        command_queue_.push(command);
        not_empty_.notify_all();
        return;
@@ -249,6 +255,7 @@ class TestHciLayer : public HciLayer {
  constexpr static uint16_t total_num_acl_data_packets = 10;
  constexpr static uint16_t total_num_synchronous_data_packets = 12;
  uint64_t event_mask = 0;
  uint64_t le_event_mask = 0;

 private:
  common::ContextualCallback<void(EventPacketView)> number_of_completed_packets_callback_;
@@ -363,11 +370,12 @@ TEST_F(ControllerTest, send_host_buffer_size_command) {
}

TEST_F(ControllerTest, send_le_set_event_mask_command) {
  controller_->LeSetEventMask(0x000000000000001F);
  auto packet = test_hci_layer_->GetCommand(OpCode::LE_SET_EVENT_MASK);
  auto command = LeSetEventMaskView::Create(packet);
  ASSERT_TRUE(command.IsValid());
  ASSERT_EQ(command.GetLeEventMask(), 0x000000000000001F);
  uint64_t new_le_event_mask = test_hci_layer_->event_mask - 1;
  controller_->LeSetEventMask(new_le_event_mask);
  // Send another command to make sure it was applied
  controller_->Reset();
  auto packet = test_hci_layer_->GetCommand(OpCode::RESET);
  ASSERT_EQ(new_le_event_mask, test_hci_layer_->le_event_mask);
}

TEST_F(ControllerTest, is_supported_test) {
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ constexpr SubeventCode LeConnectionManagementEvents[] = {
    SubeventCode::CONNECTION_COMPLETE,
    SubeventCode::ENHANCED_CONNECTION_COMPLETE,
    SubeventCode::CONNECTION_UPDATE_COMPLETE,
    SubeventCode::PHY_UPDATE_COMPLETE,
};

typedef CommandInterface<LeConnectionManagementCommandBuilder> LeAclConnectionInterface;