react-native-ble-manager 11.0.4 → 11.0.6

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.
@@ -419,8 +419,10 @@ public class Peripheral extends BluetoothGattCallback {
419
419
 
420
420
  @Override
421
421
  public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
422
- super.onCharacteristicChanged(gatt, characteristic);
423
- onCharacteristicChanged(gatt, characteristic, characteristic.getValue());
422
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
423
+ super.onCharacteristicChanged(gatt, characteristic);
424
+ onCharacteristicChanged(gatt, characteristic, characteristic.getValue());
425
+ }
424
426
  }
425
427
 
426
428
  @Override
@@ -468,8 +470,10 @@ public class Peripheral extends BluetoothGattCallback {
468
470
 
469
471
  @Override
470
472
  public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
471
- super.onCharacteristicRead(gatt, characteristic, status);
472
- onCharacteristicRead(gatt, characteristic, characteristic.getValue(), status);
473
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
474
+ super.onCharacteristicRead(gatt, characteristic, status);
475
+ onCharacteristicRead(gatt, characteristic, characteristic.getValue(), status);
476
+ }
473
477
  }
474
478
  @Override
475
479
  public void onCharacteristicRead(@NonNull final BluetoothGatt gatt,
@@ -686,7 +686,7 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
686
686
  }
687
687
 
688
688
  @objc func getMaximumWriteValueLengthForWithResponse(_ peripheralUUID: String,
689
- callback: @escaping RCTResponseSenderBlock) {
689
+ callback: @escaping RCTResponseSenderBlock) {
690
690
  NSLog("getMaximumWriteValueLengthForWithResponse")
691
691
 
692
692
  guard let peripheral = peripherals[peripheralUUID] else {
@@ -717,7 +717,7 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
717
717
  }
718
718
  }
719
719
  }
720
-
720
+
721
721
 
722
722
  func centralManager(_ central: CBCentralManager,
723
723
  didConnect peripheral: CBPeripheral) {
@@ -1072,41 +1072,43 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
1072
1072
  "code": error._code
1073
1073
  ])
1074
1074
  }
1075
+ } else {
1076
+ if hasListeners {
1077
+ sendEvent(withName: "BleManagerDidUpdateNotificationStateFor", body: [
1078
+ "peripheral": peripheral.uuidAsString(),
1079
+ "characteristic": characteristic.uuid.uuidString.lowercased(),
1080
+ "isNotifying": characteristic.isNotifying
1081
+ ])
1082
+ }
1075
1083
  }
1076
1084
 
1077
1085
  let key = Helper.key(forPeripheral: peripheral, andCharacteristic: characteristic)
1078
1086
 
1079
- if characteristic.isNotifying {
1087
+ if let error = error {
1080
1088
  if notificationCallbacks[key] != nil {
1081
- if let error = error {
1082
- invokeAndClearDictionary(&notificationCallbacks, withKey: key, usingParameters: [error])
1083
- } else {
1084
- if BleManager.verboseLogging {
1085
- NSLog("Notification began on \(characteristic.uuid)")
1086
- }
1087
- invokeAndClearDictionary(&notificationCallbacks, withKey: key, usingParameters: [])
1088
- }
1089
+ invokeAndClearDictionary(&notificationCallbacks, withKey: key, usingParameters: [error])
1089
1090
  }
1090
- } else {
1091
- // Notification has stopped
1092
1091
  if stopNotificationCallbacks[key] != nil {
1093
- if error != nil {
1094
- invokeAndClearDictionary(&stopNotificationCallbacks, withKey: key, usingParameters: [error as Any])
1095
- } else {
1096
- if BleManager.verboseLogging {
1097
- NSLog("Notification ended on \(characteristic.uuid)")
1098
- }
1092
+ invokeAndClearDictionary(&stopNotificationCallbacks, withKey: key, usingParameters: [error])
1093
+ }
1094
+ } else {
1095
+ if characteristic.isNotifying {
1096
+ if BleManager.verboseLogging {
1097
+ NSLog("Notification began on \(characteristic.uuid)")
1098
+ }
1099
+ if notificationCallbacks[key] != nil {
1100
+ invokeAndClearDictionary(&notificationCallbacks, withKey: key, usingParameters: [])
1101
+ }
1102
+ } else {
1103
+ // Notification has stopped
1104
+ if BleManager.verboseLogging {
1105
+ NSLog("Notification ended on \(characteristic.uuid)")
1106
+ }
1107
+ if stopNotificationCallbacks[key] != nil {
1099
1108
  invokeAndClearDictionary(&stopNotificationCallbacks, withKey: key, usingParameters: [])
1100
1109
  }
1101
1110
  }
1102
1111
  }
1103
- if hasListeners {
1104
- sendEvent(withName: "BleManagerDidUpdateNotificationStateFor", body: [
1105
- "peripheral": peripheral.uuidAsString(),
1106
- "characteristic": characteristic.uuid.uuidString.lowercased(),
1107
- "isNotifying": characteristic.isNotifying
1108
- ])
1109
- }
1110
1112
  }
1111
1113
 
1112
1114
  func peripheral(_ peripheral: CBPeripheral,
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"] = mfgData
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "11.0.4",
3
+ "version": "11.0.6",
4
4
  "description": "A BLE module for react native.",
5
5
  "repository": {
6
6
  "type": "git",