diff --git a/src/android/BluetoothLePlugin.java b/src/android/BluetoothLePlugin.java index ffea195..ec35f09 100644 --- a/src/android/BluetoothLePlugin.java +++ b/src/android/BluetoothLePlugin.java @@ -105,6 +105,7 @@ public class BluetoothLePlugin extends CordovaPlugin { private final String keyMatchMode = "matchMode"; private final String keyMatchNum = "matchNum"; private final String keyCallbackType = "callbackType"; + private final String keyIsLegacy = "isLegacy"; private final String keyAdvertisement = "advertisement"; private final String keyUuid = "uuid"; private final String keyService = "service"; @@ -1287,7 +1288,13 @@ private synchronized void startScanAction(JSONArray args, CallbackContext callba } catch (java.lang.IllegalArgumentException e) { } } - + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + boolean isLegacy = obj.optBoolean(keyIsLegacy, false); + try { + scanSettings.setLegacy(isLegacy); + } catch (IllegalArgumentException e) { + } + } //Start the scan with or without service UUIDs bluetoothAdapter.getBluetoothLeScanner().startScan(scanFilter, scanSettings.build(), scanCallback); } diff --git a/types/index.d.ts b/types/index.d.ts index 638d062..cb5e4cb 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -703,6 +703,11 @@ declare namespace BluetoothlePlugin { callbackType?: BluetoothCallbackType, /** True/false to show only connectable devices, rather than all devices ever seen, defaults to false (Windows)*/ isConnectable?: boolean + /** Used to set whether scanning is in "legacy" mode. In Bluetooth 5, a new scanning mode is introduced to support more + functions and features, such as extended advertising, long data packets, etc. The "legacy" mode only supports + traditional advertising data types and does not support Bluetooth 5's extended advertising. + */ + isLegacy?:boolean } interface ConnectionParams{