Skip to content

Commit

Permalink
feat: rawScanRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilNatonek committed Nov 13, 2023
1 parent 8736dc1 commit 555a192
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions ios/MultiplatformBleAdapter/BleExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
}
}
Expand Down Expand Up @@ -89,7 +95,7 @@ extension Peripheral {
"txPowerLevel": NSNull(),
"solicitedServiceUUIDs": NSNull(),
"isConnectable": NSNull(),
"overflowServiceUUIDs": NSNull()
"overflowServiceUUIDs": NSNull(),
"rawScanRecord": NSNull()
]
}
Expand Down Expand Up @@ -213,4 +219,4 @@ extension BluetoothState {
case .poweredOn: return "PoweredOn"
}
}
}
}

0 comments on commit 555a192

Please sign in to comment.