@capacitor-community/bluetooth-le 7.1.0 → 7.2.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
@@ -13,7 +13,7 @@
13
13
  <a href="https://www.npmjs.com/package/@capacitor-community/bluetooth-le"><img src="https://img.shields.io/npm/dw/@capacitor-community/bluetooth-le?style=flat-square" /></a>
14
14
  <a href="https://www.npmjs.com/package/@capacitor-community/bluetooth-le"><img src="https://img.shields.io/npm/v/@capacitor-community/bluetooth-le?style=flat-square" /></a>
15
15
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
16
- <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-22-orange?style=flat-square" /></a>
16
+ <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-23-orange?style=flat-square" /></a>
17
17
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
18
  </p>
19
19
 
@@ -255,7 +255,7 @@ export async function main(): Promise<void> {
255
255
  HEART_RATE_MEASUREMENT_CHARACTERISTIC,
256
256
  (value) => {
257
257
  console.log('current heart rate', parseHeartRate(value));
258
- }
258
+ },
259
259
  );
260
260
 
261
261
  // disconnect after 10 sec
@@ -305,7 +305,7 @@ export async function scan(): Promise<void> {
305
305
  },
306
306
  (result) => {
307
307
  console.log('received new scan result', result);
308
- }
308
+ },
309
309
  );
310
310
 
