react-native-ble-manager 12.4.5 → 12.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/SwiftBleManager.swift +21 -9
- package/package.json +1 -1
|
@@ -32,6 +32,15 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
32
32
|
|
|
33
33
|
private let serialQueue = DispatchQueue(label: "BleManager.serialQueue")
|
|
34
34
|
|
|
35
|
+
// Structured error payload so JS can detect specific failures by (domain, code).
|
|
36
|
+
private static func errorPayload(_ error: Error) -> [String: Any] {
|
|
37
|
+
return [
|
|
38
|
+
"code": error._code,
|
|
39
|
+
"domain": error._domain,
|
|
40
|
+
"message": error.localizedDescription,
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
private var exactAdvertisingName: [String]
|
|
36
45
|
|
|
37
46
|
static var verboseLogging = false
|
|
@@ -1241,14 +1250,17 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1241
1250
|
didFailToConnect peripheral: CBPeripheral,
|
|
1242
1251
|
error: Error?
|
|
1243
1252
|
) {
|
|
1244
|
-
|
|
1253
|
+
NSLog(
|
|
1245
1254
|
"Peripheral connection failure: \(peripheral.uuidAsString() ) (\(error?.localizedDescription ?? "")"
|
|
1246
|
-
|
|
1255
|
+
)
|
|
1247
1256
|
|
|
1257
|
+
let errorParam: Any =
|
|
1258
|
+
error.map(SwiftBleManager.errorPayload)
|
|
1259
|
+
?? "Peripheral connection failure: \(peripheral.uuidAsString())"
|
|
1248
1260
|
invokeAndClearDictionary(
|
|
1249
1261
|
&connectCallbacks,
|
|
1250
1262
|
withKey: peripheral.uuidAsString(),
|
|
1251
|
-
usingParameters: [
|
|
1263
|
+
usingParameters: [errorParam]
|
|
1252
1264
|
)
|
|
1253
1265
|
}
|
|
1254
1266
|
|
|
@@ -1460,7 +1472,7 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1460
1472
|
invokeAndClearDictionary(
|
|
1461
1473
|
&retrieveServicesCallbacks,
|
|
1462
1474
|
withKey: peripheral.uuidAsString(),
|
|
1463
|
-
usingParameters: [error
|
|
1475
|
+
usingParameters: [SwiftBleManager.errorPayload(error)]
|
|
1464
1476
|
)
|
|
1465
1477
|
return
|
|
1466
1478
|
}
|
|
@@ -1612,7 +1624,7 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1612
1624
|
invokeAndClearDictionary(
|
|
1613
1625
|
&readRSSICallbacks,
|
|
1614
1626
|
withKey: peripheral.uuidAsString(),
|
|
1615
|
-
usingParameters: [error
|
|
1627
|
+
usingParameters: [SwiftBleManager.errorPayload(error), RSSI]
|
|
1616
1628
|
)
|
|
1617
1629
|
} else {
|
|
1618
1630
|
invokeAndClearDictionary(
|
|
@@ -1641,7 +1653,7 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1641
1653
|
invokeAndClearDictionary(
|
|
1642
1654
|
&readDescriptorCallbacks,
|
|
1643
1655
|
withKey: key,
|
|
1644
|
-
usingParameters: [error
|
|
1656
|
+
usingParameters: [SwiftBleManager.errorPayload(error), NSNull()]
|
|
1645
1657
|
)
|
|
1646
1658
|
return
|
|
1647
1659
|
}
|
|
@@ -1723,7 +1735,7 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1723
1735
|
invokeAndClearDictionary(
|
|
1724
1736
|
&readCallbacks,
|
|
1725
1737
|
withKey: key,
|
|
1726
|
-
usingParameters: [error
|
|
1738
|
+
usingParameters: [SwiftBleManager.errorPayload(error), NSNull()]
|
|
1727
1739
|
)
|
|
1728
1740
|
return
|
|
1729
1741
|
}
|
|
@@ -1880,7 +1892,7 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1880
1892
|
invokeAndClearDictionary(
|
|
1881
1893
|
&writeDescriptorCallbacks,
|
|
1882
1894
|
withKey: key,
|
|
1883
|
-
usingParameters: [error
|
|
1895
|
+
usingParameters: [SwiftBleManager.errorPayload(error)]
|
|
1884
1896
|
)
|
|
1885
1897
|
} else {
|
|
1886
1898
|
invokeAndClearDictionary(
|
|
@@ -1911,7 +1923,7 @@ public class SwiftBleManager: NSObject, CBCentralManagerDelegate,
|
|
|
1911
1923
|
invokeAndClearDictionary(
|
|
1912
1924
|
&writeCallbacks,
|
|
1913
1925
|
withKey: key,
|
|
1914
|
-
usingParameters: [error
|
|
1926
|
+
usingParameters: [SwiftBleManager.errorPayload(error)]
|
|
1915
1927
|
)
|
|
1916
1928
|
serialQueue.sync {
|
|
1917
1929
|
writeQueues.removeValue(forKey: key)
|