react-native-ble-manager 11.0.2 → 11.0.4

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.
@@ -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
- NSLog("Read value [\(characteristic.uuid)]: (\(String(describing: characteristic.value?.hexadecimalString()))")
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
@@ -12,9 +12,9 @@ class Helper {
12
12
  case .unauthorized:
13
13
  return "unauthorized"
14
14
  case .poweredOff:
15
- return "poweredOff"
15
+ return "off"
16
16
  case .poweredOn:
17
- return "poweredOn"
17
+ return "on"
18
18
  @unknown default:
19
19
  return "unknown"
20
20
  }
@@ -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
- return map { String(format: "%02hhx", $0) }.joined()
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] {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "11.0.2",
3
+ "version": "11.0.4",
4
4
  "description": "A BLE module for react native.",
5
5
  "repository": {
6
6
  "type": "git",