@capacitor-community/bluetooth-le 8.0.1 → 8.0.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.
Files changed (52) hide show
  1. package/CapacitorCommunityBluetoothLe.podspec +17 -17
  2. package/LICENSE +21 -21
  3. package/Package.swift +27 -27
  4. package/README.md +2 -1
  5. package/android/build.gradle +73 -73
  6. package/android/src/main/AndroidManifest.xml +22 -22
  7. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1094 -1094
  8. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
  9. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +771 -771
  10. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
  11. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
  12. package/dist/docs.json +43 -43
  13. package/dist/esm/bleClient.d.ts +278 -278
  14. package/dist/esm/bleClient.js +361 -361
  15. package/dist/esm/bleClient.js.map +1 -1
  16. package/dist/esm/config.d.ts +53 -53
  17. package/dist/esm/config.js +2 -2
  18. package/dist/esm/conversion.d.ts +56 -56
  19. package/dist/esm/conversion.js +134 -134
  20. package/dist/esm/conversion.js.map +1 -1
  21. package/dist/esm/definitions.d.ts +352 -352
  22. package/dist/esm/definitions.js +42 -42
  23. package/dist/esm/definitions.js.map +1 -1
  24. package/dist/esm/index.d.ts +5 -5
  25. package/dist/esm/index.js +5 -5
  26. package/dist/esm/plugin.d.ts +2 -2
  27. package/dist/esm/plugin.js +4 -4
  28. package/dist/esm/queue.d.ts +3 -3
  29. package/dist/esm/queue.js +17 -17
  30. package/dist/esm/timeout.d.ts +1 -1
  31. package/dist/esm/timeout.js +9 -9
  32. package/dist/esm/validators.d.ts +1 -1
  33. package/dist/esm/validators.js +11 -11
  34. package/dist/esm/web.d.ts +57 -57
  35. package/dist/esm/web.js +403 -403
  36. package/dist/esm/web.js.map +1 -1
  37. package/dist/plugin.cjs.js +964 -964
  38. package/dist/plugin.cjs.js.map +1 -1
  39. package/dist/plugin.js +964 -964
  40. package/dist/plugin.js.map +1 -1
  41. package/ios/Sources/BluetoothLe/Conversion.swift +83 -83
  42. package/ios/Sources/BluetoothLe/Device.swift +422 -423
  43. package/ios/Sources/BluetoothLe/DeviceListView.swift +121 -121
  44. package/ios/Sources/BluetoothLe/DeviceManager.swift +409 -415
  45. package/ios/Sources/BluetoothLe/Logging.swift +8 -8
  46. package/ios/Sources/BluetoothLe/Plugin.swift +768 -763
  47. package/ios/Sources/BluetoothLe/ScanFilters.swift +114 -114
  48. package/ios/Sources/BluetoothLe/ThreadSafeDictionary.swift +61 -15
  49. package/ios/Tests/BluetoothLeTests/ConversionTests.swift +55 -55
  50. package/ios/Tests/BluetoothLeTests/PluginTests.swift +27 -27
  51. package/ios/Tests/BluetoothLeTests/ScanFiltersTests.swift +153 -153
  52. package/package.json +114 -114