311
311
  setTimeout(async () => {
@@ -868,7 +868,7 @@ Write a value to a descriptor.
868
868
  ### startNotifications(...)
869
869
 
870
870
  ```typescript
871
- startNotifications(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void) => Promise<void>
871
+ startNotifications(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void, options?: TimeoutOptions | undefined) => Promise<void>
872
872
  ```
873
873
 
874
874
  Start listening to changes of the value of a characteristic.
@@ -882,6 +882,7 @@ For an example, see [usage](#usage).
882
882
  | **`service`** | <code>string</code> | UUID of the service (see [UUID format](#uuid-format)) |
883
883
  | **`characteristic`** | <code>string</code> | UUID of the characteristic (see [UUID format](#uuid-format)) |
884
884
  | **`callback`** | <code>(value: <a href="#dataview">DataView</a>) =&gt; void</code> | Callback function to use when the value of the characteristic changes |
885
+ | **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call. Timeout not supported on **web**. |
885
886
 
886
887
  ---
887
888
 
@@ -928,15 +929,23 @@ Stop listening to the changes of the value of a characteristic. For an example,
928
929
 
929
930
  #### RequestBleDeviceOptions
930
931
 
931
- | Prop | Type | Description |
932
- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
933
- | **`services`** | <code>string[]</code> | Filter devices by service UUIDs. UUIDs have to be specified as 128 bit UUID strings, e.g. ['0000180d-0000-1000-8000-00805f9b34fb'] There is a helper function to convert numbers to UUIDs. e.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format)) |
934
- | **`name`** | <code>string</code> | Filter devices by name |
935
- | **`namePrefix`** | <code>string</code> | Filter devices by name prefix |
936
- | **`optionalServices`** | <code>string[]</code> | For **web**, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) |
937
- | **`allowDuplicates`** | <code>boolean</code> | Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`). (default: false) |
938
- | **`scanMode`** | <code><a href="#scanmode">ScanMode</a></code> | Android scan mode (default: <a href="#scanmode">ScanMode.SCAN_MODE_BALANCED</a>) |
939
- | **`manufacturerData`** | <code>{ companyIdentifier: number; dataPrefix?: <a href="#uint8array">Uint8Array</a>; mask?: <a href="#uint8array">Uint8Array</a>; }[]</code> | Allow scanning for devices with a specific manufacturer data https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata |
932
+ | Prop | Type | Description |
933
+ | ---------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
934
+ | **`services`** | <code>string[]</code> | Filter devices by service UUIDs. UUIDs have to be specified as 128 bit UUID strings, e.g. ['0000180d-0000-1000-8000-00805f9b34fb'] There is a helper function to convert numbers to UUIDs. e.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format)) |
935
+ | **`name`** | <code>string</code> | Filter devices by name |
936
+ | **`namePrefix`** | <code>string</code> | Filter devices by name prefix |
937
+ | **`optionalServices`** | <code>string[]</code> | For **web**, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) |
938
+ | **`allowDuplicates`** | <code>boolean</code> | Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`). (default: false) |
939
+ | **`scanMode`** | <code><a href="#scanmode">ScanMode</a></code> | Android scan mode (default: <a href="#scanmode">ScanMode.SCAN_MODE_BALANCED</a>) |
940
+ | **`manufacturerData`** | <code>ManufacturerDataFilter[]</code> | Allow scanning for devices with a specific manufacturer data https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata |
941
+
942
+ #### ManufacturerDataFilter
943
+
944
+ | Prop | Type | Description |
945
+ | ----------------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
946
+ | **`companyIdentifier`** | <code>number</code> | Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field. |
947
+ | **`dataPrefix`** | <code><a href="#uint8array">Uint8Array</a></code> | Prefix to match in the manufacturer data field. On **Android** this field is mandatory. |
948
+ | **`mask`** | <code><a href="#uint8array">Uint8Array</a></code> | Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0. The `mask` must have the same length of dataPrefix. |
940
949
 
941
950
  #### Uint8Array
942
951
 
@@ -1201,6 +1210,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1201
1210
  </tr>
1202
1211
  <tr>
1203
1212
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/gion-andri"><img src="https://avatars.githubusercontent.com/u/540998?v=4?s=100" width="100px;" alt="Gion-Andri Cantieni"/><br /><sub><b>Gion-Andri Cantieni</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=gion-andri" title="Code">💻</a></td>
1213
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/JasonAsmk"><img src="https://avatars.githubusercontent.com/u/994111?v=4?s=100" width="100px;" alt="Iason Asimakopoulos"/><br /><sub><b>Iason Asimakopoulos</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=JasonAsmk" title="Code">💻</a></td>
1204
1214
  </tr>
1205
1215
  </tbody>
1206
1216
  </table>
@@ -757,6 +757,7 @@ class BluetoothLe : Plugin() {
757
757
  fun startNotifications(call: PluginCall) {
758
758
  val device = getDevice(call) ?: return
759
759
  val characteristic = getCharacteristic(call) ?: return
760
+ val timeout = call.getFloat("timeout", DEFAULT_TIMEOUT)!!.toLong()
760
761
  device.setNotifications(characteristic.first, characteristic.second, true, { response ->
761
762
  run {
762
763
  val key =
@@ -769,7 +770,7 @@ class BluetoothLe : Plugin() {
769
770
  Logger.error(TAG, "Error in notifyListeners: ${e.localizedMessage}", e)
770
771
  }
771
772
  }
772
- }, { response ->
773
+ }, timeout, { response ->
773
774
  run {
774
775
  if (response.success) {
775
776
  call.resolve()
@@ -784,8 +785,9 @@ class BluetoothLe : Plugin() {
784
785
  fun stopNotifications(call: PluginCall) {
785
786
  val device = getDevice(call) ?: return
786
787
  val characteristic = getCharacteristic(call) ?: return
788
+ val timeout = call.getFloat("timeout", DEFAULT_TIMEOUT)!!.toLong()
787
789
  device.setNotifications(
788
- characteristic.first, characteristic.second, false, null
790
+ characteristic.first, characteristic.second, false, null, timeout
789
791
  ) { response ->
790
792
  run {
791
793
  if (response.success) {
@@ -874,6 +876,13 @@ class BluetoothLe : Plugin() {
874
876
  filters.add(filterBuilder.build())
875
877
  }
876
878
  }
879
+ // Create filters when providing only name
880
+ if (name != null && filters.isEmpty()) {
881
+ val filterBuilder = ScanFilter.Builder()
882
+ filterBuilder.setDeviceName(name)
883
+ filters.add(filterBuilder.build())
884
+ }
885
+
877
886
  return filters;
878
887
  } catch (e: IllegalArgumentException) {
879
888
  call.reject("Invalid UUID or Manufacturer data provided.")
@@ -68,6 +68,7 @@ class Device(
68
68
  private var device: BluetoothDevice = bluetoothAdapter.getRemoteDevice(address)
69
69
  private var bluetoothGatt: BluetoothGatt? = null
70
70
  private var callbackMap = HashMap<String, ((CallbackResponse) -> Unit)>()
71
+ private val bondReceiverMap = HashMap<String, BroadcastReceiver>()
71
72
  private val timeoutQueue = ConcurrentLinkedQueue<TimeoutHandler>()
72
73
  private var bondStateReceiver: BroadcastReceiver? = null
73
74
  private var currentMtu = -1
@@ -280,6 +281,9 @@ class Device(
280
281
  super.onDescriptorWrite(gatt, descriptor, status)
281
282
  val key =
282
283
  "writeDescriptor|${descriptor.characteristic.service.uuid}|${descriptor.characteristic.uuid}|${descriptor.uuid}"
284
+ bondReceiverMap.remove(key)?.let {
285
+ context.unregisterReceiver(it)
286
+ }
283
287
  if (status == BluetoothGatt.GATT_SUCCESS) {
284
288
  resolve(key, "Descriptor successfully written.")
285
289
  } else {
@@ -546,6 +550,7 @@ class Device(
546
550
  characteristicUUID: UUID,
547
551
  enable: Boolean,
548
552
  notifyCallback: ((CallbackResponse) -> Unit)?,
553
+ timeout: Long,
549
554
  callback: (CallbackResponse) -> Unit,
550
555
  ) {
551
556
  val key = "writeDescriptor|$serviceUUID|$characteristicUUID|$CLIENT_CHARACTERISTIC_CONFIG"
@@ -585,9 +590,47 @@ class Device(
585
590
  BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE
586
591
  }
587
592
 
593
+ val bondReceiver = object : BroadcastReceiver() {
594
+ override fun onReceive(ctx: Context, intent: Intent) {
595
+ if (intent.action == BluetoothDevice.ACTION_BOND_STATE_CHANGED) {
596
+ val updatedDevice =
597
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
598
+ intent.getParcelableExtra(
599
+ BluetoothDevice.EXTRA_DEVICE,
600
+ BluetoothDevice::class.java
601
+ )
602
+ } else {
603
+ intent.getParcelableExtra<BluetoothDevice>(BluetoothDevice.EXTRA_DEVICE)
604
+ }
605
+
606
+ // BroadcastReceiver receives bond state updates from all devices, need to filter by device
607
+ if (device.address == updatedDevice?.address) {
608
+ val prev = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, -1)
609
+ val state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1)
610
+ if (state == BluetoothDevice.BOND_BONDED) {
611
+ ctx.unregisterReceiver(this)
612
+ } else if (prev == BluetoothDevice.BOND_BONDING && state == BluetoothDevice.BOND_NONE) {
613
+ ctx.unregisterReceiver(this)
614
+ reject(key, "Pairing request was cancelled by the user.")
615
+ } else if (state == -1) {
616
+ ctx.unregisterReceiver(this)
617
+ }
618
+ }
619
+ }
620
+ }
621
+ }
622
+ bondReceiverMap[key] = bondReceiver
623
+ context.registerReceiver(
624
+ bondReceiver,
625
+ IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)
626
+ )
627
+
588
628
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
589
629
  val statusCode = bluetoothGatt?.writeDescriptor(descriptor, value)
590
630
  if (statusCode != BluetoothStatusCodes.SUCCESS) {
631
+ bondReceiverMap.remove(key)?.let {
632
+ context.unregisterReceiver(it)
633
+ }
591
634
  reject(key, "Setting notification failed with status code $statusCode.")
592
635
  return
593
636
  }
@@ -595,11 +638,15 @@ class Device(
595
638
  descriptor.value = value
596
639
  val resultDesc = bluetoothGatt?.writeDescriptor(descriptor)
597
640
  if (resultDesc != true) {
641
+ bondReceiverMap.remove(key)?.let {
642
+ context.unregisterReceiver(it)
643
+ }
598
644
  reject(key, "Setting notification failed.")
599
645
  return
600
646
  }
601
647
 
602
648
  }
649
+ setTimeout(key, "Setting notification timeout.", timeout)
603
650
  // wait for onDescriptorWrite
604
651
  }
605
652
 
package/dist/docs.json CHANGED
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "returns": "Promise<void>",
19
19
  "tags": [],
20
- "docs": "Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\r\nOn **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\r\nFor an example, see [usage](#usage).",
20
+ "docs": "Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\nOn **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\nFor an example, see [usage](#usage).",
21
21
  "complexTypes": [
22
22
  "InitializeOptions"
23
23
  ],
@@ -29,7 +29,7 @@
29
29
  "parameters": [],
30
30
  "returns": "Promise<boolean>",
31
31
  "tags": [],
32
- "docs": "Reports whether Bluetooth is enabled on this device.\r\nAlways returns `true` on **web**.",
32
+ "docs": "Reports whether Bluetooth is enabled on this device.\nAlways returns `true` on **web**.",
33
33
  "complexTypes": [],
34
34
  "slug": "isenabled"
35
35
  },
@@ -39,7 +39,7 @@
39
39
  "parameters": [],
40
40
  "returns": "Promise<void>",
41
41
  "tags": [],
42
- "docs": "Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE\r\nOnly available on **Android**.",
42
+ "docs": "Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE\nOnly available on **Android**.",
43
43
  "complexTypes": [],
44
44
  "slug": "requestenable"
45
45
  },
@@ -54,7 +54,7 @@
54
54
  "text": "Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()"
55
55
  }
56
56
  ],
57
- "docs": "Enable Bluetooth.\r\nOnly available on **Android**.\r\n**Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()",
57
+ "docs": "Enable Bluetooth.\nOnly available on **Android**.\n**Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()",
58
58
  "complexTypes": [],
59
59
  "slug": "enable"
60
60
  },
@@ -69,7 +69,7 @@
69
69
  "text": "Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()"
70
70
  }
71
71
  ],
72
- "docs": "Disable Bluetooth.\r\nOnly available on **Android**.\r\n**Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()",
72
+ "docs": "Disable Bluetooth.\nOnly available on **Android**.\n**Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()",
73
73
  "complexTypes": [],
74
74
  "slug": "disable"
75
75
  },
@@ -90,7 +90,7 @@
90
90
  "text": "callback Callback function to use when the Bluetooth state changes."
91
91
  }
92
92
  ],
93
- "docs": "Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\r\nNot available on **web** (the callback will never be invoked).",
93
+ "docs": "Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\nNot available on **web** (the callback will never be invoked).",
94
94
  "complexTypes": [],
95
95
  "slug": "startenablednotifications"
96
96
  },
@@ -110,7 +110,7 @@
110
110
  "parameters": [],
111
111
  "returns": "Promise<boolean>",
112
112
  "tags": [],
113
- "docs": "Reports whether Location Services are enabled on this device.\r\nOnly available on **Android**.",
113
+ "docs": "Reports whether Location Services are enabled on this device.\nOnly available on **Android**.",
114
114
  "complexTypes": [],
115
115
  "slug": "islocationenabled"
116
116
  },
