@capacitor-community/bluetooth-le 2.2.0 → 2.2.2

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-8-orange?style=flat-square" /></a>
16
+ <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-9-orange?style=flat-square" /></a>
17
17
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
18
  </p>
19
19
 
@@ -557,9 +557,9 @@ Uses [retrievePeripherals](https://developer.apple.com/documentation/corebluetoo
557
557
  [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.
558
558
  On Android, you can directly connect to the device with the deviceId.
559
559
 
560
- | Param | Type | Description |
561
- | --------------- | --------------------- | --------------------------------------------------------------------------- |
562
- | **`deviceIds`** | <code>string[]</code> | List of device IDs, e.g. saved from a previous app run. No used on **web**. |
560
+ | Param | Type | Description |
561
+ | --------------- | --------------------- | ------------------------------------------------------- |
562
+ | **`deviceIds`** | <code>string[]</code> | List of device IDs, e.g. saved from a previous app run. |
563
563
 
564
564
  **Returns:** <code>Promise&lt;BleDevice[]&gt;</code>
565
565
 
@@ -1051,16 +1051,17 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1051
1051
  <table>
1052
1052
  <tbody>
1053
1053
  <tr>
1054
- <td align="center"><a href="https://github.com/pwespi"><img src="https://avatars2.githubusercontent.com/u/24232962?v=4?s=100" width="100px;" alt="pwespi"/><br /><sub><b>pwespi</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=pwespi" title="Code">💻</a> <a href="https://github.com/capacitor-community/bluetooth-le/commits?author=pwespi" title="Documentation">📖</a></td>
1055
- <td align="center"><a href="https://twitter.com/dennisameling"><img src="https://avatars.githubusercontent.com/u/17739158?v=4?s=100" width="100px;" alt="Dennis Ameling"/><br /><sub><b>Dennis Ameling</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=dennisameling" title="Code">💻</a></td>
1056
- <td align="center"><a href="http://squio.nl"><img src="https://avatars.githubusercontent.com/u/169410?v=4?s=100" width="100px;" alt="Johannes la Poutre"/><br /><sub><b>Johannes la Poutre</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=squio" title="Documentation">📖</a> <a href="https://github.com/capacitor-community/bluetooth-le/commits?author=squio" title="Code">💻</a></td>
1057
- <td align="center"><a href="https://github.com/sultanmyrza"><img src="https://avatars.githubusercontent.com/u/12681781?v=4?s=100" width="100px;" alt="Kasymbekov Sultanmyrza"/><br /><sub><b>Kasymbekov Sultanmyrza</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=sultanmyrza" title="Code">💻</a></td>
1058
- <td align="center"><a href="https://sourcya.com"><img src="https://avatars.githubusercontent.com/u/9040320?v=4?s=100" width="100px;" alt="Mutasim Issa"/><br /><sub><b>Mutasim Issa</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=mutasimissa" title="Documentation">📖</a></td>
1059
- <td align="center"><a href="http://www.gnucoop.com"><img src="https://avatars.githubusercontent.com/u/1615301?v=4?s=100" width="100px;" alt="Marco Marche"/><br /><sub><b>Marco Marche</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=trik" title="Code">💻</a></td>
1060
- <td align="center"><a href="https://github.com/JFKakaJFK"><img src="https://avatars.githubusercontent.com/u/13108477?v=4?s=100" width="100px;" alt="Johannes Koch"/><br /><sub><b>Johannes Koch</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=JFKakaJFK" title="Code">💻</a></td>
1054
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/pwespi"><img src="https://avatars2.githubusercontent.com/u/24232962?v=4?s=100" width="100px;" alt="pwespi"/><br /><sub><b>pwespi</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=pwespi" title="Code">💻</a> <a href="https://github.com/capacitor-community/bluetooth-le/commits?author=pwespi" title="Documentation">📖</a></td>
1055
+ <td align="center" valign="top" width="14.28%"><a href="https://twitter.com/dennisameling"><img src="https://avatars.githubusercontent.com/u/17739158?v=4?s=100" width="100px;" alt="Dennis Ameling"/><br /><sub><b>Dennis Ameling</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=dennisameling" title="Code">💻</a></td>
1056
+ <td align="center" valign="top" width="14.28%"><a href="http://squio.nl"><img src="https://avatars.githubusercontent.com/u/169410?v=4?s=100" width="100px;" alt="Johannes la Poutre"/><br /><sub><b>Johannes la Poutre</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=squio" title="Documentation">📖</a> <a href="https://github.com/capacitor-community/bluetooth-le/commits?author=squio" title="Code">💻</a></td>
1057
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/sultanmyrza"><img src="https://avatars.githubusercontent.com/u/12681781?v=4?s=100" width="100px;" alt="Kasymbekov Sultanmyrza"/><br /><sub><b>Kasymbekov Sultanmyrza</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=sultanmyrza" title="Code">💻</a></td>
1058
+ <td align="center" valign="top" width="14.28%"><a href="https://sourcya.com"><img src="https://avatars.githubusercontent.com/u/9040320?v=4?s=100" width="100px;" alt="Mutasim Issa"/><br /><sub><b>Mutasim Issa</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=mutasimissa" title="Documentation">📖</a></td>
1059
+ <td align="center" valign="top" width="14.28%"><a href="http://www.gnucoop.com"><img src="https://avatars.githubusercontent.com/u/1615301?v=4?s=100" width="100px;" alt="Marco Marche"/><br /><sub><b>Marco Marche</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=trik" title="Code">💻</a></td>
1060
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/JFKakaJFK"><img src="https://avatars.githubusercontent.com/u/13108477?v=4?s=100" width="100px;" alt="Johannes Koch"/><br /><sub><b>Johannes Koch</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=JFKakaJFK" title="Code">💻</a></td>
1061
1061
  </tr>
1062
1062
  <tr>
1063
- <td align="center"><a href="https://github.com/jrobeson"><img src="https://avatars.githubusercontent.com/u/56908?v=4?s=100" width="100px;" alt="Johnny Robeson"/><br /><sub><b>Johnny Robeson</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=jrobeson" title="Code">💻</a></td>
1063
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/jrobeson"><img src="https://avatars.githubusercontent.com/u/56908?v=4?s=100" width="100px;" alt="Johnny Robeson"/><br /><sub><b>Johnny Robeson</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=jrobeson" title="Code">💻</a></td>
1064
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/aadito123"><img src="https://avatars.githubusercontent.com/u/63646058?v=4?s=100" width="100px;" alt="Aadit Olkar"/><br /><sub><b>Aadit Olkar</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=aadito123" title="Code">💻</a></td>
1064
1065
  </tr>
1065
1066
  </tbody>
1066
1067
  </table>
package/dist/docs.json CHANGED
@@ -220,7 +220,7 @@
220
220
  "parameters": [
221
221
  {
222
222
  "name": "deviceIds",
223
- "docs": "List of device IDs, e.g. saved from a previous app run. No used on **web**.",
223
+ "docs": "List of device IDs, e.g. saved from a previous app run.",
224
224
  "type": "string[]"
225
225
  }
226
226
  ],
@@ -228,7 +228,7 @@
228
228
  "tags": [
229
229
  {
230
230
  "name": "param",
231
- "text": "deviceIds List of device IDs, e.g. saved from a previous app run. No used on **web**."
231
+ "text": "deviceIds List of device IDs, e.g. saved from a previous app run."
232
232
  }
233
233
  ],
234
234
  "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.",
@@ -83,7 +83,7 @@ export interface BleClientInterface {
83
83
  * Uses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and
84
84
  * [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.
85
85
  * On Android, you can directly connect to the device with the deviceId.
86
- * @param deviceIds List of device IDs, e.g. saved from a previous app run. No used on **web**.
86
+ * @param deviceIds List of device IDs, e.g. saved from a previous app run.
87
87
  */
88
88
  getDevices(deviceIds: string[]): Promise<BleDevice[]>;
89
89
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bleClient.js","sourceRoot":"","sources":["../../src/bleClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAaxE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAsRzC,MAAM,cAAc;IAApB;QACU,iBAAY,GAAgC,IAAI,CAAC;QACjD,mBAAc,GAAG,IAAI,GAAG,EAAgC,CAAC;QACzD,UAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IA8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AAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SACpD;QACD,IAAI,OAAO,CAAC,gBAAgB,EAAE;YAC5B,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SACpE;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,YAAY,CAAC,KAAY;QAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;SACnC;aAAM,IAAI,KAAK,KAAK,SAAS,EAAE;YAC9B,OAAO,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,GAA6B;QACjD,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\nimport { Capacitor } from '@capacitor/core';\n\nimport type { DisplayStrings } from './config';\nimport { dataViewToHexString, hexStringToDataView } from './conversion';\nimport type {\n BleDevice,\n BleService,\n ConnectionPriority,\n Data,\n InitializeOptions,\n ReadResult,\n RequestBleDeviceOptions,\n ScanResult,\n ScanResultInternal,\n TimeoutOptions,\n} from './definitions';\nimport { BluetoothLe } from './plugin';\nimport { getQueue } from './queue';\nimport { parseUUID } from './validators';\n\nexport interface BleClientInterface {\n /**\n * Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\n * On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\n * For an example, see [usage](#usage).\n */\n initialize(options?: InitializeOptions): Promise<void>;\n\n /**\n * Reports whether Bluetooth is enabled on this device.\n * Always returns `true` on **web**.\n */\n isEnabled(): Promise<boolean>;\n\n /**\n * Enable Bluetooth.\n * Only available on **Android**.\n */\n enable(): Promise<void>;\n\n /**\n * Disable Bluetooth.\n * Only available on **Android**.\n */\n disable(): Promise<void>;\n\n /**\n * Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\n * Not available on **web** (the callback will never be invoked).\n * @param callback Callback function to use when the Bluetooth state changes.\n */\n startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;\n\n /**\n * Stop the enabled notifications registered with `startEnabledNotifications`.\n */\n stopEnabledNotifications(): Promise<void>;\n\n /**\n * Reports whether Location Services are enabled on this device.\n * Only available on **Android**.\n */\n isLocationEnabled(): Promise<boolean>;\n\n /**\n * Open Location settings.\n * Only available on **Android**.\n */\n openLocationSettings(): Promise<void>;\n\n /**\n * Open Bluetooth settings.\n * Only available on **Android**.\n */\n openBluetoothSettings(): Promise<void>;\n\n /**\n * Open App settings.\n * Not available on **web**.\n * On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\n * to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\n * for the app to be able use it.\n */\n openAppSettings(): Promise<void>;\n\n /**\n * Set the strings that are displayed in the `requestDevice` dialog.\n * @param displayStrings\n */\n setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;\n\n /**\n * 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.\n * For an example, see [usage](#usage).\n * @param options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)\n */\n requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;\n\n /**\n * 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.\n * Scanning 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.\n * @param options\n * @param callback\n */\n requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;\n\n /**\n * Stop scanning for BLE devices. For an example, see [usage](#usage).\n */\n stopLEScan(): Promise<void>;\n\n /**\n * On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\n * Uses [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.\n * On Android, you can directly connect to the device with the deviceId.\n * @param deviceIds List of device IDs, e.g. saved from a previous app run. No used on **web**.\n */\n getDevices(deviceIds: string[]): Promise<BleDevice[]>;\n\n /**\n * Get a list of currently connected devices.\n * Uses [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\n * and [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\n * @param services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS.\n */\n getConnectedDevices(services: string[]): Promise<BleDevice[]>;\n\n /**\n * Connect to a peripheral BLE device. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param onDisconnect Optional disconnect callback function that will be used when the device disconnects\n * @param options Options for plugin call\n */\n connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;\n\n /**\n * Create a bond with a peripheral BLE device.\n * Only available on **Android**. On iOS bonding is handled by the OS.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n createBond(deviceId: string): Promise<void>;\n\n /**\n * Report whether a peripheral BLE device is bonded.\n * Only available on **Android**. On iOS bonding is handled by the OS.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n isBonded(deviceId: string): Promise<boolean>;\n\n /**\n * Disconnect from a peripheral BLE device. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n disconnect(deviceId: string): Promise<void>;\n\n /**\n * Get services, characteristics and descriptors of a device.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n getServices(deviceId: string): Promise<BleService[]>;\n\n /**\n * Discover services, characteristics and descriptors of a device.\n * You only need this method if your peripheral device changes its services and characteristics at runtime.\n * If the discovery was successful, the remote services can be retrieved using the getServices function.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n discoverServices(deviceId: string): Promise<void>;\n\n /**\n * Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n getMtu(deviceId: string): Promise<number>;\n\n /**\n * Request a connection parameter update.\n * Only available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)\n */\n requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;\n\n /**\n * Read the RSSI value of a connected device.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n readRssi(deviceId: string): Promise<number>;\n\n /**\n * Read the value of a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param options Options for plugin call\n */\n read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;\n\n /**\n * Write a value to a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n write(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void>;\n\n /**\n * Write a value to a characteristic without waiting for a response.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n writeWithoutResponse(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void>;\n\n /**\n * Read the value of a descriptor.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\n * @param options Options for plugin call\n */\n readDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n options?: TimeoutOptions\n ): Promise<DataView>;\n\n /**\n * Write a value to a descriptor.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n writeDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void>;\n\n /**\n * Start listening to changes of the value of a characteristic.\n * Note that you should only start the notifications once per characteristic in your app and share the data and\n * not call `startNotifications` in every component that needs the data.\n * For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param callback Callback function to use when the value of the characteristic changes\n */\n startNotifications(\n deviceId: string,\n service: string,\n characteristic: string,\n callback: (value: DataView) => void\n ): Promise<void>;\n\n /**\n * Stop listening to the changes of the value of a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n */\n stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;\n}\n\nclass BleClientClass implements BleClientInterface {\n private scanListener: PluginListenerHandle | null = null;\n private eventListeners = new Map<string, PluginListenerHandle>();\n private queue = getQueue(true);\n\n enableQueue() {\n this.queue = getQueue(true);\n }\n\n disableQueue() {\n this.queue = getQueue(false);\n }\n\n async initialize(options?: InitializeOptions): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.initialize(options);\n });\n }\n\n /**\n * Reports whether BLE is enabled on this device.\n * Always returns `true` on **web**.\n * @deprecated Use `isEnabled` instead.\n */\n async getEnabled(): Promise<boolean> {\n return this.isEnabled();\n }\n\n async isEnabled(): Promise<boolean> {\n const enabled = await this.queue(async () => {\n const result = await BluetoothLe.isEnabled();\n return result.value;\n });\n return enabled;\n }\n\n async enable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.enable();\n });\n }\n\n async disable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.disable();\n });\n }\n\n async startEnabledNotifications(callback: (value: boolean) => void): Promise<void> {\n await this.queue(async () => {\n const key = `onEnabledChanged`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, (result) => {\n callback(result.value);\n });\n this.eventListeners.set(key, listener);\n await BluetoothLe.startEnabledNotifications();\n });\n }\n\n async stopEnabledNotifications(): Promise<void> {\n await this.queue(async () => {\n const key = `onEnabledChanged`;\n await this.eventListeners.get(key)?.remove();\n this.eventListeners.delete(key);\n await BluetoothLe.stopEnabledNotifications();\n });\n }\n\n async isLocationEnabled(): Promise<boolean> {\n const enabled = await this.queue(async () => {\n const result = await BluetoothLe.isLocationEnabled();\n return result.value;\n });\n return enabled;\n }\n\n async openLocationSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openLocationSettings();\n });\n }\n\n async openBluetoothSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openBluetoothSettings();\n });\n }\n\n async openAppSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openAppSettings();\n });\n }\n\n async setDisplayStrings(displayStrings: DisplayStrings): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.setDisplayStrings(displayStrings);\n });\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n options = options ? this.validateRequestBleDeviceOptions(options) : undefined;\n const result = await this.queue(async () => {\n const device = await BluetoothLe.requestDevice(options);\n return device;\n });\n return result;\n }\n\n async requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void> {\n options = this.validateRequestBleDeviceOptions(options);\n await this.queue(async () => {\n await this.scanListener?.remove();\n this.scanListener = await BluetoothLe.addListener('onScanResult', (resultInternal: ScanResultInternal) => {\n const result: ScanResult = {\n ...resultInternal,\n manufacturerData: this.convertObject(resultInternal.manufacturerData),\n serviceData: this.convertObject(resultInternal.serviceData),\n rawAdvertisement: resultInternal.rawAdvertisement\n ? this.convertValue(resultInternal.rawAdvertisement)\n : undefined,\n };\n callback(result);\n });\n await BluetoothLe.requestLEScan(options);\n });\n }\n\n async stopLEScan(): Promise<void> {\n await this.queue(async () => {\n await this.scanListener?.remove();\n this.scanListener = null;\n await BluetoothLe.stopLEScan();\n });\n }\n\n async getDevices(deviceIds: string[]): Promise<BleDevice[]> {\n return this.queue(async () => {\n const result = await BluetoothLe.getDevices({ deviceIds });\n return result.devices;\n });\n }\n\n async getConnectedDevices(services: string[]): Promise<BleDevice[]> {\n if (!Array.isArray(services)) {\n throw new Error('services must be an array');\n }\n services = services.map(parseUUID);\n return this.queue(async () => {\n const result = await BluetoothLe.getConnectedDevices({ services });\n return result.devices;\n });\n }\n\n async connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void> {\n await this.queue(async () => {\n if (onDisconnect) {\n const key = `disconnected|${deviceId}`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, () => {\n onDisconnect(deviceId);\n });\n this.eventListeners.set(key, listener);\n }\n await BluetoothLe.connect({ deviceId, ...options });\n });\n }\n\n async createBond(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.createBond({ deviceId });\n });\n }\n\n async isBonded(deviceId: string): Promise<boolean> {\n const isBonded = await this.queue(async () => {\n const result = await BluetoothLe.isBonded({ deviceId });\n return result.value;\n });\n return isBonded;\n }\n\n async disconnect(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.disconnect({ deviceId });\n });\n }\n\n async getServices(deviceId: string): Promise<BleService[]> {\n const services = await this.queue(async () => {\n const result = await BluetoothLe.getServices({ deviceId });\n return result.services;\n });\n return services;\n }\n\n async discoverServices(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.discoverServices({ deviceId });\n });\n }\n\n async getMtu(deviceId: string): Promise<number> {\n const value = await this.queue(async () => {\n const result = await BluetoothLe.getMtu({ deviceId });\n return result.value;\n });\n return value;\n }\n\n async requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.requestConnectionPriority({ deviceId, connectionPriority });\n });\n }\n\n async readRssi(deviceId: string): Promise<number> {\n const value = await this.queue(async () => {\n const result = await BluetoothLe.readRssi({ deviceId });\n return parseFloat(result.value);\n });\n return value;\n }\n\n async read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n const value = await this.queue(async () => {\n const result = await BluetoothLe.read({\n deviceId,\n service,\n characteristic,\n ...options,\n });\n return this.convertValue(result.value);\n });\n return value;\n }\n\n async write(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n return this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.write({\n deviceId,\n service,\n characteristic,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async writeWithoutResponse(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.writeWithoutResponse({\n deviceId,\n service,\n characteristic,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async readDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n options?: TimeoutOptions\n ): Promise<DataView> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n descriptor = parseUUID(descriptor);\n const value = await this.queue(async () => {\n const result = await BluetoothLe.readDescriptor({\n deviceId,\n service,\n characteristic,\n descriptor,\n ...options,\n });\n return this.convertValue(result.value);\n });\n return value;\n }\n\n async writeDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n descriptor = parseUUID(descriptor);\n return this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.writeDescriptor({\n deviceId,\n service,\n characteristic,\n descriptor,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async startNotifications(\n deviceId: string,\n service: string,\n characteristic: string,\n callback: (value: DataView) => void\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n const key = `notification|${deviceId}|${service}|${characteristic}`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, (event: ReadResult) => {\n callback(this.convertValue(event?.value));\n });\n this.eventListeners.set(key, listener);\n await BluetoothLe.startNotifications({\n deviceId,\n service,\n characteristic,\n });\n });\n }\n\n async stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n const key = `notification|${deviceId}|${service}|${characteristic}`;\n await this.eventListeners.get(key)?.remove();\n this.eventListeners.delete(key);\n await BluetoothLe.stopNotifications({\n deviceId,\n service,\n characteristic,\n });\n });\n }\n\n private validateRequestBleDeviceOptions(options: RequestBleDeviceOptions): RequestBleDeviceOptions {\n if (options.services) {\n options.services = options.services.map(parseUUID);\n }\n if (options.optionalServices) {\n options.optionalServices = options.optionalServices.map(parseUUID);\n }\n return options;\n }\n\n private convertValue(value?: Data): DataView {\n if (typeof value === 'string') {\n return hexStringToDataView(value);\n } else if (value === undefined) {\n return new DataView(new ArrayBuffer(0));\n }\n return value;\n }\n\n private convertObject(obj?: { [key: string]: Data }): { [key: string]: DataView } | undefined {\n if (obj === undefined) {\n return undefined;\n }\n const result: { [key: string]: DataView } = {};\n for (const key of Object.keys(obj)) {\n result[key] = this.convertValue(obj[key]);\n }\n return result;\n }\n}\n\nexport const BleClient = new BleClientClass();\n"]}
1
+ {"version":3,"file":"bleClient.js","sourceRoot":"","sources":["../../src/bleClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAaxE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAsRzC,MAAM,cAAc;IAApB;QACU,iBAAY,GAAgC,IAAI,CAAC;QACjD,mBAAc,GAAG,IAAI,GAAG,EAAgC,CAAC;QACzD,UAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IA8ZjC,CAAC;IA5ZC,WAAW;QACT,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,YAAY;QACV,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA2B;QAC1C,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;YAC1B,MAAM,WAAW,CAAC,UAAU,CAAC,OAAO,C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KAAK,CAAC,CAAC;SACnC;aAAM,IAAI,KAAK,KAAK,SAAS,EAAE;YAC9B,OAAO,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,GAA6B;QACjD,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\nimport { Capacitor } from '@capacitor/core';\n\nimport type { DisplayStrings } from './config';\nimport { dataViewToHexString, hexStringToDataView } from './conversion';\nimport type {\n BleDevice,\n BleService,\n ConnectionPriority,\n Data,\n InitializeOptions,\n ReadResult,\n RequestBleDeviceOptions,\n ScanResult,\n ScanResultInternal,\n TimeoutOptions,\n} from './definitions';\nimport { BluetoothLe } from './plugin';\nimport { getQueue } from './queue';\nimport { parseUUID } from './validators';\n\nexport interface BleClientInterface {\n /**\n * Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\n * On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\n * For an example, see [usage](#usage).\n */\n initialize(options?: InitializeOptions): Promise<void>;\n\n /**\n * Reports whether Bluetooth is enabled on this device.\n * Always returns `true` on **web**.\n */\n isEnabled(): Promise<boolean>;\n\n /**\n * Enable Bluetooth.\n * Only available on **Android**.\n */\n enable(): Promise<void>;\n\n /**\n * Disable Bluetooth.\n * Only available on **Android**.\n */\n disable(): Promise<void>;\n\n /**\n * Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\n * Not available on **web** (the callback will never be invoked).\n * @param callback Callback function to use when the Bluetooth state changes.\n */\n startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;\n\n /**\n * Stop the enabled notifications registered with `startEnabledNotifications`.\n */\n stopEnabledNotifications(): Promise<void>;\n\n /**\n * Reports whether Location Services are enabled on this device.\n * Only available on **Android**.\n */\n isLocationEnabled(): Promise<boolean>;\n\n /**\n * Open Location settings.\n * Only available on **Android**.\n */\n openLocationSettings(): Promise<void>;\n\n /**\n * Open Bluetooth settings.\n * Only available on **Android**.\n */\n openBluetoothSettings(): Promise<void>;\n\n /**\n * Open App settings.\n * Not available on **web**.\n * On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\n * to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\n * for the app to be able use it.\n */\n openAppSettings(): Promise<void>;\n\n /**\n * Set the strings that are displayed in the `requestDevice` dialog.\n * @param displayStrings\n */\n setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;\n\n /**\n * 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.\n * For an example, see [usage](#usage).\n * @param options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)\n */\n requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;\n\n /**\n * 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.\n * Scanning 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.\n * @param options\n * @param callback\n */\n requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;\n\n /**\n * Stop scanning for BLE devices. For an example, see [usage](#usage).\n */\n stopLEScan(): Promise<void>;\n\n /**\n * On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\n * Uses [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.\n * On Android, you can directly connect to the device with the deviceId.\n * @param deviceIds List of device IDs, e.g. saved from a previous app run.\n */\n getDevices(deviceIds: string[]): Promise<BleDevice[]>;\n\n /**\n * Get a list of currently connected devices.\n * Uses [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\n * and [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\n * @param services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS.\n */\n getConnectedDevices(services: string[]): Promise<BleDevice[]>;\n\n /**\n * Connect to a peripheral BLE device. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param onDisconnect Optional disconnect callback function that will be used when the device disconnects\n * @param options Options for plugin call\n */\n connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;\n\n /**\n * Create a bond with a peripheral BLE device.\n * Only available on **Android**. On iOS bonding is handled by the OS.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n createBond(deviceId: string): Promise<void>;\n\n /**\n * Report whether a peripheral BLE device is bonded.\n * Only available on **Android**. On iOS bonding is handled by the OS.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n isBonded(deviceId: string): Promise<boolean>;\n\n /**\n * Disconnect from a peripheral BLE device. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n disconnect(deviceId: string): Promise<void>;\n\n /**\n * Get services, characteristics and descriptors of a device.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n getServices(deviceId: string): Promise<BleService[]>;\n\n /**\n * Discover services, characteristics and descriptors of a device.\n * You only need this method if your peripheral device changes its services and characteristics at runtime.\n * If the discovery was successful, the remote services can be retrieved using the getServices function.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n discoverServices(deviceId: string): Promise<void>;\n\n /**\n * Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n getMtu(deviceId: string): Promise<number>;\n\n /**\n * Request a connection parameter update.\n * Only available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)\n */\n requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;\n\n /**\n * Read the RSSI value of a connected device.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n readRssi(deviceId: string): Promise<number>;\n\n /**\n * Read the value of a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param options Options for plugin call\n */\n read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;\n\n /**\n * Write a value to a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n write(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void>;\n\n /**\n * Write a value to a characteristic without waiting for a response.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n writeWithoutResponse(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void>;\n\n /**\n * Read the value of a descriptor.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\n * @param options Options for plugin call\n */\n readDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n options?: TimeoutOptions\n ): Promise<DataView>;\n\n /**\n * Write a value to a descriptor.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n writeDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void>;\n\n /**\n * Start listening to changes of the value of a characteristic.\n * Note that you should only start the notifications once per characteristic in your app and share the data and\n * not call `startNotifications` in every component that needs the data.\n * For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param callback Callback function to use when the value of the characteristic changes\n */\n startNotifications(\n deviceId: string,\n service: string,\n characteristic: string,\n callback: (value: DataView) => void\n ): Promise<void>;\n\n /**\n * Stop listening to the changes of the value of a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n */\n stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;\n}\n\nclass BleClientClass implements BleClientInterface {\n private scanListener: PluginListenerHandle | null = null;\n private eventListeners = new Map<string, PluginListenerHandle>();\n private queue = getQueue(true);\n\n enableQueue() {\n this.queue = getQueue(true);\n }\n\n disableQueue() {\n this.queue = getQueue(false);\n }\n\n async initialize(options?: InitializeOptions): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.initialize(options);\n });\n }\n\n /**\n * Reports whether BLE is enabled on this device.\n * Always returns `true` on **web**.\n * @deprecated Use `isEnabled` instead.\n */\n async getEnabled(): Promise<boolean> {\n return this.isEnabled();\n }\n\n async isEnabled(): Promise<boolean> {\n const enabled = await this.queue(async () => {\n const result = await BluetoothLe.isEnabled();\n return result.value;\n });\n return enabled;\n }\n\n async enable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.enable();\n });\n }\n\n async disable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.disable();\n });\n }\n\n async startEnabledNotifications(callback: (value: boolean) => void): Promise<void> {\n await this.queue(async () => {\n const key = `onEnabledChanged`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, (result) => {\n callback(result.value);\n });\n this.eventListeners.set(key, listener);\n await BluetoothLe.startEnabledNotifications();\n });\n }\n\n async stopEnabledNotifications(): Promise<void> {\n await this.queue(async () => {\n const key = `onEnabledChanged`;\n await this.eventListeners.get(key)?.remove();\n this.eventListeners.delete(key);\n await BluetoothLe.stopEnabledNotifications();\n });\n }\n\n async isLocationEnabled(): Promise<boolean> {\n const enabled = await this.queue(async () => {\n const result = await BluetoothLe.isLocationEnabled();\n return result.value;\n });\n return enabled;\n }\n\n async openLocationSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openLocationSettings();\n });\n }\n\n async openBluetoothSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openBluetoothSettings();\n });\n }\n\n async openAppSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openAppSettings();\n });\n }\n\n async setDisplayStrings(displayStrings: DisplayStrings): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.setDisplayStrings(displayStrings);\n });\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n options = options ? this.validateRequestBleDeviceOptions(options) : undefined;\n const result = await this.queue(async () => {\n const device = await BluetoothLe.requestDevice(options);\n return device;\n });\n return result;\n }\n\n async requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void> {\n options = this.validateRequestBleDeviceOptions(options);\n await this.queue(async () => {\n await this.scanListener?.remove();\n this.scanListener = await BluetoothLe.addListener('onScanResult', (resultInternal: ScanResultInternal) => {\n const result: ScanResult = {\n ...resultInternal,\n manufacturerData: this.convertObject(resultInternal.manufacturerData),\n serviceData: this.convertObject(resultInternal.serviceData),\n rawAdvertisement: resultInternal.rawAdvertisement\n ? this.convertValue(resultInternal.rawAdvertisement)\n : undefined,\n };\n callback(result);\n });\n await BluetoothLe.requestLEScan(options);\n });\n }\n\n async stopLEScan(): Promise<void> {\n await this.queue(async () => {\n await this.scanListener?.remove();\n this.scanListener = null;\n await BluetoothLe.stopLEScan();\n });\n }\n\n async getDevices(deviceIds: string[]): Promise<BleDevice[]> {\n return this.queue(async () => {\n const result = await BluetoothLe.getDevices({ deviceIds });\n return result.devices;\n });\n }\n\n async getConnectedDevices(services: string[]): Promise<BleDevice[]> {\n if (!Array.isArray(services)) {\n throw new Error('services must be an array');\n }\n services = services.map(parseUUID);\n return this.queue(async () => {\n const result = await BluetoothLe.getConnectedDevices({ services });\n return result.devices;\n });\n }\n\n async connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void> {\n await this.queue(async () => {\n if (onDisconnect) {\n const key = `disconnected|${deviceId}`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, () => {\n onDisconnect(deviceId);\n });\n this.eventListeners.set(key, listener);\n }\n await BluetoothLe.connect({ deviceId, ...options });\n });\n }\n\n async createBond(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.createBond({ deviceId });\n });\n }\n\n async isBonded(deviceId: string): Promise<boolean> {\n const isBonded = await this.queue(async () => {\n const result = await BluetoothLe.isBonded({ deviceId });\n return result.value;\n });\n return isBonded;\n }\n\n async disconnect(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.disconnect({ deviceId });\n });\n }\n\n async getServices(deviceId: string): Promise<BleService[]> {\n const services = await this.queue(async () => {\n const result = await BluetoothLe.getServices({ deviceId });\n return result.services;\n });\n return services;\n }\n\n async discoverServices(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.discoverServices({ deviceId });\n });\n }\n\n async getMtu(deviceId: string): Promise<number> {\n const value = await this.queue(async () => {\n const result = await BluetoothLe.getMtu({ deviceId });\n return result.value;\n });\n return value;\n }\n\n async requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.requestConnectionPriority({ deviceId, connectionPriority });\n });\n }\n\n async readRssi(deviceId: string): Promise<number> {\n const value = await this.queue(async () => {\n const result = await BluetoothLe.readRssi({ deviceId });\n return parseFloat(result.value);\n });\n return value;\n }\n\n async read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n const value = await this.queue(async () => {\n const result = await BluetoothLe.read({\n deviceId,\n service,\n characteristic,\n ...options,\n });\n return this.convertValue(result.value);\n });\n return value;\n }\n\n async write(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n return this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.write({\n deviceId,\n service,\n characteristic,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async writeWithoutResponse(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.writeWithoutResponse({\n deviceId,\n service,\n characteristic,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async readDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n options?: TimeoutOptions\n ): Promise<DataView> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n descriptor = parseUUID(descriptor);\n const value = await this.queue(async () => {\n const result = await BluetoothLe.readDescriptor({\n deviceId,\n service,\n characteristic,\n descriptor,\n ...options,\n });\n return this.convertValue(result.value);\n });\n return value;\n }\n\n async writeDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n value: DataView,\n options?: TimeoutOptions\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n descriptor = parseUUID(descriptor);\n return this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.writeDescriptor({\n deviceId,\n service,\n characteristic,\n descriptor,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async startNotifications(\n deviceId: string,\n service: string,\n characteristic: string,\n callback: (value: DataView) => void\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n const key = `notification|${deviceId}|${service}|${characteristic}`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, (event: ReadResult) => {\n callback(this.convertValue(event?.value));\n });\n this.eventListeners.set(key, listener);\n await BluetoothLe.startNotifications({\n deviceId,\n service,\n characteristic,\n });\n });\n }\n\n async stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n const key = `notification|${deviceId}|${service}|${characteristic}`;\n await this.eventListeners.get(key)?.remove();\n this.eventListeners.delete(key);\n await BluetoothLe.stopNotifications({\n deviceId,\n service,\n characteristic,\n });\n });\n }\n\n private validateRequestBleDeviceOptions(options: RequestBleDeviceOptions): RequestBleDeviceOptions {\n if (options.services) {\n options.services = options.services.map(parseUUID);\n }\n if (options.optionalServices) {\n options.optionalServices = options.optionalServices.map(parseUUID);\n }\n return options;\n }\n\n private convertValue(value?: Data): DataView {\n if (typeof value === 'string') {\n return hexStringToDataView(value);\n } else if (value === undefined) {\n return new DataView(new ArrayBuffer(0));\n }\n return value;\n }\n\n private convertObject(obj?: { [key: string]: Data }): { [key: string]: DataView } | undefined {\n if (obj === undefined) {\n return undefined;\n }\n const result: { [key: string]: DataView } = {};\n for (const key of Object.keys(obj)) {\n result[key] = this.convertValue(obj[key]);\n }\n return result;\n }\n}\n\nexport const BleClient = new BleClientClass();\n"]}
package/dist/esm/queue.js CHANGED
@@ -1,10 +1,18 @@
1
- import throat from 'throat';
1
+ const makeQueue = () => {
2
+ let currentTask = Promise.resolve();
3
+ // create a new promise so that errors can be bubbled
4
+ // up to the caller without being caught by the queue
5
+ return (fn) => new Promise((resolve, reject) => {
6
+ currentTask = currentTask
7
+ .then(() => fn())
8
+ .then(resolve)
9
+ .catch(reject);
10
+ });
11
+ };
2
12
  export function getQueue(enabled) {
3
13
  if (enabled) {
4
- return throat(1);
5
- }
6
- else {
7
- return (fn) => fn();
14
+ return makeQueue();
8
15
  }
16
+ return (fn) => fn();
9
17
  }
