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

Commit d1e5fa6a authored by Chris Manton's avatar Chris Manton Committed by Gerrit Code Review
Browse files

Merge "Create structs for default and with rssi inquiry results"

parents 5d4bd2f4 a268e404
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -3282,8 +3282,7 @@ packet InquiryComplete : EventPacket (event_code = INQUIRY_COMPLETE){
  status : ErrorCode,
}

packet InquiryResult : EventPacket (event_code = INQUIRY_RESULT){
  num_responses : 8,
struct InquiryResult {
  bd_addr : Address,
  page_scan_repetition_mode : PageScanRepetitionMode,
  _reserved_ : 8,
@@ -3293,6 +3292,11 @@ packet InquiryResult : EventPacket (event_code = INQUIRY_RESULT){
  _reserved_ : 1,
}

packet InquiryResult : EventPacket (event_code = INQUIRY_RESULT){
  _count_(inquiry_results) : 8,
  inquiry_results : InquiryResult[],
}

enum LinkType : 8 {
  SCO = 0x00,
  ACL = 0x01,
@@ -3513,8 +3517,7 @@ packet FlowSpecificationComplete : EventPacket (event_code = FLOW_SPECIFICATION_
  access_latency : 32, // Octets/s
}

packet InquiryResultWithRssi : EventPacket (event_code = INQUIRY_RESULT_WITH_RSSI){
  num_responses : 8,
struct InquiryResultWithRssi {
  address : Address,
  page_scan_repetition_mode : PageScanRepetitionMode,
  _reserved_ : 8,
@@ -3524,6 +3527,11 @@ packet InquiryResultWithRssi : EventPacket (event_code = INQUIRY_RESULT_WITH_RSS
  rssi : 8,
}

packet InquiryResultWithRssi : EventPacket (event_code = INQUIRY_RESULT_WITH_RSSI){
  _count_(inquiry_results) : 8,
  inquiry_results : InquiryResultWithRssi[],
}

packet ReadRemoteExtendedFeaturesComplete : EventPacket (event_code = READ_REMOTE_EXTENDED_FEATURES_COMPLETE){
  status : ErrorCode,
  connection_handle : 12,
+2 −8
Original line number Diff line number Diff line
@@ -204,20 +204,14 @@ void neighbor::InquiryModule::impl::OnEvent(hci::EventPacketView view) {
    case hci::EventCode::INQUIRY_RESULT: {
      auto packet = hci::InquiryResultView::Create(view);
      ASSERT(packet.IsValid());
      LOG_DEBUG("Inquiry result size:%zd num_responses:%d addr:%s repetition_mode:%s cod:%s clock_offset:%d",
                packet.size(), packet.GetNumResponses(), packet.GetBdAddr().ToString().c_str(),
                hci::PageScanRepetitionModeText(packet.GetPageScanRepetitionMode()).c_str(),
                packet.GetClassOfDevice().ToString().c_str(), packet.GetClockOffset());
      LOG_DEBUG("Inquiry result size:%zd num_responses:%zu", packet.size(), packet.GetInquiryResults().size());
      inquiry_callbacks_.result(packet);
    } break;

    case hci::EventCode::INQUIRY_RESULT_WITH_RSSI: {
      auto packet = hci::InquiryResultWithRssiView::Create(view);
      ASSERT(packet.IsValid());
      LOG_DEBUG("Inquiry result with rssi num_responses:%d addr:%s repetition_mode:%s cod:%s clock_offset:%d",
                packet.GetNumResponses(), packet.GetAddress().ToString().c_str(),
                hci::PageScanRepetitionModeText(packet.GetPageScanRepetitionMode()).c_str(),
                packet.GetClassOfDevice().ToString().c_str(), packet.GetClockOffset());
      LOG_DEBUG("Inquiry result with rssi num_responses:%zu", packet.GetInquiryResults().size());
      inquiry_callbacks_.result_with_rssi(packet);
    } break;

+2 −9
Original line number Diff line number Diff line
@@ -459,15 +459,8 @@ TEST_F(InquiryTest, InjectInquiryResult) {
  test_hci_layer_->Synchronize([this] { inquiry_module_->StartGeneralInquiry(128, 100); }, hci::OpCode::INQUIRY);

  WaitForInquiryResult([this] {
    uint8_t num_responses = 1;
    hci::Address bd_addr;
    hci::Address::FromString("11:22:33:44:55:66", bd_addr);
    hci::PageScanRepetitionMode page_scan_repetition_mode = hci::PageScanRepetitionMode::R1;
    hci::ClassOfDevice class_of_device;
    hci::ClassOfDevice::FromString("00:00:00", class_of_device);
    uint16_t clock_offset = 0x1234;
    auto packet = hci::InquiryResultBuilder::Create(num_responses, bd_addr, page_scan_repetition_mode, class_of_device,
                                                    clock_offset);
    const std::vector<hci::InquiryResult> inquiry_results;
    auto packet = hci::InquiryResultBuilder::Create(inquiry_results);
    test_hci_layer_->InjectInquiryResult(std::move(packet));
  });
  test_hci_layer_->Synchronize([this] { inquiry_module_->StopInquiry(); }, hci::OpCode::INQUIRY_CANCEL);
+16 −9
Original line number Diff line number Diff line
@@ -573,11 +573,13 @@ void LinkLayerController::IncomingInquiryResponsePacket(
          (bluetooth::hci::PageScanRepetitionMode)
              inquiry_response.GetPageScanRepetitionMode();

      auto packet = bluetooth::hci::InquiryResultBuilder::Create(
          0x01, inquiry_response.GetSourceAddress(), page_scan_repetition_mode,
          inquiry_response.GetClassOfDevice(),
          inquiry_response.GetClockOffset());

      std::vector<bluetooth::hci::InquiryResult> responses;
      responses.emplace_back();
      responses.back().bd_addr_ = inquiry_response.GetSourceAddress();
      responses.back().page_scan_repetition_mode_ = page_scan_repetition_mode;
      responses.back().class_of_device_ = inquiry_response.GetClassOfDevice();
      responses.back().clock_offset_ = inquiry_response.GetClockOffset();
      auto packet = bluetooth::hci::InquiryResultBuilder::Create(responses);
      send_event_(std::move(packet));
    } break;

@@ -591,10 +593,15 @@ void LinkLayerController::IncomingInquiryResponsePacket(
          (bluetooth::hci::PageScanRepetitionMode)
              inquiry_response.GetPageScanRepetitionMode();

      auto packet = bluetooth::hci::InquiryResultWithRssiBuilder::Create(
          0x01, inquiry_response.GetSourceAddress(), page_scan_repetition_mode,
          inquiry_response.GetClassOfDevice(),
          inquiry_response.GetClockOffset(), inquiry_response.GetRssi());
      std::vector<bluetooth::hci::InquiryResultWithRssi> responses;
      responses.emplace_back();
      responses.back().address_ = inquiry_response.GetSourceAddress();
      responses.back().page_scan_repetition_mode_ = page_scan_repetition_mode;
      responses.back().class_of_device_ = inquiry_response.GetClassOfDevice();
      responses.back().clock_offset_ = inquiry_response.GetClockOffset();
      responses.back().rssi_ = inquiry_response.GetRssi();
      auto packet =
          bluetooth::hci::InquiryResultWithRssiBuilder::Create(responses);
      send_event_(std::move(packet));
    } break;