darwin: Get and prefer advertised name of scanned devices

This commit is contained in:
Jonas Greifenhain
2025-05-27 19:04:16 +02:00
committed by Foti Dim
parent 4f9ad0b9e6
commit 7228b554f9
+5 -2
View File
@@ -337,14 +337,17 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
manufacturerDataList.append(universalManufacturerData!) manufacturerDataList.append(universalManufacturerData!)
} }
let advertisedName = advertisementData[CBAdvertisementDataLocalNameKey] as? String
let displayName = advertisedName ?? peripheral.name
// Apply custom filters and return early if the peripheral doesn't match // Apply custom filters and return early if the peripheral doesn't match
if !universalBleFilterUtil.filterDevice(name: peripheral.name, manufacturerData: universalManufacturerData, services: services) { if !universalBleFilterUtil.filterDevice(name: displayName, manufacturerData: universalManufacturerData, services: services) {
return return
} }
callbackChannel.onScanResult(result: UniversalBleScanResult( callbackChannel.onScanResult(result: UniversalBleScanResult(
deviceId: peripheral.uuid.uuidString, deviceId: peripheral.uuid.uuidString,
name: peripheral.name, name: displayName,
isPaired: nil, isPaired: nil,
rssi: RSSI as? Int64, rssi: RSSI as? Int64,
manufacturerDataList: manufacturerDataList, manufacturerDataList: manufacturerDataList,