10
18
  //# sourceMappingURL=queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,IAAI,OAAO,EAAE;QACX,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;KAClB;SAAM;QACL,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;KACrB;AACH,CAAC","sourcesContent":["import throat from 'throat';\n\ntype Queue = <T>(fn: () => Promise<T>) => Promise<T>;\n\nexport function getQueue(enabled: boolean): Queue {\n if (enabled) {\n return throat(1);\n } else {\n return (fn) => fn();\n }\n}\n"]}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,GAAU,EAAE;IAC5B,IAAI,WAAW,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IACtD,qDAAqD;IACrD,qDAAqD;IACrD,OAAO,CAAC,EAAE,EAAE,EAAE,CACZ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9B,WAAW,GAAG,WAAW;aACtB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;aAChB,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,IAAI,OAAO,EAAE;QACX,OAAO,SAAS,EAAE,CAAC;KACpB;IACD,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AACtB,CAAC","sourcesContent":["type Queue = <T>(fn: () => Promise<T>) => Promise<T>;\n\nconst makeQueue = (): Queue => {\n let currentTask: Promise<unknown> = Promise.resolve();\n // create a new promise so that errors can be bubbled\n // up to the caller without being caught by the queue\n return (fn) =>\n new Promise((resolve, reject) => {\n currentTask = currentTask\n .then(() => fn())\n .then(resolve)\n .catch(reject);\n });\n};\n\nexport function getQueue(enabled: boolean): Queue {\n if (enabled) {\n return makeQueue();\n }\n return (fn) => fn();\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare class BluetoothLeWeb extends WebPlugin implements BluetoothLePlug
