diff --git a/ios/MultiplatformBleAdapter/BleExtensions.swift b/ios/MultiplatformBleAdapter/BleExtensions.swift index e9c73adb..5b64d457 100644 --- a/ios/MultiplatformBleAdapter/BleExtensions.swift +++ b/ios/MultiplatformBleAdapter/BleExtensions.swift @@ -47,21 +47,27 @@ extension ScannedPeripheral { .solicitedServiceUUIDs? .map { (uuid: CBUUID) in uuid.fullUUIDString } - return [ - "id": peripheral.identifier.uuidString, - "name": peripheral.name as Any, - "rssi": rssi, - "mtu": mtu, + let advertisementDataDict: [AnyHashable: Any] = [ + "localName": advertisementData.localName as Any, "manufacturerData": manufacturerData as Any, "serviceData": serviceData as Any, "serviceUUIDs": serviceUUIDs as Any, - "localName": advertisementData.localName as Any, "txPowerLevel": advertisementData.txPowerLevel as Any, - "solicitedServiceUUIDs": solicitedServiceUUIDs as Any, "isConnectable": advertisementData.isConnectable as Any, + "solicitedServiceUUIDs": solicitedServiceUUIDs as Any, "overflowServiceUUIDs": overflowServiceUUIDs as Any - "rawScanRecord": advertisementData as Any + ] + + let advertisementDataJSON = try? JSONSerialization.data(withJSONObject: advertisementDataDict, options: []) + let advertisementDataBase64 = advertisementDataJSON?.base64EncodedString() + + return [ + "id": peripheral.identifier.uuidString, + "name": peripheral.name as Any, + "rssi": rssi, + "mtu": mtu, + "rawScanRecord": advertisementDataBase64 as Any ] } } @@ -89,7 +95,7 @@ extension Peripheral { "txPowerLevel": NSNull(), "solicitedServiceUUIDs": NSNull(), "isConnectable": NSNull(), - "overflowServiceUUIDs": NSNull() + "overflowServiceUUIDs": NSNull(), "rawScanRecord": NSNull() ] } @@ -213,4 +219,4 @@ extension BluetoothState { case .poweredOn: return "PoweredOn" } } -} +} \ No newline at end of file