react-native-ble-manager 8.4.4 → 8.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/README.md CHANGED
@@ -691,12 +691,12 @@ The scanning for peripherals is ended.
691
691
 
692
692
  **Arguments**
693
693
 
694
- - `none`
694
+ - `status` - `Number` - [iOS] the reason for stopping the scan. Error code 10 is used for timeouts, 0 covers everything else. [Android] the reason for stopping the scan (<https://developer.android.com/reference/android/bluetooth/le/ScanCallback#constants_1>). Error code 10 is used for timeouts
695
695
 
696
696
  **Examples**
697
697
 
698
698
  ```js
699
- bleManagerEmitter.addListener("BleManagerStopScan", () => {
699
+ bleManagerEmitter.addListener("BleManagerStopScan", (args) => {
700
700
  // Scanning is stopped
701
701
  });
702
702
  ```
@@ -218,6 +218,7 @@ class BleManager extends ReactContextBaseJavaModule {
218
218
  if (scanManager != null) {
219
219
  scanManager.stopScan(callback);
220
220
  WritableMap map = Arguments.createMap();
221
+ map.putInt("status", 0);
221
222
  sendEvent("BleManagerStopScan", map);
222
223
  }
223
224
  }
@@ -80,6 +80,7 @@ public class LegacyScanManager extends ScanManager {
80
80
  btAdapter.stopLeScan(mLeScanCallback);
81
81
  }
82
82
  WritableMap map = Arguments.createMap();
83
+ map.putInt("status", 0);
83
84
  bleManager.sendEvent("BleManagerStopScan", map);
84
85
  }
85
86
  }
@@ -39,7 +39,7 @@ public class LollipopScanManager extends ScanManager {
39
39
  ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder();
40
40
  List<ScanFilter> filters = new ArrayList<>();
41
41
 
42
- if (options.hasKey("legacy")) {
42
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && options.hasKey("legacy")) {
43
43
  scanSettingsBuilder.setLegacy(options.getBoolean("legacy"));
44
44
  }
45
45
 
@@ -101,6 +101,7 @@ public class LollipopScanManager extends ScanManager {
101
101
  btAdapter.getBluetoothLeScanner().stopScan(mScanCallback);
102
102
  }
103
103
  WritableMap map = Arguments.createMap();
104
+ map.putInt("status", 10);
104
105
  bleManager.sendEvent("BleManagerStopScan", map);
105
106
  }
106
107
  }
@@ -145,6 +146,7 @@ public class LollipopScanManager extends ScanManager {
145
146
  @Override
146
147
  public void onScanFailed(final int errorCode) {
147
148
  WritableMap map = Arguments.createMap();
149
+ map.putInt("status", errorCode);
148
150
  bleManager.sendEvent("BleManagerStopScan", map);
149
151
  }
150
152
  };
@@ -834,8 +834,11 @@ public class Peripheral extends BluetoothGattCallback {
834
834
  else
835
835
  writeCallback = null;
836
836
  if (!gatt.writeCharacteristic(characteristic)) {
837
- sendBackrError(writeCallback, "Write failed");
838
- writeCallback = null;
837
+ // For write without response the caller will handle all callback states
838
+ if (writeCallback != null) {
839
+ writeCallback.invoke("Write failed", writeCallback);
840
+ writeCallback = null;
841
+ }
839
842
  completedCommand();
840
843
  }
841
844
  }
package/ios/BleManager.m CHANGED
@@ -378,7 +378,7 @@ RCT_EXPORT_METHOD(stopScan:(nonnull RCTResponseSenderBlock)callback)
378
378
  }
379
379
  [manager stopScan];
380
380
  if (hasListeners) {
381
- [self sendEventWithName:@"BleManagerStopScan" body:@{}];
381
+ [self sendEventWithName:@"BleManagerStopScan" body:@{@"status": @0}];
382
382
  }
383
383
  callback(@[[NSNull null]]);
384
384
  }
@@ -390,7 +390,7 @@ RCT_EXPORT_METHOD(stopScan:(nonnull RCTResponseSenderBlock)callback)
390
390
  [manager stopScan];
391
391
  if (hasListeners) {
392
392
  if (self.bridge) {
393
- [self sendEventWithName:@"BleManagerStopScan" body:@{}];
393
+ [self sendEventWithName:@"BleManagerStopScan" body:@{@"status": @10}];
394
394
  }
395
395
  }
396
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-manager",
3
- "version": "8.4.4",
3
+ "version": "8.5.0",
4
4
  "description": "A BLE module for react native.",
5
5
  "main": "BleManager",
6
6
  "types": "./index.d.ts",