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

Commit 2a6536f7 authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

Merge "PAST: Convert address type for sync established event" am: 4afb69b0 am: c75a9c51

parents 063b2fe0 c75a9c51
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -4013,10 +4013,15 @@ enum PeriodicAdvertisingOptions : 8 {
  ENABLE_DUPLICATE_FILTERING = 0x04,
}

enum AdvertisingAddressType : 8 {
  PUBLIC_ADDRESS = 0x00,
  RANDOM_ADDRESS = 0x01,
}

packet LePeriodicAdvertisingCreateSync : LeScanningCommand (op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC) {
  options : PeriodicAdvertisingOptions,
  advertising_sid : 8,
  advertiser_address_type : AddressType,
  advertiser_address_type : AdvertisingAddressType,
  advertiser_address : Address,
  skip : 16,
  sync_timeout : 16,
@@ -4042,11 +4047,6 @@ packet LePeriodicAdvertisingTerminateSyncComplete : CommandComplete (command_op_
  status : ErrorCode,
}

enum AdvertisingAddressType : 8 {
  PUBLIC_ADDRESS = 0x00,
  RANDOM_ADDRESS = 0x01,
}

packet LeAddDeviceToPeriodicAdvertisingList : LeScanningCommand (op_code = LE_ADD_DEVICE_TO_PERIODIC_ADVERTISING_LIST) {
  advertising_address_type : AdvertisingAddressType,
  advertiser_address : Address,
@@ -4059,7 +4059,7 @@ packet LeAddDeviceToPeriodicAdvertisingListComplete : CommandComplete (command_o
}

packet LeRemoveDeviceFromPeriodicAdvertisingList : LeScanningCommand (op_code = LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISING_LIST) {
  advertiser_address_type : AddressType,
  advertiser_address_type : AdvertisingAddressType,
  advertiser_address : Address,
  advertising_sid : 8,
}
+16 −8
Original line number Diff line number Diff line
@@ -97,6 +97,11 @@ class PeriodicSyncManager {
          request.request_id, status, 0, request.advertiser_sid, request.address_with_type, 0, 0);
      return;
    }
    auto address_type = request.address_with_type.GetAddressType();
    ASSERT_LOG(
        (address_type == AddressType::PUBLIC_DEVICE_ADDRESS || address_type == AddressType::RANDOM_DEVICE_ADDRESS),
        "Invalid address type %s",
        AddressTypeText(address_type).c_str());
    periodic_syncs_.emplace_back(request);
    LOG_DEBUG("address = %s, sid = %d", request.address_with_type.ToString().c_str(), request.advertiser_sid);
    pending_sync_requests_.emplace_back(
@@ -268,7 +273,14 @@ class PeriodicSyncManager {

    auto address_with_type = AddressWithType(event_view.GetAdvertiserAddress(), event_view.GetAdvertiserAddressType());

    auto periodic_sync = GetSyncFromAddressAndSid(address_with_type.GetAddress(), event_view.GetAdvertisingSid());
    auto temp_address_type = address_with_type.GetAddressType();
    // If the create sync command uses 0x01, Random or Random ID, the result can be 0x01, 0x02, or 0x03,
    // because a Random Address, if it is an RPA, can be resolved to either Public Identity or Random Identity.
    if (temp_address_type != AddressType::PUBLIC_DEVICE_ADDRESS) {
      temp_address_type = AddressType::RANDOM_DEVICE_ADDRESS;
    }
    auto periodic_sync = GetSyncFromAddressWithTypeAndSid(
        AddressWithType(event_view.GetAdvertiserAddress(), temp_address_type), event_view.GetAdvertisingSid());
    if (periodic_sync == periodic_syncs_.end()) {
      LOG_WARN("[PSync]: Invalid address and sid for sync established");
      if (event_view.GetStatus() == ErrorCode::SUCCESS) {
@@ -440,15 +452,11 @@ class PeriodicSyncManager {
        static_cast<uint8_t>(PeriodicSyncCteType::AVOID_AOD_CONSTANT_TONE_EXTENSION_WITH_TWO_US_SLOTS));
    auto sync = GetSyncFromAddressWithTypeAndSid(address_with_type, sid);
    sync->sync_state = PERIODIC_SYNC_STATE_PENDING;
    AdvertisingAddressType advertisingAddressType =
        static_cast<AdvertisingAddressType>(address_with_type.GetAddressType());
    le_scanning_interface_->EnqueueCommand(
        hci::LePeriodicAdvertisingCreateSyncBuilder::Create(
            options,
            sid,
            address_with_type.GetAddressType(),
            address_with_type.GetAddress(),
            skip,
            timeout,
            sync_cte_type),
            options, sid, advertisingAddressType, address_with_type.GetAddress(), skip, timeout, sync_cte_type),
        handler_->BindOnceOn(this, &PeriodicSyncManager::HandlePeriodicAdvertisingCreateSyncStatus));
  }

+1 −1
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ TEST_F(PeriodicSyncManagerTest, start_sync_test) {
  auto packet_view = LePeriodicAdvertisingCreateSyncView::Create(LeScanningCommandView::Create(packet));
  ASSERT_TRUE(packet_view.IsValid());
  ASSERT_EQ(advertiser_sid, packet_view.GetAdvertisingSid());
  ASSERT_EQ(AddressType::PUBLIC_DEVICE_ADDRESS, packet_view.GetAdvertiserAddressType());
  ASSERT_EQ(AdvertisingAddressType::PUBLIC_ADDRESS, packet_view.GetAdvertiserAddressType());
  ASSERT_EQ(address, packet_view.GetAdvertiserAddress());
  ASSERT_EQ(skip, packet_view.GetSkip());
  ASSERT_EQ(sync_timeout, packet_view.GetSyncTimeout());