Do not normalize UUIDs on native side (#138)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
## 0.16.0
|
||||
* Bump bluez to 0.8.3
|
||||
* Improve readme
|
||||
* Do not normalize UUIDs on native side
|
||||
* Reverse _permissionStatus return values in example app
|
||||
|
||||
## 0.15.0
|
||||
|
||||
@@ -73,16 +73,8 @@ fun Int.toBleConnectionState(): BleConnectionState {
|
||||
}
|
||||
}
|
||||
|
||||
fun String.validFullUUID(): String {
|
||||
return when (this.count()) {
|
||||
4 -> "0000$this-0000-1000-8000-00805F9B34FB"
|
||||
8 -> "$this-0000-1000-8000-00805F9B34FB"
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
fun List<String>.toUUIDList(): List<UUID> {
|
||||
return this.map { UUID.fromString(it.validFullUUID()) }
|
||||
return this.map { UUID.fromString(it) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -143,20 +143,6 @@ public extension CBPeripheral {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
var validFullUUID: String {
|
||||
let uuidLength = count
|
||||
if uuidLength == 4 || uuidLength == 8 {
|
||||
let baseUuid = "00000000-0000-1000-8000-00805F9B34FB"
|
||||
let start = baseUuid.startIndex
|
||||
let range = baseUuid.index(start, offsetBy: 4 - uuidLength) ..< baseUuid.index(start, offsetBy: 4)
|
||||
return baseUuid.replacingCharacters(in: range, with: self).lowercased()
|
||||
} else {
|
||||
return self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension FlutterStandardTypedData {
|
||||
func toData() -> Data {
|
||||
return Data(data)
|
||||
|
||||
@@ -348,7 +348,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
|
||||
isPaired: nil,
|
||||
rssi: RSSI as? Int64,
|
||||
manufacturerDataList: manufacturerDataList,
|
||||
services: services?.map { $0.uuidStr.validFullUUID }
|
||||
services: services?.map { $0.uuidStr }
|
||||
)) { _ in }
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ extension String {
|
||||
extension [String] {
|
||||
func toCBUUID() throws -> [CBUUID] {
|
||||
return try compactMap { serviceUUID in
|
||||
guard UUID(uuidString: serviceUUID.validFullUUID) != nil else {
|
||||
guard UUID(uuidString: serviceUUID) != nil else {
|
||||
throw PigeonError(code: "IllegalArgument", message: "Invalid service UUID:\(serviceUUID)", details: nil)
|
||||
}
|
||||
return CBUUID(string: serviceUUID)
|
||||
|
||||
Reference in New Issue
Block a user