Skip to content

Commit

Permalink
new field raw data
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilNatonek committed Nov 12, 2023
1 parent 559781f commit 715dce6
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions iOS/classes/BleExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,28 @@ 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
]

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 All @@ -88,7 +95,8 @@ extension Peripheral {
"txPowerLevel": NSNull(),
"solicitedServiceUUIDs": NSNull(),
"isConnectable": NSNull(),
"overflowServiceUUIDs": NSNull()
"overflowServiceUUIDs": NSNull(),
"rawScanRecord": NSNull()
]
}
}
Expand Down Expand Up @@ -211,4 +219,4 @@ extension BluetoothState {
case .poweredOn: return "PoweredOn"
}
}
}
}

0 comments on commit 715dce6

Please sign in to comment.