From fb8bfe05b2aabdd65edca24d1da5b8a29e5b7430 Mon Sep 17 00:00:00 2001 From: hai007 Date: Tue, 25 Feb 2025 18:15:29 -0800 Subject: [PATCH] [NearbyConnections] Fix IOS incorrect endpoint info from GATT server 1. Put the entire regular advertisement onto the gatt server 2. Provide the gatt read characterestics with offset. PiperOrigin-RevId: 731102862 --- connections/implementation/mediums/ble_v2.cc | 4 +--- .../implementation/apple/Mediums/BLEv2/GNCBLEGATTServer.m | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/connections/implementation/mediums/ble_v2.cc b/connections/implementation/mediums/ble_v2.cc index d3d2dd8c..7ca9d2da 100644 --- a/connections/implementation/mediums/ble_v2.cc +++ b/connections/implementation/mediums/ble_v2.cc @@ -961,9 +961,7 @@ bool BleV2::StartRegularAdvertisingLocked( // Begin building the regular BLE advertisement. BleAdvertisementData advertising_data; ByteArray medium_advertisement_bytes = - medium_.IsExtendedAdvertisementsAvailable() - ? medium_advertisement.ByteArrayWithExtraField() - : ByteArray(medium_advertisement); + medium_advertisement.ByteArrayWithExtraField(); // Start extended advertisement first if available. bool extended_regular_advertisement_success = false; diff --git a/internal/platform/implementation/apple/Mediums/BLEv2/GNCBLEGATTServer.m b/internal/platform/implementation/apple/Mediums/BLEv2/GNCBLEGATTServer.m index 9ab8dfe1..89b85990 100644 --- a/internal/platform/implementation/apple/Mediums/BLEv2/GNCBLEGATTServer.m +++ b/internal/platform/implementation/apple/Mediums/BLEv2/GNCBLEGATTServer.m @@ -327,7 +327,8 @@ static char *const kGNCBLEGATTServerQueueLabel = "com.nearby.GNCBLEGATTServer"; [_peripheralManager respondToRequest:request withResult:CBATTErrorAttributeNotFound]; return; } - request.value = value; + request.value = + [value subdataWithRange:NSMakeRange(request.offset, value.length - request.offset)]; [_peripheralManager respondToRequest:request withResult:CBATTErrorSuccess]; }