@@ -120,7 +120,7 @@
120
120
  "parameters": [],
121
121
  "returns": "Promise<void>",
122
122
  "tags": [],
123
- "docs": "Open Location settings.\r\nOnly available on **Android**.",
123
+ "docs": "Open Location settings.\nOnly available on **Android**.",
124
124
  "complexTypes": [],
125
125
  "slug": "openlocationsettings"
126
126
  },
@@ -130,7 +130,7 @@
130
130
  "parameters": [],
131
131
  "returns": "Promise<void>",
132
132
  "tags": [],
133
- "docs": "Open Bluetooth settings.\r\nOnly available on **Android**.",
133
+ "docs": "Open Bluetooth settings.\nOnly available on **Android**.",
134
134
  "complexTypes": [],
135
135
  "slug": "openbluetoothsettings"
136
136
  },
@@ -140,7 +140,7 @@
140
140
  "parameters": [],
141
141
  "returns": "Promise<void>",
142
142
  "tags": [],
143
- "docs": "Open App settings.\r\nNot available on **web**.\r\nOn **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\r\nto request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\r\nfor the app to be able use it.",
143
+ "docs": "Open App settings.\nNot available on **web**.\nOn **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\nto request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\nfor the app to be able use it.",
144
144
  "complexTypes": [],
