@capacitor-community/bluetooth-le 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -161
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +43 -19
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +82 -78
- package/dist/docs.json +906 -849
- package/dist/esm/bleClient.js +15 -1
- package/dist/esm/bleClient.js.map +1 -1
- package/dist/esm/conversion.d.ts +12 -0
- package/dist/esm/conversion.js +33 -0
- package/dist/esm/conversion.js.map +1 -1
- package/dist/esm/definitions.d.ts +41 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -0
- package/dist/esm/web.js +66 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +115 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +115 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/DeviceListView.swift +121 -0
- package/ios/Plugin/DeviceManager.swift +114 -13
- package/ios/Plugin/Plugin.swift +61 -6
- package/package.json +13 -3
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-
|
|
16
|
+
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-25-orange?style=flat-square" /></a>
|
|
17
17
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
18
18
|
</p>
|
|
19
19
|
|
|
@@ -89,7 +89,6 @@ Below is an index of all the methods available.
|
|
|
89
89
|
- [`startNotifications(...)`](#startnotifications)
|
|
90
90
|
- [`stopNotifications(...)`](#stopnotifications)
|
|
91
91
|
- [Interfaces](#interfaces)
|
|
92
|
-
- [Type Aliases](#type-aliases)
|
|
93
92
|
- [Enums](#enums)
|
|
94
93
|
|
|
95
94
|
</docgen-index>
|
|
@@ -786,7 +785,7 @@ Read the value of a characteristic. For an example, see [usage](#usage).
|
|
|
786
785
|
| **`characteristic`** | <code>string</code> | UUID of the characteristic (see [UUID format](#uuid-format)) |
|
|
787
786
|
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call |
|
|
788
787
|
|
|
789
|
-
**Returns:** <code>Promise<
|
|
788
|
+
**Returns:** <code>Promise<[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)></code>
|
|
790
789
|
|
|
791
790
|
---
|
|
792
791
|
|
|
@@ -798,13 +797,13 @@ write(deviceId: string, service: string, characteristic: string, value: DataView
|
|
|
798
797
|
|
|
799
798
|
Write a value to a characteristic. For an example, see [usage](#usage).
|
|
800
799
|
|
|
801
|
-
| Param | Type
|
|
802
|
-
| -------------------- |
|
|
803
|
-
| **`deviceId`** | <code>string</code>
|
|
804
|
-
| **`service`** | <code>string</code>
|
|
805
|
-
| **`characteristic`** | <code>string</code>
|
|
806
|
-
| **`value`** | <code
|
|
807
|
-
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code>
|
|
800
|
+
| Param | Type | Description |
|
|
801
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
802
|
+
| **`deviceId`** | <code>string</code> | The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan)) |
|
|
803
|
+
| **`service`** | <code>string</code> | UUID of the service (see [UUID format](#uuid-format)) |
|
|
804
|
+
| **`characteristic`** | <code>string</code> | UUID of the characteristic (see [UUID format](#uuid-format)) |
|
|
805
|
+
| **`value`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)</code> | The value to write as a [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView). To create a [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0]) |
|
|
806
|
+
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call |
|
|
808
807
|
|
|
809
808
|
---
|
|
810
809
|
|
|
@@ -816,13 +815,13 @@ writeWithoutResponse(deviceId: string, service: string, characteristic: string,
|
|
|
816
815
|
|
|
817
816
|
Write a value to a characteristic without waiting for a response.
|
|
818
817
|
|
|
819
|
-
| Param | Type
|
|
820
|
-
| -------------------- |
|
|
821
|
-
| **`deviceId`** | <code>string</code>
|
|
822
|
-
| **`service`** | <code>string</code>
|
|
823
|
-
| **`characteristic`** | <code>string</code>
|
|
824
|
-
| **`value`** | <code
|
|
825
|
-
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code>
|
|
818
|
+
| Param | Type | Description |
|
|
819
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
820
|
+
| **`deviceId`** | <code>string</code> | The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan)) |
|
|
821
|
+
| **`service`** | <code>string</code> | UUID of the service (see [UUID format](#uuid-format)) |
|
|
822
|
+
| **`characteristic`** | <code>string</code> | UUID of the characteristic (see [UUID format](#uuid-format)) |
|
|
823
|
+
| **`value`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)</code> | The value to write as a [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView). To create a [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0]) |
|
|
824
|
+
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call |
|
|
826
825
|
|
|
827
826
|
---
|
|
828
827
|
|
|
@@ -842,7 +841,7 @@ Read the value of a descriptor.
|
|
|
842
841
|
| **`descriptor`** | <code>string</code> | UUID of the descriptor (see [UUID format](#uuid-format)) |
|
|
843
842
|
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call |
|
|
844
843
|
|
|
845
|
-
**Returns:** <code>Promise<
|
|
844
|
+
**Returns:** <code>Promise<[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)></code>
|
|
846
845
|
|
|
847
846
|
---
|
|
848
847
|
|
|
@@ -854,14 +853,14 @@ writeDescriptor(deviceId: string, service: string, characteristic: string, descr
|
|
|
854
853
|
|
|
855
854
|
Write a value to a descriptor.
|
|
856
855
|
|
|
857
|
-
| Param | Type
|
|
858
|
-
| -------------------- |
|
|
859
|
-
| **`deviceId`** | <code>string</code>
|
|
860
|
-
| **`service`** | <code>string</code>
|
|
861
|
-
| **`characteristic`** | <code>string</code>
|
|
862
|
-
| **`descriptor`** | <code>string</code>
|
|
863
|
-
| **`value`** | <code
|
|
864
|
-
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code>
|
|
856
|
+
| Param | Type | Description |
|
|
857
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
858
|
+
| **`deviceId`** | <code>string</code> | The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan)) |
|
|
859
|
+
| **`service`** | <code>string</code> | UUID of the service (see [UUID format](#uuid-format)) |
|
|
860
|
+
| **`characteristic`** | <code>string</code> | UUID of the characteristic (see [UUID format](#uuid-format)) |
|
|
861
|
+
| **`descriptor`** | <code>string</code> | UUID of the descriptor (see [UUID format](#uuid-format)) |
|
|
862
|
+
| **`value`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)</code> | The value to write as a [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView). To create a [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0]) |
|
|
863
|
+
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call |
|
|
865
864
|
|
|
866
865
|
---
|
|
867
866
|
|
|
@@ -876,13 +875,13 @@ Note that you should only start the notifications once per characteristic in you
|
|
|
876
875
|
not call `startNotifications` in every component that needs the data.
|
|
877
876
|
For an example, see [usage](#usage).
|
|
878
877
|
|
|
879
|
-
| Param | Type
|
|
880
|
-
| -------------------- |
|
|
881
|
-
| **`deviceId`** | <code>string</code>
|
|
882
|
-
| **`service`** | <code>string</code>
|
|
883
|
-
| **`characteristic`** | <code>string</code>
|
|
884
|
-
| **`callback`** | <code>(value:
|
|
885
|
-
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code>
|
|
878
|
+
| Param | Type | Description |
|
|
879
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
880
|
+
| **`deviceId`** | <code>string</code> | The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan)) |
|
|
881
|
+
| **`service`** | <code>string</code> | UUID of the service (see [UUID format](#uuid-format)) |
|
|
882
|
+
| **`characteristic`** | <code>string</code> | UUID of the characteristic (see [UUID format](#uuid-format)) |
|
|
883
|
+
| **`callback`** | <code>(value: [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)) => void</code> | Callback function to use when the value of the characteristic changes |
|
|
884
|
+
| **`options`** | <code><a href="#timeoutoptions">TimeoutOptions</a></code> | Options for plugin call. Timeout not supported on **web**. |
|
|
886
885
|
|
|
887
886
|
---
|
|
888
887
|
|
|
@@ -929,134 +928,46 @@ Stop listening to the changes of the value of a characteristic. For an example,
|
|
|
929
928
|
|
|
930
929
|
#### RequestBleDeviceOptions
|
|
931
930
|
|
|
932
|
-
| Prop | Type | Description |
|
|
933
|
-
| ---------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
934
|
-
| **`services`** | <code>string[]</code> | Filter devices by service UUIDs. UUIDs have to be specified as 128 bit UUID strings, e.g. ['0000180d-0000-1000-8000-00805f9b34fb'] There is a helper function to convert numbers to UUIDs. e.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format)) |
|
|
935
|
-
| **`name`** | <code>string</code> | Filter devices by name |
|
|
936
|
-
| **`namePrefix`** | <code>string</code> | Filter devices by name prefix |
|
|
937
|
-
| **`optionalServices`** | <code>string[]</code> | For **web**, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) |
|
|
938
|
-
| **`allowDuplicates`** | <code>boolean</code> | Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`). (default: false) |
|
|
939
|
-
| **`scanMode`** | <code><a href="#scanmode">ScanMode</a></code> | Android scan mode (default: <a href="#scanmode">ScanMode.SCAN_MODE_BALANCED</a>) |
|
|
940
|
-
| **`manufacturerData`** | <code>ManufacturerDataFilter[]</code> | Allow scanning for devices with a specific manufacturer data https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata |
|
|
931
|
+
| Prop | Type | Description | Default |
|
|
932
|
+
| ---------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
|
|
933
|
+
| **`services`** | <code>string[]</code> | Filter devices by service UUIDs. UUIDs have to be specified as 128 bit UUID strings, e.g. ['0000180d-0000-1000-8000-00805f9b34fb'] There is a helper function to convert numbers to UUIDs. e.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format)) | |
|
|
934
|
+
| **`name`** | <code>string</code> | Filter devices by name | |
|
|
935
|
+
| **`namePrefix`** | <code>string</code> | Filter devices by name prefix | |
|
|
936
|
+
| **`optionalServices`** | <code>string[]</code> | For **web**, all services that will be used have to be listed under services or optionalServices, e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format)) | |
|
|
937
|
+
| **`allowDuplicates`** | <code>boolean</code> | Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`). (default: false) | |
|
|
938
|
+
| **`scanMode`** | <code><a href="#scanmode">ScanMode</a></code> | Android scan mode (default: <a href="#scanmode">ScanMode.SCAN_MODE_BALANCED</a>) | |
|
|
939
|
+
| **`manufacturerData`** | <code>ManufacturerDataFilter[]</code> | Allow scanning for devices with a specific manufacturer data https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata | |
|
|
940
|
+
| **`displayMode`** | <code>'alert' \| 'list'</code> | Display mode for the device list in `requestDevice` (**iOS** only). - `"alert"`: Classic alert dialog (default) - `"list"`: Scrollable list view | <code>"alert"</code> |
|
|
941
|
+
| **`serviceData`** | <code>ServiceDataFilter[]</code> | Allow scanning for devices with specific service data. Service data is data associated with a specific service UUID in the advertisement packet. Useful for protocols like OpenDroneID, EddyStone, and Open Beacon. | |
|
|
941
942
|
|
|
942
943
|
#### ManufacturerDataFilter
|
|
943
944
|
|
|
944
|
-
| Prop | Type
|
|
945
|
-
| ----------------------- |
|
|
946
|
-
| **`companyIdentifier`** | <code>number</code>
|
|
947
|
-
| **`dataPrefix`** | <code
|
|
948
|
-
| **`mask`** | <code
|
|
949
|
-
|
|
950
|
-
####
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
|
956
|
-
|
|
|
957
|
-
| **`BYTES_PER_ELEMENT`** | <code>number</code> | The size in bytes of each element in the array. |
|
|
958
|
-
| **`buffer`** | <code><a href="#arraybufferlike">ArrayBufferLike</a></code> | The <a href="#arraybuffer">ArrayBuffer</a> instance referenced by the array. |
|
|
959
|
-
| **`byteLength`** | <code>number</code> | The length in bytes of the array. |
|
|
960
|
-
| **`byteOffset`** | <code>number</code> | The offset in bytes of the array. |
|
|
961
|
-
| **`length`** | <code>number</code> | The length of the array. |
|
|
962
|
-
|
|
963
|
-
| Method | Signature | Description |
|
|
964
|
-
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
965
|
-
| **copyWithin** | (target: number, start: number, end?: number \| undefined) => this | Returns the this object after copying a section of the array identified by start and end to the same array starting at position target |
|
|
966
|
-
| **every** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) => unknown, thisArg?: any) => boolean | Determines whether all the members of an array satisfy the specified test. |
|
|
967
|
-
| **fill** | (value: number, start?: number \| undefined, end?: number \| undefined) => this | Returns the this object after filling the section identified by start and end with value |
|
|
968
|
-
| **filter** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) => any, thisArg?: any) => <a href="#uint8array">Uint8Array</a> | Returns the elements of an array that meet the condition specified in a callback function. |
|
|
969
|
-
| **find** | (predicate: (value: number, index: number, obj: <a href="#uint8array">Uint8Array</a>) => boolean, thisArg?: any) => number \| undefined | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
|
|
970
|
-
| **findIndex** | (predicate: (value: number, index: number, obj: <a href="#uint8array">Uint8Array</a>) => boolean, thisArg?: any) => number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
|
|
971
|
-
| **forEach** | (callbackfn: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
|
|
972
|
-
| **indexOf** | (searchElement: number, fromIndex?: number \| undefined) => number | Returns the index of the first occurrence of a value in an array. |
|
|
973
|
-
| **join** | (separator?: string \| undefined) => string | Adds all the elements of an array separated by the specified separator string. |
|
|
974
|
-
| **lastIndexOf** | (searchElement: number, fromIndex?: number \| undefined) => number | Returns the index of the last occurrence of a value in an array. |
|
|
975
|
-
| **map** | (callbackfn: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) => number, thisArg?: any) => <a href="#uint8array">Uint8Array</a> | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
|
|
976
|
-
| **reduce** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => number) => number | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
977
|
-
| **reduce** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => number, initialValue: number) => number | |
|
|
978
|
-
| **reduce** | <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => U, initialValue: U) => U | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
979
|
-
| **reduceRight** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => number) => number | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
980
|
-
| **reduceRight** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => number, initialValue: number) => number | |
|
|
981
|
-
| **reduceRight** | <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => U, initialValue: U) => U | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
982
|
-
| **reverse** | () => <a href="#uint8array">Uint8Array</a> | Reverses the elements in an Array. |
|
|
983
|
-
| **set** | (array: <a href="#arraylike">ArrayLike</a><number>, offset?: number \| undefined) => void | Sets a value or an array of values. |
|
|
984
|
-
| **slice** | (start?: number \| undefined, end?: number \| undefined) => <a href="#uint8array">Uint8Array</a> | Returns a section of an array. |
|
|
985
|
-
| **some** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
|
|
986
|
-
| **sort** | (compareFn?: ((a: number, b: number) => number) \| undefined) => this | Sorts an array. |
|
|
987
|
-
| **subarray** | (begin?: number \| undefined, end?: number \| undefined) => <a href="#uint8array">Uint8Array</a> | Gets a new <a href="#uint8array">Uint8Array</a> view of the <a href="#arraybuffer">ArrayBuffer</a> store for this array, referencing the elements at begin, inclusive, up to end, exclusive. |
|
|
988
|
-
| **toLocaleString** | () => string | Converts a number to a string by using the current locale. |
|
|
989
|
-
| **toString** | () => string | Returns a string representation of an array. |
|
|
990
|
-
| **valueOf** | () => <a href="#uint8array">Uint8Array</a> | Returns the primitive value of the specified object. |
|
|
991
|
-
|
|
992
|
-
#### ArrayLike
|
|
993
|
-
|
|
994
|
-
| Prop | Type |
|
|
995
|
-
| ------------ | ------------------- |
|
|
996
|
-
| **`length`** | <code>number</code> |
|
|
997
|
-
|
|
998
|
-
#### ArrayBufferTypes
|
|
999
|
-
|
|
1000
|
-
Allowed <a href="#arraybuffer">ArrayBuffer</a> types for the buffer of an ArrayBufferView and related Typed Arrays.
|
|
1001
|
-
|
|
1002
|
-
| Prop | Type |
|
|
1003
|
-
| ----------------- | --------------------------------------------------- |
|
|
1004
|
-
| **`ArrayBuffer`** | <code><a href="#arraybuffer">ArrayBuffer</a></code> |
|
|
1005
|
-
|
|
1006
|
-
#### ArrayBuffer
|
|
1007
|
-
|
|
1008
|
-
Represents a raw buffer of binary data, which is used to store data for the
|
|
1009
|
-
different typed arrays. ArrayBuffers cannot be read from or written to directly,
|
|
1010
|
-
but can be passed to a typed array or <a href="#dataview">DataView</a> Object to interpret the raw
|
|
1011
|
-
buffer as needed.
|
|
1012
|
-
|
|
1013
|
-
| Prop | Type | Description |
|
|
1014
|
-
| ---------------- | ------------------- | ------------------------------------------------------------------------------- |
|
|
1015
|
-
| **`byteLength`** | <code>number</code> | Read-only. The length of the <a href="#arraybuffer">ArrayBuffer</a> (in bytes). |
|
|
1016
|
-
|
|
1017
|
-
| Method | Signature | Description |
|
|
1018
|
-
| --------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
|
1019
|
-
| **slice** | (begin: number, end?: number \| undefined) => <a href="#arraybuffer">ArrayBuffer</a> | Returns a section of an <a href="#arraybuffer">ArrayBuffer</a>. |
|
|
945
|
+
| Prop | Type | Description |
|
|
946
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
947
|
+
| **`companyIdentifier`** | <code>number</code> | Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field. |
|
|
948
|
+
| **`dataPrefix`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)</code> | Prefix to match in the manufacturer data field. On **Android** this field is mandatory. android, ios: DataView web: [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) |
|
|
949
|
+
| **`mask`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)</code> | Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0. The `mask` must have the same length of dataPrefix. android, ios: DataView web: [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) |
|
|
950
|
+
|
|
951
|
+
#### ServiceDataFilter
|
|
952
|
+
|
|
953
|
+
| Prop | Type | Description |
|
|
954
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
955
|
+
| **`serviceUuid`** | <code>string</code> | Service UUID to filter by. The service data must be associated with this UUID. UUIDs have to be specified as 128 bit UUID strings, e.g. '0000fffa-0000-1000-8000-00805f9b34fb' |
|
|
956
|
+
| **`dataPrefix`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)</code> | Prefix to match in the service data field. For example, OpenDroneID uses [0x0D] as the advertisement code. android, ios: string web: [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) |
|
|
957
|
+
| **`mask`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)</code> | Set filter on partial service data. For any bit in the mask, set it to 1 if it needs to match the one in service data, otherwise set it to 0. The `mask` must have the same length as dataPrefix. android, ios: string web: [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView) |
|
|
1020
958
|
|
|
1021
959
|
#### ScanResult
|
|
1022
960
|
|
|
1023
|
-
| Prop | Type
|
|
1024
|
-
| ---------------------- |
|
|
1025
|
-
| **`device`** | <code><a href="#bledevice">BleDevice</a></code>
|
|
1026
|
-
| **`localName`** | <code>string</code>
|
|
1027
|
-
| **`rssi`** | <code>number</code>
|
|
1028
|
-
| **`txPower`** | <code>number</code>
|
|
1029
|
-
| **`manufacturerData`** | <code>{ [key: string]:
|
|
1030
|
-
| **`serviceData`** | <code>{ [key: string]:
|
|
1031
|
-
| **`uuids`** | <code>string[]</code>
|
|
1032
|
-
| **`rawAdvertisement`** | <code
|
|
1033
|
-
|
|
1034
|
-
#### DataView
|
|
1035
|
-
|
|
1036
|
-
| Prop | Type |
|
|
1037
|
-
| ---------------- | --------------------------------------------------- |
|
|
1038
|
-
| **`buffer`** | <code><a href="#arraybuffer">ArrayBuffer</a></code> |
|
|
1039
|
-
| **`byteLength`** | <code>number</code> |
|
|
1040
|
-
| **`byteOffset`** | <code>number</code> |
|
|
1041
|
-
|
|
1042
|
-
| Method | Signature | Description |
|
|
1043
|
-
| -------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1044
|
-
| **getFloat32** | (byteOffset: number, littleEndian?: boolean \| undefined) => number | Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1045
|
-
| **getFloat64** | (byteOffset: number, littleEndian?: boolean \| undefined) => number | Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1046
|
-
| **getInt8** | (byteOffset: number) => number | Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1047
|
-
| **getInt16** | (byteOffset: number, littleEndian?: boolean \| undefined) => number | Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1048
|
-
| **getInt32** | (byteOffset: number, littleEndian?: boolean \| undefined) => number | Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1049
|
-
| **getUint8** | (byteOffset: number) => number | Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1050
|
-
| **getUint16** | (byteOffset: number, littleEndian?: boolean \| undefined) => number | Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1051
|
-
| **getUint32** | (byteOffset: number, littleEndian?: boolean \| undefined) => number | Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. |
|
|
1052
|
-
| **setFloat32** | (byteOffset: number, value: number, littleEndian?: boolean \| undefined) => void | Stores an Float32 value at the specified byte offset from the start of the view. |
|
|
1053
|
-
| **setFloat64** | (byteOffset: number, value: number, littleEndian?: boolean \| undefined) => void | Stores an Float64 value at the specified byte offset from the start of the view. |
|
|
1054
|
-
| **setInt8** | (byteOffset: number, value: number) => void | Stores an Int8 value at the specified byte offset from the start of the view. |
|
|
1055
|
-
| **setInt16** | (byteOffset: number, value: number, littleEndian?: boolean \| undefined) => void | Stores an Int16 value at the specified byte offset from the start of the view. |
|
|
1056
|
-
| **setInt32** | (byteOffset: number, value: number, littleEndian?: boolean \| undefined) => void | Stores an Int32 value at the specified byte offset from the start of the view. |
|
|
1057
|
-
| **setUint8** | (byteOffset: number, value: number) => void | Stores an Uint8 value at the specified byte offset from the start of the view. |
|
|
1058
|
-
| **setUint16** | (byteOffset: number, value: number, littleEndian?: boolean \| undefined) => void | Stores an Uint16 value at the specified byte offset from the start of the view. |
|
|
1059
|
-
| **setUint32** | (byteOffset: number, value: number, littleEndian?: boolean \| undefined) => void | Stores an Uint32 value at the specified byte offset from the start of the view. |
|
|
961
|
+
| Prop | Type | Description |
|
|
962
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
963
|
+
| **`device`** | <code><a href="#bledevice">BleDevice</a></code> | The peripheral device that was found in the scan. **Android** and **web**: `device.name` is always identical to `localName`. **iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans. |
|
|
964
|
+
| **`localName`** | <code>string</code> | The name of the peripheral device from the advertisement data. |
|
|
965
|
+
| **`rssi`** | <code>number</code> | Received Signal Strength Indication. |
|
|
966
|
+
| **`txPower`** | <code>number</code> | Transmit power in dBm. A value of 127 indicates that it is not available. |
|
|
967
|
+
| **`manufacturerData`** | <code>{ [key: string]: [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView); }</code> | Manufacturer data, key is a company identifier and value is the data. |
|
|
968
|
+
| **`serviceData`** | <code>{ [key: string]: [DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView); }</code> | Service data, key is a service UUID and value is the data. |
|
|
969
|
+
| **`uuids`** | <code>string[]</code> | Advertised services. |
|
|
970
|
+
| **`rawAdvertisement`** | <code>[DataView](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView)</code> | Raw advertisement data (**Android** only). |
|
|
1060
971
|
|
|
1061
972
|
#### TimeoutOptions
|
|
1062
973
|
|
|
@@ -1102,12 +1013,6 @@ buffer as needed.
|
|
|
1102
1013
|
| ---------- | ------------------- |
|
|
1103
1014
|
| **`uuid`** | <code>string</code> |
|
|
1104
1015
|
|
|
1105
|
-
### Type Aliases
|
|
1106
|
-
|
|
1107
|
-
#### ArrayBufferLike
|
|
1108
|
-
|
|
1109
|
-
<code>ArrayBufferTypes[keyof ArrayBufferTypes]</code>
|
|
1110
|
-
|
|
1111
1016
|
### Enums
|
|
1112
1017
|
|
|
1113
1018
|
#### ScanMode
|
|
@@ -1211,6 +1116,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
1211
1116
|
<tr>
|
|
1212
1117
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/gion-andri"><img src="https://avatars.githubusercontent.com/u/540998?v=4?s=100" width="100px;" alt="Gion-Andri Cantieni"/><br /><sub><b>Gion-Andri Cantieni</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=gion-andri" title="Code">💻</a></td>
|
|
1213
1118
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/JasonAsmk"><img src="https://avatars.githubusercontent.com/u/994111?v=4?s=100" width="100px;" alt="Iason Asimakopoulos"/><br /><sub><b>Iason Asimakopoulos</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=JasonAsmk" title="Code">💻</a></td>
|
|
1119
|
+
<td align="center" valign="top" width="14.28%"><a href="https://www.talaviram.com"><img src="https://avatars.githubusercontent.com/u/6911158?v=4?s=100" width="100px;" alt="Tal Aviram"/><br /><sub><b>Tal Aviram</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=talaviram" title="Code">💻</a></td>
|
|
1120
|
+
<td align="center" valign="top" width="14.28%"><a href="https://emmanuelrobinson.dev/"><img src="https://avatars.githubusercontent.com/u/52470812?v=4?s=100" width="100px;" alt="Emmanuel Robinson Ejakpomewhe"/><br /><sub><b>Emmanuel Robinson Ejakpomewhe</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=emmanuelorobinson" title="Code">💻</a></td>
|
|
1214
1121
|
</tr>
|
|
1215
1122
|
</tbody>
|
|
1216
1123
|
</table>
|
|
@@ -513,6 +513,7 @@ class BluetoothLe : Plugin() {
|
|
|
513
513
|
device.disconnect(timeout) { response ->
|
|
514
514
|
run {
|
|
515
515
|
if (response.success) {
|
|
516
|
+
device.cleanup()
|
|
516
517
|
deviceMap.remove(device.getId())
|
|
517
518
|
call.resolve()
|
|
518
519
|
} else {
|
|
@@ -812,6 +813,7 @@ class BluetoothLe : Plugin() {
|
|
|
812
813
|
|
|
813
814
|
val services = (call.getArray("services", JSArray()) as JSArray).toList<String>()
|
|
814
815
|
val manufacturerDataArray = call.getArray("manufacturerData", JSArray())
|
|
816
|
+
val serviceDataArray = call.getArray("serviceData", JSArray())
|
|
815
817
|
val name = call.getString("name", null)
|
|
816
818
|
|
|
817
819
|
try {
|
|
@@ -825,6 +827,43 @@ class BluetoothLe : Plugin() {
|
|
|
825
827
|
filters.add(filter.build())
|
|
826
828
|
}
|
|
827
829
|
|
|
830
|
+
// Service Data Handling (for filtering by service data like OpenDroneID)
|
|
831
|
+
serviceDataArray?.let {
|
|
832
|
+
for (i in 0 until it.length()) {
|
|
833
|
+
val serviceDataObject = it.getJSONObject(i)
|
|
834
|
+
|
|
835
|
+
val serviceUuid = serviceDataObject.getString("serviceUuid")
|
|
836
|
+
val servicePuuid = ParcelUuid.fromString(serviceUuid)
|
|
837
|
+
|
|
838
|
+
val dataPrefix = if (serviceDataObject.has("dataPrefix")) {
|
|
839
|
+
val dataPrefixString = serviceDataObject.getString("dataPrefix")
|
|
840
|
+
stringToBytes(dataPrefixString)
|
|
841
|
+
} else null
|
|
842
|
+
|
|
843
|
+
val mask = if (serviceDataObject.has("mask")) {
|
|
844
|
+
val maskString = serviceDataObject.getString("mask")
|
|
845
|
+
stringToBytes(maskString)
|
|
846
|
+
} else null
|
|
847
|
+
|
|
848
|
+
val filterBuilder = ScanFilter.Builder()
|
|
849
|
+
|
|
850
|
+
if (dataPrefix != null && mask != null) {
|
|
851
|
+
filterBuilder.setServiceData(servicePuuid, dataPrefix, mask)
|
|
852
|
+
} else if (dataPrefix != null) {
|
|
853
|
+
filterBuilder.setServiceData(servicePuuid, dataPrefix)
|
|
854
|
+
} else {
|
|
855
|
+
// Set service data filter without data (just match the service UUID)
|
|
856
|
+
filterBuilder.setServiceData(servicePuuid, byteArrayOf())
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
if (name != null) {
|
|
860
|
+
filterBuilder.setDeviceName(name)
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
filters.add(filterBuilder.build())
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
828
867
|
// Manufacturer Data Handling (with optional parameters)
|
|
829
868
|
manufacturerDataArray?.let {
|
|
830
869
|
for (i in 0 until it.length()) {
|
|
@@ -833,28 +872,13 @@ class BluetoothLe : Plugin() {
|
|
|
833
872
|
val companyIdentifier = manufacturerDataObject.getInt("companyIdentifier")
|
|
834
873
|
|
|
835
874
|
val dataPrefix = if (manufacturerDataObject.has("dataPrefix")) {
|
|
836
|
-
val
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
ByteArray(byteLength).apply {
|
|
840
|
-
for (idx in 0 until byteLength) {
|
|
841
|
-
val key = idx.toString()
|
|
842
|
-
this[idx] = (dataPrefixObject.getInt(key) and 0xFF).toByte()
|
|
843
|
-
}
|
|
844
|
-
}
|
|
875
|
+
val dataPrefixString = manufacturerDataObject.getString("dataPrefix")
|
|
876
|
+
stringToBytes(dataPrefixString)
|
|
845
877
|
} else null
|
|
846
878
|
|
|
847
|
-
|
|
848
879
|
val mask = if (manufacturerDataObject.has("mask")) {
|
|
849
|
-
val
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
ByteArray(byteLength).apply {
|
|
853
|
-
for (idx in 0 until byteLength) {
|
|
854
|
-
val key = idx.toString()
|
|
855
|
-
this[idx] = (maskObject.getInt(key) and 0xFF).toByte()
|
|
856
|
-
}
|
|
857
|
-
}
|
|
880
|
+
val maskString = manufacturerDataObject.getString("mask")
|
|
881
|
+
stringToBytes(maskString)
|
|
858
882
|
} else null
|
|
859
883
|
|
|
860
884
|
val filterBuilder = ScanFilter.Builder()
|