react-native-ble-manager 11.5.3 → 11.5.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.
@@ -122,14 +122,17 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
122
122
  // Helper method to call the callbacks for a specific peripheral and clear the queue
123
123
  func invokeAndClearDictionary(_ dictionary: inout Dictionary<String, [RCTResponseSenderBlock]>, withKey key: String, usingParameters parameters: [Any]) {
124
124
  serialQueue.sync {
125
-
126
- if let peripheralCallbacks = dictionary[key] {
127
- for callback in peripheralCallbacks {
128
- callback(parameters)
129
- }
130
-
131
- dictionary.removeValue(forKey: key)
125
+ invokeAndClearDictionary_THREAD_UNSAFE(&dictionary, withKey: key, usingParameters: parameters)
126
+ }
127
+ }
128
+
129
+ func invokeAndClearDictionary_THREAD_UNSAFE(_ dictionary: inout Dictionary<String, [RCTResponseSenderBlock]>, withKey key: String, usingParameters parameters: [Any]) {
130
+ if let peripheralCallbacks = dictionary[key] {
131
+ for callback in peripheralCallbacks {
132
+ callback(parameters)
132
133
  }
134
+
135
+ dictionary.removeValue(forKey: key)
133
136
  }
134
137
  }
135
138
 
@@ -1078,16 +1081,18 @@ class BleManager: RCTEventEmitter, CBCentralManagerDelegate, CBPeripheralDelegat
1078
1081
  NSLog("Read value [\(characteristic.uuid)]: \( value.hexadecimalString())")
1079
1082
  }
1080
1083
 
1081
- if readCallbacks[key] != nil {
1082
- invokeAndClearDictionary(&readCallbacks, withKey: key, usingParameters: [NSNull(), characteristic.value!.toArray()])
1083
- } else {
1084
- if hasListeners {
1085
- sendEvent(withName: "BleManagerDidUpdateValueForCharacteristic", body: [
1086
- "peripheral": peripheral.uuidAsString(),
1087
- "characteristic": characteristic.uuid.uuidString.lowercased(),
1088
- "service": characteristic.service!.uuid.uuidString.lowercased(),
1089
- "value": characteristic.value!.toArray()
1090
- ])
1084
+ serialQueue.sync {
1085
+ if readCallbacks[key] != nil {
1086
+ invokeAndClearDictionary_THREAD_UNSAFE(&readCallbacks, withKey: key, usingParameters: [NSNull(), characteristic.value!.toArray()])
1087
+ } else {
1088
+ if hasListeners {
1089
+ sendEvent(withName: "BleManagerDidUpdateValueForCharacteristic", body: [
1090
+ "peripheral": peripheral.uuidAsString(),
1091
+ "characteristic": characteristic.uuid.uuidString.lowercased(),
1092
+ "service": characteristic.service!.uuid.uuidString.lowercased(),
1093
+ "value": characteristic.value!.toArray()
1094
+ ])
1095
+ }
1091
1096
  }
1092
1097
  }
1093
1098
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "11.5.3",
3
+ "version": "11.5.4",
4
4
  "description": "A BLE module for react native.",
5
5
  "repository": {
6
6
  "type": "git",