145
145
  "slug": "openappsettings"
146
146
  },
@@ -184,7 +184,7 @@
184
184
  "text": "options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)"
185
185
  }
186
186
  ],
187
- "docs": "Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\r\nFor an example, see [usage](#usage).",
187
+ "docs": "Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\nFor an example, see [usage](#usage).",
188
188
  "complexTypes": [
189
189
  "BleDevice",
190
190
  "RequestBleDeviceOptions"
@@ -217,7 +217,7 @@
217
217
  "text": "callback"
218
218
  }
219
219
  ],
220
- "docs": "Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\r\nScanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\r\n**Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.",
220
+ "docs": "Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\nScanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\n**Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.",
221
221
  "complexTypes": [
222
222
  "RequestBleDeviceOptions",
223
223
  "ScanResult"
@@ -251,7 +251,7 @@
251
251
  "text": "deviceIds List of device IDs, e.g. saved from a previous app run."
252
252
  }
253
253
  ],
254
- "docs": "On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\r\nUses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and\r\n[getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\r\nOn Android, you can directly connect to the device with the deviceId.",
254
+ "docs": "On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\nUses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and\n[getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\nOn Android, you can directly connect to the device with the deviceId.",
255
255
  "complexTypes": [
256
256
  "BleDevice"
257
257
  ],
@@ -263,7 +263,7 @@
263
263
  "parameters": [],