22
22
  private onAdvertisementReceivedCallback;
23
23
  private onAdvertisementReceived;
24
24
  stopLEScan(): Promise<void>;
25
- getDevices(_options: GetDevicesOptions): Promise<GetDevicesResult>;
25
+ getDevices(options: GetDevicesOptions): Promise<GetDevicesResult>;
26
26
  getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult>;
27
27
  connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
28
28
  private onDisconnectedCallback;
package/dist/esm/web.js CHANGED
@@ -103,9 +103,11 @@ export class BluetoothLeWeb extends WebPlugin {
103
103
  }
104
104
  this.scan = null;
105
105
  }
106
- async getDevices(_options) {
106
+ async getDevices(options) {
107
107
  const devices = await navigator.bluetooth.getDevices();
108
- const bleDevices = devices.map((device) => {
108
+ const bleDevices = devices
109
+ .filter((device) => options.deviceIds.includes(device.id))
110
+ .map((device) => {
109
111
  this.deviceMap.set(device.id, device);
110
112
  const bleDevice = this.getBleDevice(device);
111
113
  return bleDevice;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA0BjF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAA7C;;QACU,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,sBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,SAAI,GAA2B,IAAI,CAAC;QAEpC,+BAA0B,GAAG,KAAK,CAAC;QAkFnC,oCAA+B,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QA4E1E,2BAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAiJxD,yCAAoC,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAiD9F,CAAC;IA9VC,KAAK,CAAC,UAAU;QACd,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;YAC5D,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;QAChE,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;SACzD;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,uBAAuB;QACvB,OAAO,EAAE,KAAK,EAAE,IAAI,EA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,CAAC,OAAiC;;QAClD,MAAM,OAAO,GAA4B,EAAE,CAAC;QAC5C,KAAK,MAAM,OAAO,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,EAAE,EAAE;YAC7C,OAAO,CAAC,IAAI,CAAC;gBACX,QAAQ,EAAE,CAAC,OAAO,CAAC;gBACnB,IAAI,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI;gBACnB,UAAU,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;aAChC,CAAC,CAAC;SACJ;QACD,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAA,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAClE,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;SACJ;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,gBAAgB,CAAC,QAAgB;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;SACnG;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAuB;;QAC1C,MAAM,SAAS,GAAc;YAC3B,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,yDAAyD;YACzD,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS;SAC/B,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { hexStringToDataView, mapToObject, webUUIDToString } from './conversion';\nimport type {\n BleCharacteristic,\n BleCharacteristicProperties,\n BleDescriptor,\n BleService,\n TimeoutOptions,\n BleDevice,\n BleServices,\n BluetoothLePlugin,\n BooleanResult,\n DeviceIdOptions,\n GetConnectedDevicesOptions,\n GetDevicesOptions,\n GetDevicesResult,\n ReadDescriptorOptions,\n ReadOptions,\n ReadResult,\n ReadRssiResult,\n RequestBleDeviceOptions,\n ScanResultInternal,\n WriteOptions,\n WriteDescriptorOptions,\n GetMtuResult,\n RequestConnectionPriorityOptions,\n} from './definitions';\nimport { runWithTimeout } from './timeout';\n\nexport class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {\n private deviceMap = new Map<string, BluetoothDevice>();\n private discoveredDevices = new Map<string, boolean>();\n private scan: BluetoothLEScan | null = null;\n private requestBleDeviceOptions: RequestBleDeviceOptions | undefined;\n private DEFAULT_CONNECTION_TIMEOUT = 10000;\n\n async initialize(): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.bluetooth) {\n throw this.unavailable('Web Bluetooth API not available in this browser.');\n }\n const isAvailable = await navigator.bluetooth.getAvailability();\n if (!isAvailable) {\n throw this.unavailable('No Bluetooth radio available.');\n }\n }\n\n async isEnabled(): Promise<BooleanResult> {\n // not available on web\n return { value: true };\n }\n\n async enable(): Promise<void> {\n throw this.unavailable('enable is not available on web.');\n }\n\n async disable(): Promise<void> {\n throw this.unavailable('disable is not available on web.');\n }\n\n async startEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async stopEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async isLocationEnabled(): Promise<BooleanResult> {\n throw this.unavailable('isLocationEnabled is not available on web.');\n }\n\n async openLocationSettings(): Promise<void> {\n throw this.unavailable('openLocationSettings is not available on web.');\n }\n\n async openBluetoothSettings(): Promise<void> {\n throw this.unavailable('openBluetoothSettings is not available on web.');\n }\n\n async openAppSettings(): Promise<void> {\n throw this.unavailable('openAppSettings is not available on web.');\n }\n\n async setDisplayStrings(): Promise<void> {\n // not available on web\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n const filters = this.getFilters(options);\n const device = await navigator.bluetooth.requestDevice({\n filters: filters.length ? filters : undefined,\n optionalServices: options?.optionalServices,\n acceptAllDevices: filters.length === 0,\n });\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n }\n\n async requestLEScan(options?: RequestBleDeviceOptions): Promise<void> {\n this.requestBleDeviceOptions = options;\n const filters = this.getFilters(options);\n await this.stopLEScan();\n this.discoveredDevices = new Map<string, boolean>();\n navigator.bluetooth.removeEventListener(\n 'advertisementreceived',\n this.onAdvertisementReceivedCallback as EventListener\n );\n navigator.bluetooth.addEventListener('advertisementreceived', this.onAdvertisementReceivedCallback);\n this.scan = await navigator.bluetooth.requestLEScan({\n filters: filters.length ? filters : undefined,\n acceptAllAdvertisements: filters.length === 0,\n keepRepeatedDevices: options?.allowDuplicates,\n });\n }\n\n private onAdvertisementReceivedCallback = this.onAdvertisementReceived.bind(this);\n\n private onAdvertisementReceived(event: BluetoothAdvertisingEvent): void {\n const deviceId = event.device.id;\n this.deviceMap.set(deviceId, event.device);\n const isNew = !this.discoveredDevices.has(deviceId);\n if (isNew || this.requestBleDeviceOptions?.allowDuplicates) {\n this.discoveredDevices.set(deviceId, true);\n const device = this.getBleDevice(event.device);\n const result: ScanResultInternal = {\n device,\n localName: device.name,\n rssi: event.rssi,\n txPower: event.txPower,\n manufacturerData: mapToObject(event.manufacturerData),\n serviceData: mapToObject(event.serviceData),\n uuids: event.uuids?.map(webUUIDToString),\n };\n this.notifyListeners('onScanResult', result);\n }\n }\n\n async stopLEScan(): Promise<void> {\n if (this.scan?.active) {\n this.scan.stop();\n }\n this.scan = null;\n }\n\n async getDevices(_options: GetDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices.map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => {\n return device.gatt?.connected;\n })\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async connect(options: DeviceIdOptions & TimeoutOptions): Promise<void> {\n const device = this.getDeviceFromMap(options.deviceId);\n device.removeEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n device.addEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n const timeoutError = Symbol();\n if (device.gatt === undefined) {\n throw new Error('No gatt server available.');\n }\n try {\n const timeout = options.timeout ?? this.DEFAULT_CONNECTION_TIMEOUT;\n await runWithTimeout(device.gatt.connect(), timeout, timeoutError);\n } catch (error) {\n // cancel pending connect call, does not work yet in chromium because of a bug:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=684073\n await device.gatt?.disconnect();\n if (error === timeoutError) {\n throw new Error('Connection timeout');\n } else {\n throw error;\n }\n }\n }\n\n private onDisconnectedCallback = this.onDisconnected.bind(this);\n\n private onDisconnected(event: Event): void {\n const deviceId = (event.target as BluetoothDevice).id;\n const key = `disconnected|${deviceId}`;\n this.notifyListeners(key, null);\n }\n\n async createBond(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('createBond is not available on web.');\n }\n\n async isBonded(_options: DeviceIdOptions): Promise<BooleanResult> {\n throw this.unavailable('isBonded is not available on web.');\n }\n\n async disconnect(options: DeviceIdOptions): Promise<void> {\n this.getDeviceFromMap(options.deviceId).gatt?.disconnect();\n }\n\n async getServices(options: DeviceIdOptions): Promise<BleServices> {\n const services = (await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryServices()) ?? [];\n const bleServices: BleService[] = [];\n for (const service of services) {\n const characteristics = await service.getCharacteristics();\n const bleCharacteristics: BleCharacteristic[] = [];\n for (const characteristic of characteristics) {\n bleCharacteristics.push({\n uuid: characteristic.uuid,\n properties: this.getProperties(characteristic),\n descriptors: await this.getDescriptors(characteristic),\n });\n }\n bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics });\n }\n return { services: bleServices };\n }\n\n private async getDescriptors(characteristic: BluetoothRemoteGATTCharacteristic): Promise<BleDescriptor[]> {\n try {\n const descriptors = await characteristic.getDescriptors();\n return descriptors.map((descriptor) => ({\n uuid: descriptor.uuid,\n }));\n } catch {\n return [];\n }\n }\n\n private getProperties(characteristic: BluetoothRemoteGATTCharacteristic): BleCharacteristicProperties {\n return {\n broadcast: characteristic.properties.broadcast,\n read: characteristic.properties.read,\n writeWithoutResponse: characteristic.properties.writeWithoutResponse,\n write: characteristic.properties.write,\n notify: characteristic.properties.notify,\n indicate: characteristic.properties.indicate,\n authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites,\n reliableWrite: characteristic.properties.reliableWrite,\n writableAuxiliaries: characteristic.properties.writableAuxiliaries,\n };\n }\n\n private async getCharacteristic(\n options: ReadOptions | WriteOptions\n ): Promise<BluetoothRemoteGATTCharacteristic | undefined> {\n const service = await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryService(options?.service);\n return service?.getCharacteristic(options?.characteristic);\n }\n\n private async getDescriptor(\n options: ReadDescriptorOptions | WriteDescriptorOptions\n ): Promise<BluetoothRemoteGATTDescriptor | undefined> {\n const characteristic = await this.getCharacteristic(options);\n return characteristic?.getDescriptor(options?.descriptor);\n }\n\n async discoverServices(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('discoverServices is not available on web.');\n }\n\n async getMtu(_options: DeviceIdOptions): Promise<GetMtuResult> {\n throw this.unavailable('getMtu is not available on web.');\n }\n\n async requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void> {\n throw this.unavailable('requestConnectionPriority is not available on web.');\n }\n\n async readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult> {\n throw this.unavailable('readRssi is not available on web.');\n }\n\n async read(options: ReadOptions): Promise<ReadResult> {\n const characteristic = await this.getCharacteristic(options);\n const value = await characteristic?.readValue();\n return { value };\n }\n\n async write(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithResponse(dataView);\n }\n\n async writeWithoutResponse(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithoutResponse(dataView);\n }\n\n async readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult> {\n const descriptor = await this.getDescriptor(options);\n const value = await descriptor?.readValue();\n return { value };\n }\n\n async writeDescriptor(options: WriteDescriptorOptions): Promise<void> {\n const descriptor = await this.getDescriptor(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await descriptor?.writeValue(dataView);\n }\n\n async startNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n characteristic?.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n characteristic?.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n await characteristic?.startNotifications();\n }\n\n private onCharacteristicValueChangedCallback = this.onCharacteristicValueChanged.bind(this);\n\n private onCharacteristicValueChanged(event: Event): void {\n const characteristic = event.target as BluetoothRemoteGATTCharacteristic;\n const key = `notification|${characteristic.service?.device.id}|${characteristic.service?.uuid}|${characteristic.uuid}`;\n this.notifyListeners(key, {\n value: characteristic.value,\n });\n }\n\n async stopNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n await characteristic?.stopNotifications();\n }\n\n private getFilters(options?: RequestBleDeviceOptions): BluetoothLEScanFilter[] {\n const filters: BluetoothLEScanFilter[] = [];\n for (const service of options?.services ?? []) {\n filters.push({\n services: [service],\n name: options?.name,\n namePrefix: options?.namePrefix,\n });\n }\n if ((options?.name || options?.namePrefix) && filters.length === 0) {\n filters.push({\n name: options.name,\n namePrefix: options.namePrefix,\n });\n }\n return filters;\n }\n\n private getDeviceFromMap(deviceId: string): BluetoothDevice {\n const device = this.deviceMap.get(deviceId);\n if (device === undefined) {\n throw new Error('Device not found. Call \"requestDevice\", \"requestLEScan\" or \"getDevices\" first.');\n }\n return device;\n }\n\n private getBleDevice(device: BluetoothDevice): BleDevice {\n const bleDevice: BleDevice = {\n deviceId: device.id,\n // use undefined instead of null if name is not available\n name: device.name ?? undefined,\n };\n return bleDevice;\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA0BjF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAA7C;;QACU,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,sBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,SAAI,GAA2B,IAAI,CAAC;QAEpC,+BAA0B,GAAG,KAAK,CAAC;QAkFnC,oCAA+B,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QA8E1E,2BAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAiJxD,yCAAoC,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAiD9F,CAAC;IAhWC,KAAK,CAAC,UAAU;QACd,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;YAC5D,MAAM,IA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AAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;SACnG;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAuB;;QAC1C,MAAM,SAAS,GAAc;YAC3B,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,yDAAyD;YACzD,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS;SAC/B,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { hexStringToDataView, mapToObject, webUUIDToString } from './conversion';\nimport type {\n BleCharacteristic,\n BleCharacteristicProperties,\n BleDescriptor,\n BleService,\n TimeoutOptions,\n BleDevice,\n BleServices,\n BluetoothLePlugin,\n BooleanResult,\n DeviceIdOptions,\n GetConnectedDevicesOptions,\n GetDevicesOptions,\n GetDevicesResult,\n ReadDescriptorOptions,\n ReadOptions,\n ReadResult,\n ReadRssiResult,\n RequestBleDeviceOptions,\n ScanResultInternal,\n WriteOptions,\n WriteDescriptorOptions,\n GetMtuResult,\n RequestConnectionPriorityOptions,\n} from './definitions';\nimport { runWithTimeout } from './timeout';\n\nexport class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {\n private deviceMap = new Map<string, BluetoothDevice>();\n private discoveredDevices = new Map<string, boolean>();\n private scan: BluetoothLEScan | null = null;\n private requestBleDeviceOptions: RequestBleDeviceOptions | undefined;\n private DEFAULT_CONNECTION_TIMEOUT = 10000;\n\n async initialize(): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.bluetooth) {\n throw this.unavailable('Web Bluetooth API not available in this browser.');\n }\n const isAvailable = await navigator.bluetooth.getAvailability();\n if (!isAvailable) {\n throw this.unavailable('No Bluetooth radio available.');\n }\n }\n\n async isEnabled(): Promise<BooleanResult> {\n // not available on web\n return { value: true };\n }\n\n async enable(): Promise<void> {\n throw this.unavailable('enable is not available on web.');\n }\n\n async disable(): Promise<void> {\n throw this.unavailable('disable is not available on web.');\n }\n\n async startEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async stopEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async isLocationEnabled(): Promise<BooleanResult> {\n throw this.unavailable('isLocationEnabled is not available on web.');\n }\n\n async openLocationSettings(): Promise<void> {\n throw this.unavailable('openLocationSettings is not available on web.');\n }\n\n async openBluetoothSettings(): Promise<void> {\n throw this.unavailable('openBluetoothSettings is not available on web.');\n }\n\n async openAppSettings(): Promise<void> {\n throw this.unavailable('openAppSettings is not available on web.');\n }\n\n async setDisplayStrings(): Promise<void> {\n // not available on web\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n const filters = this.getFilters(options);\n const device = await navigator.bluetooth.requestDevice({\n filters: filters.length ? filters : undefined,\n optionalServices: options?.optionalServices,\n acceptAllDevices: filters.length === 0,\n });\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n }\n\n async requestLEScan(options?: RequestBleDeviceOptions): Promise<void> {\n this.requestBleDeviceOptions = options;\n const filters = this.getFilters(options);\n await this.stopLEScan();\n this.discoveredDevices = new Map<string, boolean>();\n navigator.bluetooth.removeEventListener(\n 'advertisementreceived',\n this.onAdvertisementReceivedCallback as EventListener\n );\n navigator.bluetooth.addEventListener('advertisementreceived', this.onAdvertisementReceivedCallback);\n this.scan = await navigator.bluetooth.requestLEScan({\n filters: filters.length ? filters : undefined,\n acceptAllAdvertisements: filters.length === 0,\n keepRepeatedDevices: options?.allowDuplicates,\n });\n }\n\n private onAdvertisementReceivedCallback = this.onAdvertisementReceived.bind(this);\n\n private onAdvertisementReceived(event: BluetoothAdvertisingEvent): void {\n const deviceId = event.device.id;\n this.deviceMap.set(deviceId, event.device);\n const isNew = !this.discoveredDevices.has(deviceId);\n if (isNew || this.requestBleDeviceOptions?.allowDuplicates) {\n this.discoveredDevices.set(deviceId, true);\n const device = this.getBleDevice(event.device);\n const result: ScanResultInternal = {\n device,\n localName: device.name,\n rssi: event.rssi,\n txPower: event.txPower,\n manufacturerData: mapToObject(event.manufacturerData),\n serviceData: mapToObject(event.serviceData),\n uuids: event.uuids?.map(webUUIDToString),\n };\n this.notifyListeners('onScanResult', result);\n }\n }\n\n async stopLEScan(): Promise<void> {\n if (this.scan?.active) {\n this.scan.stop();\n }\n this.scan = null;\n }\n\n async getDevices(options: GetDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => options.deviceIds.includes(device.id))\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => {\n return device.gatt?.connected;\n })\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async connect(options: DeviceIdOptions & TimeoutOptions): Promise<void> {\n const device = this.getDeviceFromMap(options.deviceId);\n device.removeEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n device.addEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n const timeoutError = Symbol();\n if (device.gatt === undefined) {\n throw new Error('No gatt server available.');\n }\n try {\n const timeout = options.timeout ?? this.DEFAULT_CONNECTION_TIMEOUT;\n await runWithTimeout(device.gatt.connect(), timeout, timeoutError);\n } catch (error) {\n // cancel pending connect call, does not work yet in chromium because of a bug:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=684073\n await device.gatt?.disconnect();\n if (error === timeoutError) {\n throw new Error('Connection timeout');\n } else {\n throw error;\n }\n }\n }\n\n private onDisconnectedCallback = this.onDisconnected.bind(this);\n\n private onDisconnected(event: Event): void {\n const deviceId = (event.target as BluetoothDevice).id;\n const key = `disconnected|${deviceId}`;\n this.notifyListeners(key, null);\n }\n\n async createBond(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('createBond is not available on web.');\n }\n\n async isBonded(_options: DeviceIdOptions): Promise<BooleanResult> {\n throw this.unavailable('isBonded is not available on web.');\n }\n\n async disconnect(options: DeviceIdOptions): Promise<void> {\n this.getDeviceFromMap(options.deviceId).gatt?.disconnect();\n }\n\n async getServices(options: DeviceIdOptions): Promise<BleServices> {\n const services = (await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryServices()) ?? [];\n const bleServices: BleService[] = [];\n for (const service of services) {\n const characteristics = await service.getCharacteristics();\n const bleCharacteristics: BleCharacteristic[] = [];\n for (const characteristic of characteristics) {\n bleCharacteristics.push({\n uuid: characteristic.uuid,\n properties: this.getProperties(characteristic),\n descriptors: await this.getDescriptors(characteristic),\n });\n }\n bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics });\n }\n return { services: bleServices };\n }\n\n private async getDescriptors(characteristic: BluetoothRemoteGATTCharacteristic): Promise<BleDescriptor[]> {\n try {\n const descriptors = await characteristic.getDescriptors();\n return descriptors.map((descriptor) => ({\n uuid: descriptor.uuid,\n }));\n } catch {\n return [];\n }\n }\n\n private getProperties(characteristic: BluetoothRemoteGATTCharacteristic): BleCharacteristicProperties {\n return {\n broadcast: characteristic.properties.broadcast,\n read: characteristic.properties.read,\n writeWithoutResponse: characteristic.properties.writeWithoutResponse,\n write: characteristic.properties.write,\n notify: characteristic.properties.notify,\n indicate: characteristic.properties.indicate,\n authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites,\n reliableWrite: characteristic.properties.reliableWrite,\n writableAuxiliaries: characteristic.properties.writableAuxiliaries,\n };\n }\n\n private async getCharacteristic(\n options: ReadOptions | WriteOptions\n ): Promise<BluetoothRemoteGATTCharacteristic | undefined> {\n const service = await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryService(options?.service);\n return service?.getCharacteristic(options?.characteristic);\n }\n\n private async getDescriptor(\n options: ReadDescriptorOptions | WriteDescriptorOptions\n ): Promise<BluetoothRemoteGATTDescriptor | undefined> {\n const characteristic = await this.getCharacteristic(options);\n return characteristic?.getDescriptor(options?.descriptor);\n }\n\n async discoverServices(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('discoverServices is not available on web.');\n }\n\n async getMtu(_options: DeviceIdOptions): Promise<GetMtuResult> {\n throw this.unavailable('getMtu is not available on web.');\n }\n\n async requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void> {\n throw this.unavailable('requestConnectionPriority is not available on web.');\n }\n\n async readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult> {\n throw this.unavailable('readRssi is not available on web.');\n }\n\n async read(options: ReadOptions): Promise<ReadResult> {\n const characteristic = await this.getCharacteristic(options);\n const value = await characteristic?.readValue();\n return { value };\n }\n\n async write(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithResponse(dataView);\n }\n\n async writeWithoutResponse(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithoutResponse(dataView);\n }\n\n async readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult> {\n const descriptor = await this.getDescriptor(options);\n const value = await descriptor?.readValue();\n return { value };\n }\n\n async writeDescriptor(options: WriteDescriptorOptions): Promise<void> {\n const descriptor = await this.getDescriptor(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await descriptor?.writeValue(dataView);\n }\n\n async startNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n characteristic?.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n characteristic?.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n await characteristic?.startNotifications();\n }\n\n private onCharacteristicValueChangedCallback = this.onCharacteristicValueChanged.bind(this);\n\n private onCharacteristicValueChanged(event: Event): void {\n const characteristic = event.target as BluetoothRemoteGATTCharacteristic;\n const key = `notification|${characteristic.service?.device.id}|${characteristic.service?.uuid}|${characteristic.uuid}`;\n this.notifyListeners(key, {\n value: characteristic.value,\n });\n }\n\n async stopNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n await characteristic?.stopNotifications();\n }\n\n private getFilters(options?: RequestBleDeviceOptions): BluetoothLEScanFilter[] {\n const filters: BluetoothLEScanFilter[] = [];\n for (const service of options?.services ?? []) {\n filters.push({\n services: [service],\n name: options?.name,\n namePrefix: options?.namePrefix,\n });\n }\n if ((options?.name || options?.namePrefix) && filters.length === 0) {\n filters.push({\n name: options.name,\n namePrefix: options.namePrefix,\n });\n }\n return filters;\n }\n\n private getDeviceFromMap(deviceId: string): BluetoothDevice {\n const device = this.deviceMap.get(deviceId);\n if (device === undefined) {\n throw new Error('Device not found. Call \"requestDevice\", \"requestLEScan\" or \"getDevices\" first.');\n }\n return device;\n }\n\n private getBleDevice(device: BluetoothDevice): BleDevice {\n const bleDevice: BleDevice = {\n deviceId: device.id,\n // use undefined instead of null if name is not available\n name: device.name ?? undefined,\n };\n return bleDevice;\n }\n}\n"]}
@@ -3,11 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@capacitor/core');
6
- var throat = require('throat');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var throat__default = /*#__PURE__*/_interopDefaultLegacy(throat);
11
6
 
12
7
  /**
13
8
  * Android scan mode
@@ -129,13 +124,22 @@ const BluetoothLe = core.registerPlugin('BluetoothLe', {
129
124
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.BluetoothLeWeb()),
130
125
  });
131
126
 
127
+ const makeQueue = () => {
128
+ let currentTask = Promise.resolve();
129
+ // create a new promise so that errors can be bubbled
130
+ // up to the caller without being caught by the queue
131
+ return (fn) => new Promise((resolve, reject) => {
132
+ currentTask = currentTask
133
+ .then(() => fn())
134
+ .then(resolve)
135
+ .catch(reject);
136
+ });
137
+ };
132
138
  function getQueue(enabled) {
133
139
  if (enabled) {
134
- return throat__default["default"](1);
135
- }
136
- else {
137
- return (fn) => fn();
140
+ return makeQueue();
138
141
  }
142
+ return (fn) => fn();
139
143
  }
140
144
 
141
145
  function parseUUID(uuid) {
@@ -601,9 +605,11 @@ class BluetoothLeWeb extends core.WebPlugin {
601
605
  }
602
606
  this.scan = null;
603
607
  }
604
- async getDevices(_options) {
608
+ async getDevices(options) {
605
609
  const devices = await navigator.bluetooth.getDevices();
606
- const bleDevices = devices.map((device) => {
610
+ const bleDevices = devices
611
+ .filter((device) => options.deviceIds.includes(device.id))
612
+ .map((device) => {
607
613
  this.deviceMap.set(device.id, device);
608
614
  const bleDevice = this.getBleDevice(device);
609
615
  return bleDevice;