@@ -1,278 +1,278 @@
1
- import type { DisplayStrings } from './config';
2
- import type { BleDevice, BleService, ConnectionPriority, InitializeOptions, RequestBleDeviceOptions, ScanResult, TimeoutOptions } from './definitions';
3
- export interface BleClientInterface {
4
- /**
5
- * Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.
6
- * On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.
7
- * For an example, see [usage](#usage).
8
- */
9
- initialize(options?: InitializeOptions): Promise<void>;
10
- /**
11
- * Reports whether Bluetooth is enabled on this device.
12
- * Always returns `true` on **web**.
13
- */
14
- isEnabled(): Promise<boolean>;
15
- /**
16
- * Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE
17
- * Only available on **Android**.*/
18
- requestEnable(): Promise<void>;
19
- /**
20
- * Enable Bluetooth.
21
- * Only available on **Android**.
22
- * **Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()
23
- * @deprecated Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()
24
- */
25
- enable(): Promise<void>;
26
- /**
27
- * Disable Bluetooth.
28
- * Only available on **Android**.
29
- * **Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()
30
- * @deprecated Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()
31
- */
32
- disable(): Promise<void>;
33
- /**
34
- * Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.
35
- * Not available on **web** (the callback will never be invoked).
36
- * @param callback Callback function to use when the Bluetooth state changes.
37
- */
38
- startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;
39
- /**
40
- * Stop the enabled notifications registered with `startEnabledNotifications`.
41
- */
42
- stopEnabledNotifications(): Promise<void>;
43
- /**
44
- * Reports whether Location Services are enabled on this device.
45
- * Only available on **Android**.
46
- */
47
- isLocationEnabled(): Promise<boolean>;
48
- /**
49
- * Open Location settings.
50
- * Only available on **Android**.
51
- */
52
- openLocationSettings(): Promise<void>;
53
- /**
54
- * Open Bluetooth settings.
55
- * Only available on **Android**.
56
- */
57
- openBluetoothSettings(): Promise<void>;
58
- /**
59
- * Open App settings.
60
- * Not available on **web**.
61
- * On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible
62
- * to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings
63
- * for the app to be able use it.
64
- */
65
- openAppSettings(): Promise<void>;
66
- /**
67
- * Set the strings that are displayed in the `requestDevice` dialog.
68
- * @param displayStrings
69
- */
70
- setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;
71
- /**
72
- * 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.
73
- * For an example, see [usage](#usage).
74
- * @param options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)
75
- */
76
- requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;
77
- /**
78
- * 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.
79
- * Scanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).
80
- * **Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.
81
- * @param options
82
- * @param callback
83
- */
84
- requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;
85
- /**
86
- * Stop scanning for BLE devices. For an example, see [usage](#usage).
87
- */
88
- stopLEScan(): Promise<void>;
89
- /**
90
- * On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.
91
- * Uses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and
92
- * [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.
93
- * On Android, you can directly connect to the device with the deviceId.
94
- * @param deviceIds List of device IDs, e.g. saved from a previous app run.
95
- */
96
- getDevices(deviceIds: string[]): Promise<BleDevice[]>;
97
- /**
98
- * Get a list of currently bonded devices.
99
- * Only available on **Android**.
100
- * Uses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android
101
- */
102
- getBondedDevices(): Promise<BleDevice[]>;
103
- /**
104
- * Get a list of currently connected devices.
105
- * Uses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,
106
- * [getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android
107
- * and [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.
108
- * @param services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS.
109
- */
110
- getConnectedDevices(services: string[]): Promise<BleDevice[]>;
111
- /**
112
- * Connect to a peripheral BLE device. For an example, see [usage](#usage).
113
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
114
- * @param onDisconnect Optional disconnect callback function that will be used when the device disconnects
115
- * @param options Options for plugin call
116
- */
117
- connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;
118
- /**
119
- * Create a bond with a peripheral BLE device.
120
- * Only available on **Android**. On iOS bonding is handled by the OS.
121
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
122
- * @param options Options for plugin call
123
- */
124
- createBond(deviceId: string, options?: TimeoutOptions): Promise<void>;
125
- /**
126
- * Report whether a peripheral BLE device is bonded.
127
- * Only available on **Android**. On iOS bonding is handled by the OS.
128
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
129
- */
130
- isBonded(deviceId: string): Promise<boolean>;
131
- /**
132
- * Disconnect from a peripheral BLE device. For an example, see [usage](#usage).
133
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
134
- */
135
- disconnect(deviceId: string): Promise<void>;
136
- /**
137
- * Get services, characteristics and descriptors of a device.
138
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
139
- */
140
- getServices(deviceId: string): Promise<BleService[]>;
141
- /**
142
- * Discover services, characteristics and descriptors of a device.
143
- * You only need this method if your peripheral device changes its services and characteristics at runtime.
144
- * If the discovery was successful, the remote services can be retrieved using the getServices function.
145
- * Not available on **web**.
146
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
147
- */
148
- discoverServices(deviceId: string): Promise<void>;
149
- /**
150
- * Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.
151
- * Not available on **web**.
152
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
153
- */
154
- getMtu(deviceId: string): Promise<number>;
155
- /**
156
- * Request a connection parameter update.
157
- * Only available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)
158
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
159
- * @param connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)
160
- */
161
- requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;
162
- /**
163
- * Read the RSSI value of a connected device.
164
- * Not available on **web**.
165
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
166
- */
167
- readRssi(deviceId: string): Promise<number>;
168
- /**
169
- * Read the value of a characteristic. For an example, see [usage](#usage).
170
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
171
- * @param service UUID of the service (see [UUID format](#uuid-format))
172
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
173
- * @param options Options for plugin call
174
- */
175
- read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;
176
- /**
177
- * Write a value to a characteristic. For an example, see [usage](#usage).
178
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
179
- * @param service UUID of the service (see [UUID format](#uuid-format))
180
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
181
- * @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])
182
- * @param options Options for plugin call
183
- */
184
- write(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
185
- /**
186
- * Write a value to a characteristic without waiting for a response.
187
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
188
- * @param service UUID of the service (see [UUID format](#uuid-format))
189
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
190
- * @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])
191
- * @param options Options for plugin call
192
- */
193
- writeWithoutResponse(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
194
- /**
195
- * Read the value of a descriptor.
196
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
197
- * @param service UUID of the service (see [UUID format](#uuid-format))
198
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
199
- * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))
200
- * @param options Options for plugin call
201
- */
202
- readDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, options?: TimeoutOptions): Promise<DataView>;
203
- /**
204
- * Write a value to a descriptor.
205
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
206
- * @param service UUID of the service (see [UUID format](#uuid-format))
207
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
208
- * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))
209
- * @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])
210
- * @param options Options for plugin call
211
- */
212
- writeDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, value: DataView, options?: TimeoutOptions): Promise<void>;
213
- /**
214
- * Start listening to changes of the value of a characteristic.
215
- * Note that you should only start the notifications once per characteristic in your app and share the data and
216
- * not call `startNotifications` in every component that needs the data.
217
- * For an example, see [usage](#usage).
218
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
219
- * @param service UUID of the service (see [UUID format](#uuid-format))
220
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
221
- * @param callback Callback function to use when the value of the characteristic changes
222
- * @param options Options for plugin call. Timeout not supported on **web**.
223
- */
224
- startNotifications(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void, options?: TimeoutOptions): Promise<void>;
225
- /**
226
- * Stop listening to the changes of the value of a characteristic. For an example, see [usage](#usage).
227
- * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
228
- * @param service UUID of the service (see [UUID format](#uuid-format))
229
- * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
230
- */
231
- stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;
232
- }
233
- declare class BleClientClass implements BleClientInterface {
234
- private scanListener;
235
- private eventListeners;
236
- private queue;
237
- enableQueue(): void;
238
- disableQueue(): void;
239
- initialize(options?: InitializeOptions): Promise<void>;
240
- isEnabled(): Promise<boolean>;
241
- requestEnable(): Promise<void>;
242
- enable(): Promise<void>;
243
- disable(): Promise<void>;
244
- startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;
245
- stopEnabledNotifications(): Promise<void>;
246
- isLocationEnabled(): Promise<boolean>;
247
- openLocationSettings(): Promise<void>;
248
- openBluetoothSettings(): Promise<void>;
249
- openAppSettings(): Promise<void>;
250
- setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;
251
- requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;
252
- requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;
253
- stopLEScan(): Promise<void>;
254
- getDevices(deviceIds: string[]): Promise<BleDevice[]>;
255
- getConnectedDevices(services: string[]): Promise<BleDevice[]>;
256
- getBondedDevices(): Promise<BleDevice[]>;
257
- connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;
258
- createBond(deviceId: string, options?: TimeoutOptions): Promise<void>;
259
- isBonded(deviceId: string): Promise<boolean>;
260
- disconnect(deviceId: string): Promise<void>;
261
- getServices(deviceId: string): Promise<BleService[]>;
262
- discoverServices(deviceId: string): Promise<void>;
263
- getMtu(deviceId: string): Promise<number>;
264
- requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;
265
- readRssi(deviceId: string): Promise<number>;
266
- read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;
267
- write(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
268
- writeWithoutResponse(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
269
- readDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, options?: TimeoutOptions): Promise<DataView>;
270
- writeDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, value: DataView, options?: TimeoutOptions): Promise<void>;
271
- startNotifications(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void, options?: TimeoutOptions): Promise<void>;
272
- stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;
273
- private validateRequestBleDeviceOptions;
274
- private convertValue;
275
- private convertObject;
276
- }
277
- export declare const BleClient: BleClientClass;
278
- export {};
1
+ import type { DisplayStrings } from './config';
2
+ import type { BleDevice, BleService, ConnectionPriority, InitializeOptions, RequestBleDeviceOptions, ScanResult, TimeoutOptions } from './definitions';
3
+ export interface BleClientInterface {
4
+ /**
5
+ * Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.
6
+ * On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.
7
+ * For an example, see [usage](#usage).
8
+ */
9
+ initialize(options?: InitializeOptions): Promise<void>;
10
+ /**
11
+ * Reports whether Bluetooth is enabled on this device.
12
+ * Always returns `true` on **web**.
13
+ */
14
+ isEnabled(): Promise<boolean>;
15
+ /**
16
+ * Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE
17
+ * Only available on **Android**.*/
18
+ requestEnable(): Promise<void>;
19
+ /**
20
+ * Enable Bluetooth.
21
+ * Only available on **Android**.
22
+ * **Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()
23
+ * @deprecated Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()
24
+ */
25
+ enable(): Promise<void>;
26
+ /**
27
+ * Disable Bluetooth.
28
+ * Only available on **Android**.
29
+ * **Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()
30
+ * @deprecated Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()
31
+ */
32
+ disable(): Promise<void>;
33
+ /**
34
+ * Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.
35
+ * Not available on **web** (the callback will never be invoked).
36
+ * @param callback Callback function to use when the Bluetooth state changes.
37
+ */
38
+ startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;
39
+ /**
40
+ * Stop the enabled notifications registered with `startEnabledNotifications`.
41
+ */
42
+ stopEnabledNotifications(): Promise<void>;
43
+ /**
44
+ * Reports whether Location Services are enabled on this device.
45
+ * Only available on **Android**.
46
+ */
47
+ isLocationEnabled(): Promise<boolean>;
48
+ /**
49
+ * Open Location settings.
50
+ * Only available on **Android**.
51
+ */
52
+ openLocationSettings(): Promise<void>;
53
+ /**
54
+ * Open Bluetooth settings.
55
+ * Only available on **Android**.
56
+ */
57
+ openBluetoothSettings(): Promise<void>;
58
+ /**
59
+ * Open App settings.
60
+ * Not available on **web**.
61
+ * On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible
62
+ * to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings
63
+ * for the app to be able use it.
64
+ */
65
+ openAppSettings(): Promise<void>;
66
+ /**
67
+ * Set the strings that are displayed in the `requestDevice` dialog.
68
+ * @param displayStrings
69
+ */
70
+ setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;
71
+ /**
72
+ * 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.
73
+ * For an example, see [usage](#usage).
74
+ * @param options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)
75
+ */
76
+ requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;
77
+ /**
78
+ * 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.
79
+ * Scanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).
80
+ * **Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.
81
+ * @param options
82
+ * @param callback
83
+ */
84
+ requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;
85
+ /**
86
+ * Stop scanning for BLE devices. For an example, see [usage](#usage).
87
+ */
88
+ stopLEScan(): Promise<void>;
89
+ /**
90
+ * On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.
91
+ * Uses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and
92
+ * [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.
93
+ * On Android, you can directly connect to the device with the deviceId.
94
+ * @param deviceIds List of device IDs, e.g. saved from a previous app run.
95
+ */
96
+ getDevices(deviceIds: string[]): Promise<BleDevice[]>;
97
+ /**
98
+ * Get a list of currently bonded devices.
99
+ * Only available on **Android**.
100
+ * Uses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android
101
+ */
102
+ getBondedDevices(): Promise<BleDevice[]>;
103
+ /**
104
+ * Get a list of currently connected devices.
105
+ * Uses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,
106
+ * [getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android
107
+ * and [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.
108
+ * @param services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS.
109
+ */
110
+ getConnectedDevices(services: string[]): Promise<BleDevice[]>;
111
+ /**
112
+ * Connect to a peripheral BLE device. For an example, see [usage](#usage).
113
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
114
+ * @param onDisconnect Optional disconnect callback function that will be used when the device disconnects
115
+ * @param options Options for plugin call
116
+ */
117
+ connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;
118
+ /**
119
+ * Create a bond with a peripheral BLE device.
120
+ * Only available on **Android**. On iOS bonding is handled by the OS.
121
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
122
+ * @param options Options for plugin call
123
+ */
124
+ createBond(deviceId: string, options?: TimeoutOptions): Promise<void>;
125
+ /**
126
+ * Report whether a peripheral BLE device is bonded.
127
+ * Only available on **Android**. On iOS bonding is handled by the OS.
128
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
129
+ */
130
+ isBonded(deviceId: string): Promise<boolean>;
131
+ /**
132
+ * Disconnect from a peripheral BLE device. For an example, see [usage](#usage).
133
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
134
+ */
135
+ disconnect(deviceId: string): Promise<void>;
136
+ /**
137
+ * Get services, characteristics and descriptors of a device.
138
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
139
+ */
140
+ getServices(deviceId: string): Promise<BleService[]>;
141
+ /**
142
+ * Discover services, characteristics and descriptors of a device.
143
+ * You only need this method if your peripheral device changes its services and characteristics at runtime.
144
+ * If the discovery was successful, the remote services can be retrieved using the getServices function.
145
+ * Not available on **web**.
146
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
147
+ */
148
+ discoverServices(deviceId: string): Promise<void>;
149
+ /**
150
+ * Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.
151
+ * Not available on **web**.
152
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
153
+ */
154
+ getMtu(deviceId: string): Promise<number>;
155
+ /**
156
+ * Request a connection parameter update.
157
+ * Only available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)
158
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
159
+ * @param connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)
160
+ */
161
+ requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;
162
+ /**
163
+ * Read the RSSI value of a connected device.
164
+ * Not available on **web**.
165
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
166
+ */
167
+ readRssi(deviceId: string): Promise<number>;
168
+ /**
169
+ * Read the value of a characteristic. For an example, see [usage](#usage).
170
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
171
+ * @param service UUID of the service (see [UUID format](#uuid-format))
172
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
173
+ * @param options Options for plugin call
174
+ */
175
+ read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;
176
+ /**
177
+ * Write a value to a characteristic. For an example, see [usage](#usage).
178
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
179
+ * @param service UUID of the service (see [UUID format](#uuid-format))
180
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
181
+ * @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])
182
+ * @param options Options for plugin call
183
+ */
184
+ write(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
185
+ /**
186
+ * Write a value to a characteristic without waiting for a response.
187
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
188
+ * @param service UUID of the service (see [UUID format](#uuid-format))
189
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
190
+ * @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])
191
+ * @param options Options for plugin call
192
+ */
193
+ writeWithoutResponse(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
194
+ /**
195
+ * Read the value of a descriptor.
196
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
197
+ * @param service UUID of the service (see [UUID format](#uuid-format))
198
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
199
+ * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))
200
+ * @param options Options for plugin call
201
+ */
202
+ readDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, options?: TimeoutOptions): Promise<DataView>;
203
+ /**
204
+ * Write a value to a descriptor.
205
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
206
+ * @param service UUID of the service (see [UUID format](#uuid-format))
207
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
208
+ * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))
209
+ * @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])
210
+ * @param options Options for plugin call
211
+ */
212
+ writeDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, value: DataView, options?: TimeoutOptions): Promise<void>;
213
+ /**
214
+ * Start listening to changes of the value of a characteristic.
215
+ * Note that you should only start the notifications once per characteristic in your app and share the data and
216
+ * not call `startNotifications` in every component that needs the data.
217
+ * For an example, see [usage](#usage).
218
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
219
+ * @param service UUID of the service (see [UUID format](#uuid-format))
220
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
221
+ * @param callback Callback function to use when the value of the characteristic changes
222
+ * @param options Options for plugin call. Timeout not supported on **web**.
223
+ */
224
+ startNotifications(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void, options?: TimeoutOptions): Promise<void>;
225
+ /**
226
+ * Stop listening to the changes of the value of a characteristic. For an example, see [usage](#usage).
227
+ * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
228
+ * @param service UUID of the service (see [UUID format](#uuid-format))
229
+ * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))
230
+ */
231
+ stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;
232
+ }
233
+ declare class BleClientClass implements BleClientInterface {
234
+ private scanListener;
235
+ private eventListeners;
236
+ private queue;
237
+ enableQueue(): void;
238
+ disableQueue(): void;
239
+ initialize(options?: InitializeOptions): Promise<void>;
240
+ isEnabled(): Promise<boolean>;
241
+ requestEnable(): Promise<void>;
242
+ enable(): Promise<void>;
243
+ disable(): Promise<void>;
244
+ startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;
245
+ stopEnabledNotifications(): Promise<void>;
246
+ isLocationEnabled(): Promise<boolean>;
247
+ openLocationSettings(): Promise<void>;
248
+ openBluetoothSettings(): Promise<void>;
249
+ openAppSettings(): Promise<void>;
250
+ setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;
251
+ requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;
252
+ requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;
253
+ stopLEScan(): Promise<void>;
254
+ getDevices(deviceIds: string[]): Promise<BleDevice[]>;
255
+ getConnectedDevices(services: string[]): Promise<BleDevice[]>;
256
+ getBondedDevices(): Promise<BleDevice[]>;
257
+ connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;
258
+ createBond(deviceId: string, options?: TimeoutOptions): Promise<void>;
259
+ isBonded(deviceId: string): Promise<boolean>;
260
+ disconnect(deviceId: string): Promise<void>;
261
+ getServices(deviceId: string): Promise<BleService[]>;
262
+ discoverServices(deviceId: string): Promise<void>;
263
+ getMtu(deviceId: string): Promise<number>;
264
+ requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;
265
+ readRssi(deviceId: string): Promise<number>;
266
+ read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;
267
+ write(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
268
+ writeWithoutResponse(deviceId: string, service: string, characteristic: string, value: DataView, options?: TimeoutOptions): Promise<void>;
269
+ readDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, options?: TimeoutOptions): Promise<DataView>;
270
+ writeDescriptor(deviceId: string, service: string, characteristic: string, descriptor: string, value: DataView, options?: TimeoutOptions): Promise<void>;
271
+ startNotifications(deviceId: string, service: string, characteristic: string, callback: (value: DataView) => void, options?: TimeoutOptions): Promise<void>;
272
+ stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;
273
+ private validateRequestBleDeviceOptions;
274
+ private convertValue;
275
+ private convertObject;
276
+ }
277
+ export declare const BleClient: BleClientClass;
278
+ export {};