264
264
  "returns": "Promise<BleDevice[]>",
265
265
  "tags": [],
266
- "docs": "Get a list of currently bonded devices.\r\nOnly available on **Android**.\r\nUses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android",
266
+ "docs": "Get a list of currently bonded devices.\nOnly available on **Android**.\nUses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android",
267
267
  "complexTypes": [
268
268
  "BleDevice"
269
269
  ],
@@ -286,7 +286,7 @@
286
286
  "text": "services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS."
287
287
  }
288
288
  ],
289
- "docs": "Get a list of currently connected devices.\r\nUses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,\r\n[getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android\r\nand [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.",
289
+ "docs": "Get a list of currently connected devices.\nUses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,\n[getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android\nand [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.",
290
290
  "complexTypes": [
291
291
  "BleDevice"
292
292
  ],
@@ -359,7 +359,7 @@
359
359
  "text": "options Options for plugin call"
360
360
  }
361
361
  ],
362
- "docs": "Create a bond with a peripheral BLE device.\r\nOnly available on **Android**. On iOS bonding is handled by the OS.",
362
+ "docs": "Create a bond with a peripheral BLE device.\nOnly available on **Android**. On iOS bonding is handled by the OS.",
363
363
  "complexTypes": [
364
364
  "TimeoutOptions"
365
365
  ],
@@ -382,7 +382,7 @@
382
382
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
383
383
  }
384
384
  ],
385
- "docs": "Report whether a peripheral BLE device is bonded.\r\nOnly available on **Android**. On iOS bonding is handled by the OS.",
385
+ "docs": "Report whether a peripheral BLE device is bonded.\nOnly available on **Android**. On iOS bonding is handled by the OS.",
386
386
  "complexTypes": [],
387
387
  "slug": "isbonded"
388
388
  },
@@ -447,7 +447,7 @@
447
447
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
448
448
  }
449
449
  ],
450
- "docs": "Discover services, characteristics and descriptors of a device.\r\nYou only need this method if your peripheral device changes its services and characteristics at runtime.\r\nIf the discovery was successful, the remote services can be retrieved using the getServices function.\r\nNot available on **web**.",
450
+ "docs": "Discover services, characteristics and descriptors of a device.\nYou only need this method if your peripheral device changes its services and characteristics at runtime.\nIf the discovery was successful, the remote services can be retrieved using the getServices function.\nNot available on **web**.",
451
451
  "complexTypes": [],
452
452
  "slug": "discoverservices"
453
453
  },
@@ -468,7 +468,7 @@
468
468
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
469
469
  }
470
470
  ],
