react-native-ble-manager 11.0.3 → 11.0.5
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/BleManager.swift +8 -2
- package/ios/Helper.swift +7 -4
- package/package.json +1 -1
package/ios/BleManager.swift
CHANGED
|
@@ -197,6 +197,10 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
|
|
|
197
197
|
initOptions[CBCentralManagerOptionShowPowerAlertKey] = showAlert
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
if let verboseLogging = options["verboseLogging"] as? Bool {
|
|
201
|
+
BleManager.verboseLogging = verboseLogging
|
|
202
|
+
}
|
|
203
|
+
|
|
200
204
|
var queue: DispatchQueue
|
|
201
205
|
if let queueIdentifierKey = options["queueIdentifierKey"] as? String {
|
|
202
206
|
queue = DispatchQueue(label: queueIdentifierKey, qos: DispatchQoS.background)
|
|
@@ -1035,10 +1039,12 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
|
|
|
1035
1039
|
return
|
|
1036
1040
|
}
|
|
1037
1041
|
|
|
1038
|
-
|
|
1042
|
+
if BleManager.verboseLogging, let value = characteristic.value {
|
|
1043
|
+
NSLog("Read value [\(characteristic.uuid)]: \( value.hexadecimalString())")
|
|
1044
|
+
}
|
|
1039
1045
|
|
|
1040
1046
|
if readCallbacks[key] != nil {
|
|
1041
|
-
invokeAndClearDictionary(&readCallbacks, withKey: key, usingParameters: [NSNull(), characteristic.value
|
|
1047
|
+
invokeAndClearDictionary(&readCallbacks, withKey: key, usingParameters: [NSNull(), characteristic.value!.toArray()])
|
|
1042
1048
|
} else {
|
|
1043
1049
|
if hasListeners {
|
|
1044
1050
|
sendEvent(withName: "BleManagerDidUpdateValueForCharacteristic", body: [
|
package/ios/Helper.swift
CHANGED
|
@@ -105,11 +105,11 @@ class Helper {
|
|
|
105
105
|
if mfgData.count > 1 {
|
|
106
106
|
let manufactureID = UInt16(mfgData[0]) + UInt16(mfgData[1]) << 8
|
|
107
107
|
var manInfo: [String: Any] = [:]
|
|
108
|
-
manInfo[String(format: "%04X", manufactureID)] = mfgData.subdata(in: 2..<mfgData.endIndex)
|
|
109
|
-
adv["manufacturerData"] =
|
|
108
|
+
manInfo[String(format: "%04X", manufactureID)] = mfgData.subdata(in: 2..<mfgData.endIndex).toArray()
|
|
109
|
+
adv["manufacturerData"] = manInfo
|
|
110
110
|
}
|
|
111
111
|
adv.removeValue(forKey: CBAdvertisementDataManufacturerDataKey)
|
|
112
|
-
adv["manufacturerRawData"] = mfgData
|
|
112
|
+
adv["manufacturerRawData"] = mfgData.toArray()
|
|
113
113
|
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -340,7 +340,10 @@ class BLECommandContext:NSObject {
|
|
|
340
340
|
extension Data {
|
|
341
341
|
func hexadecimalString() -> String {
|
|
342
342
|
/* Returns hexadecimal string of Data. Empty string if data is empty. */
|
|
343
|
-
|
|
343
|
+
if self.isEmpty {
|
|
344
|
+
return ""
|
|
345
|
+
}
|
|
346
|
+
return map { "0x" + String(format: "%02hhx", $0) }.joined(separator: " ")
|
|
344
347
|
}
|
|
345
348
|
|
|
346
349
|
func toArray() -> [NSNumber] {
|