471
- "docs": "Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\r\nNot available on **web**.",
471
+ "docs": "Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\nNot available on **web**.",
472
472
  "complexTypes": [],
473
473
  "slug": "getmtu"
474
474
  },
@@ -498,7 +498,7 @@
498
498
  "text": "connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)"
499
499
  }
500
500
  ],
501
- "docs": "Request a connection parameter update.\r\nOnly available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)",
501
+ "docs": "Request a connection parameter update.\nOnly available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)",
502
502
  "complexTypes": [
503
503
  "ConnectionPriority"
504
504
  ],
@@ -521,7 +521,7 @@
521
521
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
522
522
  }
523
523
  ],
524
- "docs": "Read the RSSI value of a connected device.\r\nNot available on **web**.",
524
+ "docs": "Read the RSSI value of a connected device.\nNot available on **web**.",
525
525
  "complexTypes": [],
526
526
  "slug": "readrssi"
527
527
  },
@@ -827,7 +827,7 @@
827
827
  },
828
828
  {
829
829
  "name": "startNotifications",
830
- "signature": "(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void) => Promise<void>",
830
+ "signature": "(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void, options?: TimeoutOptions | undefined) => Promise<void>",
831
831
  "parameters": [
832
832
  {
833
833
  "name": "deviceId",
@@ -848,6 +848,11 @@
848
848
  "name": "callback",
849
849
  "docs": "Callback function to use when the value of the characteristic changes",
850
850
  "type": "(value: DataView) => void"
851
+ },
852
+ {
853
+ "name": "options",
854
+ "docs": "Options for plugin call. Timeout not supported on **web**.",
855
+ "type": "TimeoutOptions | undefined"
851
856
  }
852
857
  ],
853
858
  "returns": "Promise<void>",
@@ -867,11 +872,16 @@
867
872
  {
868
873
  "name": "param",
869
874
  "text": "callback Callback function to use when the value of the characteristic changes"
875
+ },
876
+ {
877
+ "name": "param",
878
+ "text": "options Options for plugin call. Timeout not supported on **web**."
870
879
  }
871
880
  ],
872
- "docs": "Start listening to changes of the value of a characteristic.\r\nNote that you should only start the notifications once per characteristic in your app and share the data and\r\nnot call `startNotifications` in every component that needs the data.\r\nFor an example, see [usage](#usage).",
881
+ "docs": "Start listening to changes of the value of a characteristic.\nNote that you should only start the notifications once per characteristic in your app and share the data and\nnot call `startNotifications` in every component that needs the data.\nFor an example, see [usage](#usage).",
873
882
  "complexTypes": [
874
- "DataView"
883
+ "DataView",
884
+ "TimeoutOptions"
875
885
  ],
876
886
  "slug": "startnotifications"
877
887
  },
@@ -933,7 +943,7 @@
933
943
  "name": "default"
934
944
  }
935
945
  ],
936
- "docs": "If your app doesn't use Bluetooth scan results to derive physical\r\nlocation information, you can strongly assert that your app\r\ndoesn't derive physical location. (Android only)\r\nRequires adding 'neverForLocation' to AndroidManifest.xml\r\nhttps://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location",
946
+ "docs": "If your app doesn't use Bluetooth scan results to derive physical\nlocation information, you can strongly assert that your app\ndoesn't derive physical location. (Android only)\nRequires adding 'neverForLocation' to AndroidManifest.xml\nhttps://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location",
937
947
  "complexTypes": [],
938
948
  "type": "boolean | undefined"
939
949
  }
@@ -1038,7 +1048,7 @@
1038
1048
  {
1039
1049
  "name": "deviceId",
1040
1050
  "tags": [],
1041
- "docs": "ID of the device, which will be needed for further calls.\r\nOn **Android** this is the BLE MAC address.\r\nOn **iOS** and **web** it is an identifier.",
1051
+ "docs": "ID of the device, which will be needed for further calls.\nOn **Android** this is the BLE MAC address.\nOn **iOS** and **web** it is an identifier.",
1042
1052
  "complexTypes": [],
1043
1053
  "type": "string"
1044
1054
  },
@@ -1068,7 +1078,7 @@
1068
1078
  {
1069
1079
  "name": "services",
1070
1080
  "tags": [],
1071
- "docs": "Filter devices by service UUIDs.\r\nUUIDs have to be specified as 128 bit UUID strings,\r\ne.g. ['0000180d-0000-1000-8000-00805f9b34fb']\r\nThere is a helper function to convert numbers to UUIDs.\r\ne.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))",
1081
+ "docs": "Filter devices by service UUIDs.\nUUIDs have to be specified as 128 bit UUID strings,\ne.g. ['0000180d-0000-1000-8000-00805f9b34fb']\nThere is a helper function to convert numbers to UUIDs.\ne.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))",
1072
1082
  "complexTypes": [],
1073
1083
  "type": "string[] | undefined"
1074
1084
  },
@@ -1089,14 +1099,14 @@
1089
1099
  {
1090
1100
  "name": "optionalServices",
1091
1101
  "tags": [],
1092
- "docs": "For **web**, all services that will be used have to be listed under services or optionalServices,\r\ne.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))",
1102
+ "docs": "For **web**, all services that will be used have to be listed under services or optionalServices,\ne.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))",
1093
1103
  "complexTypes": [],
1094
1104
  "type": "string[] | undefined"
1095
1105
  },
1096
1106
  {
1097
1107
  "name": "allowDuplicates",
1098
1108
  "tags": [],
1099
- "docs": "Normally scans will discard the second and subsequent advertisements from a single device.\r\nIf you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\r\n(default: false)",
1109
+ "docs": "Normally scans will discard the second and subsequent advertisements from a single device.\nIf you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\n(default: false)",
1100
1110
  "complexTypes": [],
1101
1111
  "type": "boolean | undefined"
1102
1112
  },
@@ -1112,11 +1122,45 @@
1112
1122
  {
1113
1123
  "name": "manufacturerData",
1114
1124
  "tags": [],
1115
- "docs": "Allow scanning for devices with a specific manufacturer data\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata",
1125
+ "docs": "Allow scanning for devices with a specific manufacturer data\nhttps://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata",
1126
+ "complexTypes": [
1127
+ "ManufacturerDataFilter"
1128
+ ],
1129
+ "type": "ManufacturerDataFilter[] | undefined"
1130
+ }
1131
+ ]
1132
+ },
1133
+ {
1134
+ "name": "ManufacturerDataFilter",
1135
+ "slug": "manufacturerdatafilter",
1136
+ "docs": "",
1137
+ "tags": [],
1138
+ "methods": [],
1139
+ "properties": [
1140
+ {
1141
+ "name": "companyIdentifier",
1142
+ "tags": [],
1143
+ "docs": "Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field.",
1144
+ "complexTypes": [],
1145
+ "type": "number"
1146
+ },
1147
+ {
1148
+ "name": "dataPrefix",
1149
+ "tags": [],
1150
+ "docs": "Prefix to match in the manufacturer data field.\nOn **Android** this field is mandatory.",
1151
+ "complexTypes": [
1152
+ "Uint8Array"
1153
+ ],
1154
+ "type": "Uint8Array"
1155
+ },
1156
+ {
1157
+ "name": "mask",
1158
+ "tags": [],
1159
+ "docs": "Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.\nThe `mask` must have the same length of dataPrefix.",
1116
1160
  "complexTypes": [
1117
1161
  "Uint8Array"
1118
1162
  ],
1119
- "type": "{ companyIdentifier: number; dataPrefix?: Uint8Array | undefined; mask?: Uint8Array | undefined; }[] | undefined"
1163
+ "type": "Uint8Array"
1120
1164
  }
1121
1165
  ]
1122
1166
  },
@@ -1961,7 +2005,7 @@
1961
2005
  {
1962
2006
  "name": "device",
1963
2007
  "tags": [],
1964
- "docs": "The peripheral device that was found in the scan.\r\n**Android** and **web**: `device.name` is always identical to `localName`.\r\n**iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.",
2008
+ "docs": "The peripheral device that was found in the scan.\n**Android** and **web**: `device.name` is always identical to `localName`.\n**iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.",
1965
2009
  "complexTypes": [
1966
2010
  "BleDevice"
1967
2011
  ],
@@ -2559,7 +2603,7 @@
2559
2603
  {
2560
2604
  "name": "timeout",
2561
2605
  "tags": [],
2562
- "docs": "Timeout in milliseconds for plugin call.\r\nDefault is 10000 for `connect` and 5000 for other plugin methods.",
2606
+ "docs": "Timeout in milliseconds for plugin call.\nDefault is 10000 for `connect` and 5000 for other plugin methods.",
2563
2607
  "complexTypes": [],
2564
2608
  "type": "number | undefined"
2565
2609
  }
@@ -2743,19 +2787,19 @@
2743
2787
  "name": "SCAN_MODE_LOW_POWER",
2744
2788
  "value": "0",
2745
2789
  "tags": [],
2746
- "docs": "Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER"
2790
+ "docs": "Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER"
2747
2791
  },
2748
2792
  {
2749
2793
  "name": "SCAN_MODE_BALANCED",
2750
2794
  "value": "1",
2751
2795
  "tags": [],
2752
- "docs": "Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED"
2796
+ "docs": "Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED"
2753
2797
  },
2754
2798
  {
2755
2799
  "name": "SCAN_MODE_LOW_LATENCY",
2756
2800
  "value": "2",
2757
2801
  "tags": [],
2758
- "docs": "Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY"
2802
+ "docs": "Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY"
2759
2803
  }
2760
2804
  ]
2761
2805
  },
@@ -2767,19 +2811,19 @@
2767
2811
  "name": "CONNECTION_PRIORITY_BALANCED",
2768
2812
  "value": "0",
2769
2813
  "tags": [],
2770
- "docs": "Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.\r\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED"
2814
+ "docs": "Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED"
2771
2815
  },
2772
2816
  {
2773
2817
  "name": "CONNECTION_PRIORITY_HIGH",
2774
2818
  "value": "1",
2775
2819
  "tags": [],
2776
- "docs": "Request a high priority, low latency connection. An application should only request high priority connection parameters to transfer large amounts of data over LE quickly. Once the transfer is complete, the application should request CONNECTION_PRIORITY_BALANCED connection parameters to reduce energy use.\r\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH"
2820
+ "docs": "Request a high priority, low latency connection. An application should only request high priority connection parameters to transfer large amounts of data over LE quickly. Once the transfer is complete, the application should request CONNECTION_PRIORITY_BALANCED connection parameters to reduce energy use.\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH"
2777
2821
  },
2778
2822
  {
2779
2823
  "name": "CONNECTION_PRIORITY_LOW_POWER",
2780
2824
  "value": "2",
2781
2825
  "tags": [],
2782
- "docs": "Request low power, reduced data rate connection parameters.\r\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER"
2826
+ "docs": "Request low power, reduced data rate connection parameters.\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER"
2783
2827
  }
2784
2828
  ]
2785
2829
  }
@@ -2812,11 +2856,11 @@
2812
2856
  "name": "since"
2813
2857
  },
2814
2858
  {
2815
- "text": "{\r\n\"scanning\": \"Scanning...\",\r\n\"cancel\": \"Cancel\",\r\n\"availableDevices\": \"Available devices\",\r\n\"noDeviceFound\": \"No device found\"\r\n}",
2859
+ "text": "{\n\"scanning\": \"Scanning...\",\n\"cancel\": \"Cancel\",\n\"availableDevices\": \"Available devices\",\n\"noDeviceFound\": \"No device found\"\n}",
2816
2860
  "name": "default"
2817
2861
  },
2818
2862
  {
2819
- "text": "{\r\nscanning: \"Am Scannen...\",\r\ncancel: \"Abbrechen\",\r\navailableDevices: \"Verfügbare Geräte\",\r\nnoDeviceFound: \"Kein Gerät gefunden\",\r\n}",
2863
+ "text": "{\nscanning: \"Am Scannen...\",\ncancel: \"Abbrechen\",\navailableDevices: \"Verfügbare Geräte\",\nnoDeviceFound: \"Kein Gerät gefunden\",\n}",
2820
2864
  "name": "example"
2821
2865
  }
2822
2866
  ],