@react-native-ohos/react-native-ble-plx 3.2.1-rc.2 → 3.2.1
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/LICENSE +202 -202
- package/README.OpenSource +10 -10
- package/README.md +9 -9
- package/app.plugin.js +1 -1
- package/harmony/rn_bleplx/build-profile.json5 +7 -7
- package/harmony/rn_bleplx/hvigorfile.ts +1 -1
- package/harmony/rn_bleplx/index.ets +26 -26
- package/harmony/rn_bleplx/obfuscation-rules.txt +17 -17
- package/harmony/rn_bleplx/oh-package.json5 +13 -13
- package/harmony/rn_bleplx/src/main/cpp/BlePlxPackage.h +36 -36
- package/harmony/rn_bleplx/src/main/cpp/CMakeLists.txt +9 -9
- package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/BaseReactNativeBlePlxPackage.h +65 -65
- package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.cpp +59 -59
- package/harmony/rn_bleplx/src/main/cpp/generated/RNOH/generated/turbo_modules/BlePlx.h +16 -16
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ComponentDescriptors.h +22 -22
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.cpp +18 -18
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.h +19 -19
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.cpp +21 -21
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.h +20 -20
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.cpp +19 -19
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.h +25 -25
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.cpp +18 -18
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.h +22 -22
- package/harmony/rn_bleplx/src/main/ets/BleDevice.ts +98 -98
- package/harmony/rn_bleplx/src/main/ets/BleModule.ts +1219 -1219
- package/harmony/rn_bleplx/src/main/ets/BlePlxInterface.ts +26 -26
- package/harmony/rn_bleplx/src/main/ets/BlePlxModule.ts +246 -246
- package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ets +46 -46
- package/harmony/rn_bleplx/src/main/ets/Characteristic.ts +179 -179
- package/harmony/rn_bleplx/src/main/ets/CommonConstants.ts +29 -29
- package/harmony/rn_bleplx/src/main/ets/Descriptor.ts +143 -143
- package/harmony/rn_bleplx/src/main/ets/Service.ts +85 -85
- package/harmony/rn_bleplx/src/main/ets/common/BleError.ts +90 -90
- package/harmony/rn_bleplx/src/main/ets/common/BleErrorToJsObjectConverter.ts +62 -62
- package/harmony/rn_bleplx/src/main/ets/common/BleEvent.ts +32 -32
- package/harmony/rn_bleplx/src/main/ets/common/BleUtils.ts +86 -86
- package/harmony/rn_bleplx/src/main/ets/common/IdGenerator.ts +49 -49
- package/harmony/rn_bleplx/src/main/ets/common/IdGeneratorKey.ts +70 -70
- package/harmony/rn_bleplx/src/main/ets/common/InstanceIdGenerator.ts +36 -36
- package/harmony/rn_bleplx/src/main/ets/common/Logger.ts +64 -64
- package/harmony/rn_bleplx/src/main/ets/common/PermissionHandler.ts +98 -98
- package/harmony/rn_bleplx/src/main/ets/common/ServiceFactory.ts +37 -37
- package/harmony/rn_bleplx/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/rn_bleplx/src/main/ets/generated/index.ets +5 -5
- package/harmony/rn_bleplx/src/main/ets/generated/ts.ts +6 -6
- package/harmony/rn_bleplx/src/main/ets/generated/turboModules/BlePlx.ts +100 -100
- package/harmony/rn_bleplx/src/main/ets/generated/turboModules/ts.ts +5 -5
- package/harmony/rn_bleplx/src/main/module.json5 +6 -6
- package/harmony/rn_bleplx/ts.ets +25 -25
- package/harmony/rn_bleplx.har +0 -0
- package/package.json +185 -185
- package/src/BleError.js +555 -555
- package/src/BleManager.js +1287 -1287
- package/src/BleModule.js +847 -847
- package/src/Characteristic.js +166 -166
- package/src/Descriptor.js +82 -82
- package/src/Device.js +370 -370
- package/src/NativeBlePlx.ts +121 -121
- package/src/Service.js +188 -188
- package/src/TypeDefinition.js +360 -360
- package/src/Utils.js +26 -26
- package/src/index.d.ts +2113 -2113
- package/src/index.js +20 -20
package/src/BleModule.js
CHANGED
|
@@ -1,847 +1,847 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { NativeModules, NativeEventEmitter } from 'react-native'
|
|
5
|
-
import { State, LogLevel, ConnectionPriority } from './TypeDefinition'
|
|
6
|
-
import type {
|
|
7
|
-
DeviceId,
|
|
8
|
-
Identifier,
|
|
9
|
-
UUID,
|
|
10
|
-
TransactionId,
|
|
11
|
-
Base64,
|
|
12
|
-
ScanOptions,
|
|
13
|
-
ConnectionOptions
|
|
14
|
-
} from './TypeDefinition'
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Native device object passed from BleModule.
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
export interface NativeDevice {
|
|
21
|
-
/**
|
|
22
|
-
* Device identifier: MAC address on Android and UUID on iOS.
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
id: DeviceId;
|
|
26
|
-
/**
|
|
27
|
-
* Device name if present
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
name: ?string;
|
|
31
|
-
/**
|
|
32
|
-
* Current Received Signal Strength Indication of device
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
rssi: ?number;
|
|
36
|
-
/**
|
|
37
|
-
* Current Maximum Transmission Unit for this device. When device is not connected
|
|
38
|
-
* default value of 23 is used.
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
|
-
mtu: number;
|
|
42
|
-
|
|
43
|
-
// Advertisement
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Device's custom manufacturer data. Its format is defined by manufacturer.
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
49
|
-
manufacturerData: ?Base64;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Raw device scan data. When you have specific advertiser data,
|
|
53
|
-
* you can implement your own processing.
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
rawScanRecord: Base64;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Map od service UUIDs with associated data.
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
serviceData: ?{ [uuid: UUID]: Base64 };
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* List of available services visible during scanning.
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
serviceUUIDs: ?Array<UUID>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* User friendly name of device.
|
|
72
|
-
* @private
|
|
73
|
-
*/
|
|
74
|
-
localName: ?string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Transmission power level of device.
|
|
78
|
-
* @private
|
|
79
|
-
*/
|
|
80
|
-
txPowerLevel: ?number;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* List of solicited service UUIDs.
|
|
84
|
-
* @private
|
|
85
|
-
*/
|
|
86
|
-
solicitedServiceUUIDs: ?Array<UUID>;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Is device connectable.
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
isConnectable: ?boolean;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* List of overflow service UUIDs.
|
|
96
|
-
* @private
|
|
97
|
-
*/
|
|
98
|
-
overflowServiceUUIDs: ?Array<UUID>;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Native service object passed from BleModule.
|
|
103
|
-
* @private
|
|
104
|
-
*/
|
|
105
|
-
export interface NativeService {
|
|
106
|
-
/**
|
|
107
|
-
* Service unique identifier
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
id: Identifier;
|
|
111
|
-
/**
|
|
112
|
-
* Service UUID
|
|
113
|
-
* @private
|
|
114
|
-
*/
|
|
115
|
-
uuid: UUID;
|
|
116
|
-
/**
|
|
117
|
-
* Device's ID to which service belongs
|
|
118
|
-
* @private
|
|
119
|
-
*/
|
|
120
|
-
deviceID: DeviceId;
|
|
121
|
-
/**
|
|
122
|
-
* Value indicating whether the type of service is primary or secondary.
|
|
123
|
-
* @private
|
|
124
|
-
*/
|
|
125
|
-
isPrimary: boolean;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Native characteristic object passed from BleModule.
|
|
130
|
-
* @private
|
|
131
|
-
*/
|
|
132
|
-
export interface NativeCharacteristic {
|
|
133
|
-
/**
|
|
134
|
-
* Characteristic unique identifier
|
|
135
|
-
* @private
|
|
136
|
-
*/
|
|
137
|
-
id: Identifier;
|
|
138
|
-
/**
|
|
139
|
-
* Characteristic UUID
|
|
140
|
-
* @private
|
|
141
|
-
*/
|
|
142
|
-
uuid: UUID;
|
|
143
|
-
/**
|
|
144
|
-
* Service's ID to which characteristic belongs
|
|
145
|
-
* @private
|
|
146
|
-
*/
|
|
147
|
-
serviceID: Identifier;
|
|
148
|
-
/**
|
|
149
|
-
* Service's UUID to which characteristic belongs
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
serviceUUID: UUID;
|
|
153
|
-
/**
|
|
154
|
-
* Device's ID to which characteristic belongs
|
|
155
|
-
* @private
|
|
156
|
-
*/
|
|
157
|
-
deviceID: DeviceId;
|
|
158
|
-
/**
|
|
159
|
-
* True if characteristic can be read
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
isReadable: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* True if characteristic can be written with response
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
|
-
isWritableWithResponse: boolean;
|
|
168
|
-
/**
|
|
169
|
-
* True if characteristic can be written without response
|
|
170
|
-
* @private
|
|
171
|
-
*/
|
|
172
|
-
isWritableWithoutResponse: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* True if characteristic can monitor value changes.
|
|
175
|
-
* @private
|
|
176
|
-
*/
|
|
177
|
-
isNotifiable: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* True if characteristic is monitoring value changes without ACK.
|
|
180
|
-
* @private
|
|
181
|
-
*/
|
|
182
|
-
isNotifying: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* True if characteristic is monitoring value changes with ACK.
|
|
185
|
-
* @private
|
|
186
|
-
*/
|
|
187
|
-
isIndicatable: boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Characteristic value if present
|
|
190
|
-
* @private
|
|
191
|
-
*/
|
|
192
|
-
value: ?Base64;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Native descriptor object passed from BleModule.
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
export interface NativeDescriptor {
|
|
200
|
-
/**
|
|
201
|
-
* Descriptor unique identifier
|
|
202
|
-
* @private
|
|
203
|
-
*/
|
|
204
|
-
id: Identifier;
|
|
205
|
-
/**
|
|
206
|
-
* Descriptor UUID
|
|
207
|
-
* @private
|
|
208
|
-
*/
|
|
209
|
-
uuid: UUID;
|
|
210
|
-
/**
|
|
211
|
-
* Characteristic's ID to which descriptor belongs
|
|
212
|
-
* @private
|
|
213
|
-
*/
|
|
214
|
-
characteristicID: Identifier;
|
|
215
|
-
/**
|
|
216
|
-
* Characteristic's UUID to which descriptor belongs
|
|
217
|
-
* @private
|
|
218
|
-
*/
|
|
219
|
-
characteristicUUID: UUID;
|
|
220
|
-
/**
|
|
221
|
-
* Service's ID to which descriptor belongs
|
|
222
|
-
* @private
|
|
223
|
-
*/
|
|
224
|
-
serviceID: Identifier;
|
|
225
|
-
/**
|
|
226
|
-
* Service's UUID to which descriptor belongs
|
|
227
|
-
* @private
|
|
228
|
-
*/
|
|
229
|
-
serviceUUID: UUID;
|
|
230
|
-
/**
|
|
231
|
-
* Device's ID to which descriptor belongs
|
|
232
|
-
* @private
|
|
233
|
-
*/
|
|
234
|
-
deviceID: DeviceId;
|
|
235
|
-
/**
|
|
236
|
-
* Descriptor value if present
|
|
237
|
-
* @private
|
|
238
|
-
*/
|
|
239
|
-
value: ?Base64;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Object representing information about restored BLE state after application relaunch.
|
|
244
|
-
* @private
|
|
245
|
-
*/
|
|
246
|
-
export interface NativeBleRestoredState {
|
|
247
|
-
/**
|
|
248
|
-
* List of connected devices after state restoration.
|
|
249
|
-
* @type {Array<NativeDevice>}
|
|
250
|
-
* @instance
|
|
251
|
-
* @memberof NativeBleRestoredState
|
|
252
|
-
* @private
|
|
253
|
-
*/
|
|
254
|
-
connectedPeripherals: Array<NativeDevice>;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Native BLE Module interface
|
|
259
|
-
* @private
|
|
260
|
-
*/
|
|
261
|
-
export interface BleModuleInterface {
|
|
262
|
-
// NativeModule methods
|
|
263
|
-
|
|
264
|
-
addListener(string): void;
|
|
265
|
-
removeListeners(number): void;
|
|
266
|
-
|
|
267
|
-
// Lifecycle
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Creates new native module internally. Only one module
|
|
271
|
-
* is allowed to be instantiated.
|
|
272
|
-
* @param {?string} restoreIdentifierKey Optional unique Id used for state restoration of BLE manager.
|
|
273
|
-
* @private
|
|
274
|
-
*/
|
|
275
|
-
createClient(restoreIdentifierKey: ?string): void;
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Destroys previously instantiated module. This function is
|
|
279
|
-
* only safe when previously BleModule was created.
|
|
280
|
-
* @returns {Promise<void>} Promise may return an error when the function cannot be called.
|
|
281
|
-
* @private
|
|
282
|
-
*/
|
|
283
|
-
destroyClient(): Promise<void>;
|
|
284
|
-
|
|
285
|
-
// Monitoring state
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Enable Bluetooth. This function blocks until BLE is in PoweredOn state. [Android only]
|
|
289
|
-
*
|
|
290
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
291
|
-
* @returns {Promise<void>} Promise completes when state transition was successful.
|
|
292
|
-
* @private
|
|
293
|
-
*/
|
|
294
|
-
enable(transactionId: TransactionId): Promise<void>;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Disable Bluetooth. This function blocks until BLE is in PoweredOff state. [Android only]
|
|
298
|
-
*
|
|
299
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
300
|
-
* @returns {Promise<void>} Promise completes when state transition was successful.
|
|
301
|
-
* @private
|
|
302
|
-
*/
|
|
303
|
-
disable(transactionId: TransactionId): Promise<void>;
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Current state of BLE device.
|
|
307
|
-
*
|
|
308
|
-
* @returns {Promise<State>} Current state of BLE device.
|
|
309
|
-
* @private
|
|
310
|
-
*/
|
|
311
|
-
state(): Promise<$Keys<typeof State>>;
|
|
312
|
-
|
|
313
|
-
// Scanning
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Starts device scan.
|
|
317
|
-
*
|
|
318
|
-
* @param {?Array<UUID>} filteredUUIDs List of UUIDs for services which needs to be present to detect device during
|
|
319
|
-
* scanning.
|
|
320
|
-
* @param {?ScanOptions} options Platform dependent options
|
|
321
|
-
* @returns {Promise<void>} the promise may be rejected if the operation is impossible to perform.
|
|
322
|
-
* @private
|
|
323
|
-
*/
|
|
324
|
-
startDeviceScan(filteredUUIDs: ?Array<UUID>, options: ?ScanOptions): Promise<void>;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Stops device scan.
|
|
328
|
-
* @private
|
|
329
|
-
* @returns {Promise<void>} the promise may be rejected if the operation is impossible to perform.
|
|
330
|
-
*/
|
|
331
|
-
stopDeviceScan(): Promise<void>;
|
|
332
|
-
|
|
333
|
-
// Device operations
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Request a connection parameter update. This functions may update connection parameters on Android API level 21 or
|
|
337
|
-
* above.
|
|
338
|
-
*
|
|
339
|
-
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
340
|
-
* @param {ConnectionPriority} connectionPriority: Connection priority.
|
|
341
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation.
|
|
342
|
-
* @returns {Promise<NativeDevice>} Connected device.
|
|
343
|
-
* @private
|
|
344
|
-
*/
|
|
345
|
-
requestConnectionPriorityForDevice(
|
|
346
|
-
deviceIdentifier: DeviceId,
|
|
347
|
-
connectionPriority: $Values<typeof ConnectionPriority>,
|
|
348
|
-
transactionId: TransactionId
|
|
349
|
-
): Promise<NativeDevice>;
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Reads RSSI for connected device.
|
|
353
|
-
*
|
|
354
|
-
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
355
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
356
|
-
* @returns {Promise<NativeDevice>} Connected device with updated RSSI value.
|
|
357
|
-
* @private
|
|
358
|
-
*/
|
|
359
|
-
readRSSIForDevice(deviceIdentifier: DeviceId, transactionId: TransactionId): Promise<NativeDevice>;
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Request new MTU value for this device. This function currently is not doing anything
|
|
363
|
-
* on iOS platform as MTU exchange is done automatically. Since Android 14,
|
|
364
|
-
* mtu management has been changed, more information can be found at the link:
|
|
365
|
-
* https://developer.android.com/about/versions/14/behavior-changes-all#mtu-set-to-517
|
|
366
|
-
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
367
|
-
* @param {number} mtu New MTU to negotiate.
|
|
368
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
369
|
-
* @returns {Promise<NativeDevice>} Device with updated MTU size. Default value is 23 (517 since Android 14)..
|
|
370
|
-
* @private
|
|
371
|
-
*/
|
|
372
|
-
requestMTUForDevice(deviceIdentifier: DeviceId, mtu: number, transactionId: TransactionId): Promise<NativeDevice>;
|
|
373
|
-
|
|
374
|
-
// Device management
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Returns a list of known peripherals by their identifiers.
|
|
378
|
-
* @param {Array<DeviceId>} deviceIdentifiers List of device identifiers
|
|
379
|
-
* @returns {Promise<Array<NativeDevice>>} List of known devices by their identifiers.
|
|
380
|
-
* @private
|
|
381
|
-
*/
|
|
382
|
-
devices(deviceIdentifiers: Array<DeviceId>): Promise<Array<NativeDevice>>;
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Returns a list of the peripherals (containing any of the specified services) currently connected to the system
|
|
386
|
-
* which have discovered services. Returned devices **may not be connected** to your application.
|
|
387
|
-
* @param {Array<UUID>} serviceUUIDs List of service UUIDs. Device must contain at least one of them to be listed.
|
|
388
|
-
* @returns {Promise<Array<NativeDevice>>} List of known devices with discovered services as stated in the parameter.
|
|
389
|
-
* @private
|
|
390
|
-
*/
|
|
391
|
-
connectedDevices(serviceUUIDs: Array<UUID>): Promise<Array<NativeDevice>>;
|
|
392
|
-
|
|
393
|
-
// Connection management
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Connect to specified device.
|
|
397
|
-
*
|
|
398
|
-
* @param {DeviceId} deviceIdentifier Device identifier to connect to.
|
|
399
|
-
* @param {?ConnectionOptions} options Connection options.
|
|
400
|
-
* @returns {Promise<NativeDevice>} Connected device.
|
|
401
|
-
* @private
|
|
402
|
-
*/
|
|
403
|
-
connectToDevice(deviceIdentifier: DeviceId, options: ?ConnectionOptions): Promise<NativeDevice>;
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Cancels pending device connection.
|
|
407
|
-
*
|
|
408
|
-
* @param {DeviceId} deviceIdentifier Device identifier which is already connected.
|
|
409
|
-
* @returns {Promise<NativeDevice>} Disconnected device.
|
|
410
|
-
* @private
|
|
411
|
-
*/
|
|
412
|
-
cancelDeviceConnection(deviceIdentifier: DeviceId): Promise<NativeDevice>;
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Checks if specified device is connected.
|
|
416
|
-
*
|
|
417
|
-
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
418
|
-
* @returns {Promise<boolean>} True if specified device is connected.
|
|
419
|
-
* @private
|
|
420
|
-
*/
|
|
421
|
-
isDeviceConnected(deviceIdentifier: DeviceId): Promise<boolean>;
|
|
422
|
-
|
|
423
|
-
// Discovery
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Discovers all services, characteristics and descriptors for specified device.
|
|
427
|
-
*
|
|
428
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
429
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
430
|
-
* @returns {Promise<NativeDevice>} Device which has discovered characteristics and services.
|
|
431
|
-
* @private
|
|
432
|
-
*/
|
|
433
|
-
discoverAllServicesAndCharacteristicsForDevice(
|
|
434
|
-
deviceIdentifier: DeviceId,
|
|
435
|
-
transactionId: TransactionId
|
|
436
|
-
): Promise<NativeDevice>;
|
|
437
|
-
|
|
438
|
-
// Service and characteristic getters
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* List of discovered services for specified device.
|
|
442
|
-
*
|
|
443
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
444
|
-
* @returns {Promise<Array<NativeService>>} List of services available in device.
|
|
445
|
-
* @private
|
|
446
|
-
*/
|
|
447
|
-
servicesForDevice(deviceIdentifier: DeviceId): Promise<Array<NativeService>>;
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* List of discovered characteristics for specified service.
|
|
451
|
-
*
|
|
452
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
453
|
-
* @param {UUID} serviceUUID Service UUID which contains characteristics.
|
|
454
|
-
* @returns {Promise<Array<NativeCharacteristic>>} List of characteristics available in service.
|
|
455
|
-
* @private
|
|
456
|
-
*/
|
|
457
|
-
characteristicsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID): Promise<Array<NativeCharacteristic>>;
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* List of discovered characteristics for specified service.
|
|
461
|
-
*
|
|
462
|
-
* @param {Identifier} serviceIdentifier Service ID which contains characteristics.
|
|
463
|
-
* @returns {Promise<Array<NativeCharacteristic>>} List of characteristics available in service.
|
|
464
|
-
* @private
|
|
465
|
-
*/
|
|
466
|
-
characteristicsForService(serviceIdentifier: Identifier): Promise<Array<NativeCharacteristic>>;
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* List of discovered descriptors for specified characteristic.
|
|
470
|
-
*
|
|
471
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
472
|
-
* @param {UUID} serviceUUID Service UUID which contains descriptors.
|
|
473
|
-
* @param {UUID} characteristicUUID Characteristic UUID which contains descriptors.
|
|
474
|
-
* @returns {Promise<Array<NativeDescriptor>>} List of descriptors available in characteristic.
|
|
475
|
-
* @private
|
|
476
|
-
*/
|
|
477
|
-
descriptorsForDevice(
|
|
478
|
-
deviceIdentifier: DeviceId,
|
|
479
|
-
serviceUUID: UUID,
|
|
480
|
-
characteristicUUID: UUID
|
|
481
|
-
): Promise<Array<NativeDescriptor>>;
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* List of discovered descriptors for specified characteristic.
|
|
485
|
-
*
|
|
486
|
-
* @param {Identifier} serviceIdentifier Service identifier which contains descriptors.
|
|
487
|
-
* @param {UUID} characteristicUUID Characteristic UUID which contains descriptors.
|
|
488
|
-
* @returns {Promise<Array<NativeDescriptor>>} List of descriptors available in characteristic.
|
|
489
|
-
* @private
|
|
490
|
-
*/
|
|
491
|
-
descriptorsForService(serviceIdentifier: Identifier, characteristicUUID: UUID): Promise<Array<NativeDescriptor>>;
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* List of discovered descriptors for specified characteristic.
|
|
495
|
-
*
|
|
496
|
-
* @param {Identifier} characteristicIdentifier Characteristic identifier which contains descriptors.
|
|
497
|
-
* @returns {Promise<Array<NativeDescriptor>>} List of descriptors available in characteristic.
|
|
498
|
-
* @private
|
|
499
|
-
*/
|
|
500
|
-
descriptorsForCharacteristic(characteristicIdentifier: Identifier): Promise<Array<NativeDescriptor>>;
|
|
501
|
-
|
|
502
|
-
// Characteristics operations
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Read characteristic's value.
|
|
506
|
-
*
|
|
507
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
508
|
-
* @param {UUID} serviceUUID Service UUID
|
|
509
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
510
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
511
|
-
* @returns {Promise<NativeCharacteristic>} Characteristic for which value was read
|
|
512
|
-
* @private
|
|
513
|
-
*/
|
|
514
|
-
readCharacteristicForDevice(
|
|
515
|
-
deviceIdentifier: DeviceId,
|
|
516
|
-
serviceUUID: UUID,
|
|
517
|
-
characteristicUUID: UUID,
|
|
518
|
-
transactionId: TransactionId
|
|
519
|
-
): Promise<NativeCharacteristic>;
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Read characteristic's value.
|
|
523
|
-
*
|
|
524
|
-
* @param {Identifier} serviceIdentifier Service ID
|
|
525
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
526
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
527
|
-
* @returns {Promise<NativeCharacteristic>} Characteristic for which value was read
|
|
528
|
-
* @private
|
|
529
|
-
*/
|
|
530
|
-
readCharacteristicForService(
|
|
531
|
-
serviceIdentifier: Identifier,
|
|
532
|
-
characteristicUUID: UUID,
|
|
533
|
-
transactionId: TransactionId
|
|
534
|
-
): Promise<NativeCharacteristic>;
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* Read characteristic's value.
|
|
538
|
-
*
|
|
539
|
-
* @param {Identifier} characteristicIdentifer Characteristic ID
|
|
540
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
541
|
-
* @returns {Promise<NativeCharacteristic>} Characteristic for which value was read
|
|
542
|
-
* @private
|
|
543
|
-
*/
|
|
544
|
-
readCharacteristic(characteristicIdentifer: Identifier, transactionId: TransactionId): Promise<NativeCharacteristic>;
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Write value to characteristic.
|
|
548
|
-
*
|
|
549
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
550
|
-
* @param {UUID} serviceUUID Service UUID
|
|
551
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
552
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
553
|
-
* @param {boolean} withResponse True if write should be with response
|
|
554
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
555
|
-
* @returns {Promise<NativeCharacteristic>} Characteristic which saved passed value
|
|
556
|
-
* @private
|
|
557
|
-
*/
|
|
558
|
-
writeCharacteristicForDevice(
|
|
559
|
-
deviceIdentifier: DeviceId,
|
|
560
|
-
serviceUUID: UUID,
|
|
561
|
-
characteristicUUID: UUID,
|
|
562
|
-
valueBase64: Base64,
|
|
563
|
-
withResponse: boolean,
|
|
564
|
-
transactionId: TransactionId
|
|
565
|
-
): Promise<NativeCharacteristic>;
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Write value to characteristic.
|
|
569
|
-
*
|
|
570
|
-
* @param {Identifier} serviceIdentifier Service ID
|
|
571
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
572
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
573
|
-
* @param {boolean} withResponse True if write should be with response
|
|
574
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
575
|
-
* @returns {Promise<NativeCharacteristic>} Characteristic which saved passed value
|
|
576
|
-
* @private
|
|
577
|
-
*/
|
|
578
|
-
writeCharacteristicForService(
|
|
579
|
-
serviceIdentifier: Identifier,
|
|
580
|
-
characteristicUUID: UUID,
|
|
581
|
-
valueBase64: Base64,
|
|
582
|
-
withResponse: boolean,
|
|
583
|
-
transactionId: TransactionId
|
|
584
|
-
): Promise<NativeCharacteristic>;
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Write value to characteristic.
|
|
588
|
-
*
|
|
589
|
-
* @param {Identifier} characteristicIdentifier Characteristic ID
|
|
590
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
591
|
-
* @param {boolean} withResponse True if write should be with response
|
|
592
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
593
|
-
* @returns {Promise<NativeCharacteristic>} Characteristic which saved passed value
|
|
594
|
-
* @private
|
|
595
|
-
*/
|
|
596
|
-
writeCharacteristic(
|
|
597
|
-
characteristicIdentifier: Identifier,
|
|
598
|
-
valueBase64: Base64,
|
|
599
|
-
withResponse: boolean,
|
|
600
|
-
transactionId: TransactionId
|
|
601
|
-
): Promise<NativeCharacteristic>;
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* Setup monitoring of characteristic value.
|
|
605
|
-
*
|
|
606
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
607
|
-
* @param {UUID} serviceUUID Service UUID
|
|
608
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
609
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
610
|
-
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
611
|
-
* @private
|
|
612
|
-
*/
|
|
613
|
-
monitorCharacteristicForDevice(
|
|
614
|
-
deviceIdentifier: DeviceId,
|
|
615
|
-
serviceUUID: UUID,
|
|
616
|
-
characteristicUUID: UUID,
|
|
617
|
-
transactionId: TransactionId
|
|
618
|
-
): Promise<void>;
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Setup monitoring of characteristic value.
|
|
622
|
-
*
|
|
623
|
-
* @param {Identifier} serviceIdentifier Service ID
|
|
624
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
625
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
626
|
-
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
627
|
-
* @private
|
|
628
|
-
*/
|
|
629
|
-
monitorCharacteristicForService(
|
|
630
|
-
serviceIdentifier: Identifier,
|
|
631
|
-
characteristicUUID: UUID,
|
|
632
|
-
transactionId: TransactionId
|
|
633
|
-
): Promise<void>;
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* Setup monitoring of characteristic value.
|
|
637
|
-
*
|
|
638
|
-
* @param {Identifier} characteristicIdentifier Characteristic ID
|
|
639
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
640
|
-
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
641
|
-
* @private
|
|
642
|
-
*/
|
|
643
|
-
monitorCharacteristic(characteristicIdentifier: Identifier, transactionId: TransactionId): Promise<void>;
|
|
644
|
-
|
|
645
|
-
// Descriptor operations
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Read descriptor's value.
|
|
649
|
-
*
|
|
650
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
651
|
-
* @param {UUID} serviceUUID Service UUID
|
|
652
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
653
|
-
* @param {UUID} descriptorUUID Descriptor UUID
|
|
654
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
655
|
-
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
656
|
-
* @private
|
|
657
|
-
*/
|
|
658
|
-
readDescriptorForDevice(
|
|
659
|
-
deviceIdentifier: DeviceId,
|
|
660
|
-
serviceUUID: UUID,
|
|
661
|
-
characteristicUUID: UUID,
|
|
662
|
-
descriptorUUID: UUID,
|
|
663
|
-
transactionId: TransactionId
|
|
664
|
-
): Promise<NativeDescriptor>;
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* Read descriptor's value.
|
|
668
|
-
*
|
|
669
|
-
* @param {Identifier} serviceIdentifier Service identifier
|
|
670
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
671
|
-
* @param {UUID} descriptorUUID Descriptor UUID
|
|
672
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
673
|
-
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
674
|
-
* @private
|
|
675
|
-
*/
|
|
676
|
-
readDescriptorForService(
|
|
677
|
-
serviceIdentifier: Identifier,
|
|
678
|
-
characteristicUUID: UUID,
|
|
679
|
-
descriptorUUID: UUID,
|
|
680
|
-
transactionId: TransactionId
|
|
681
|
-
): Promise<NativeDescriptor>;
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* Read descriptor's value.
|
|
685
|
-
*
|
|
686
|
-
* @param {Identifier} characteristicIdentifier Characteristic identifier
|
|
687
|
-
* @param {UUID} descriptorUUID Descriptor UUID
|
|
688
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
689
|
-
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
690
|
-
* @private
|
|
691
|
-
*/
|
|
692
|
-
readDescriptorForCharacteristic(
|
|
693
|
-
characteristicIdentifier: Identifier,
|
|
694
|
-
descriptorUUID: UUID,
|
|
695
|
-
transactionId: TransactionId
|
|
696
|
-
): Promise<NativeDescriptor>;
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* Read descriptor's value.
|
|
700
|
-
*
|
|
701
|
-
* @param {Identifier} descriptorIdentifier Descriptor identifier
|
|
702
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
703
|
-
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
704
|
-
* @private
|
|
705
|
-
*/
|
|
706
|
-
readDescriptor(descriptorIdentifier: Identifier, transactionId: TransactionId): Promise<NativeDescriptor>;
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Write value to descriptor.
|
|
710
|
-
*
|
|
711
|
-
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
712
|
-
* @param {UUID} serviceUUID Service UUID
|
|
713
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
714
|
-
* @param {UUID} descriptorUUID Descriptor UUID
|
|
715
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
716
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
717
|
-
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
718
|
-
* @private
|
|
719
|
-
*/
|
|
720
|
-
writeDescriptorForDevice(
|
|
721
|
-
deviceIdentifier: DeviceId,
|
|
722
|
-
serviceUUID: UUID,
|
|
723
|
-
characteristicUUID: UUID,
|
|
724
|
-
descriptorUUID: UUID,
|
|
725
|
-
valueBase64: Base64,
|
|
726
|
-
transactionId: TransactionId
|
|
727
|
-
): Promise<NativeDescriptor>;
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Write value to descriptor.
|
|
731
|
-
*
|
|
732
|
-
* @param {Identifier} serviceIdentifier Service identifier
|
|
733
|
-
* @param {UUID} characteristicUUID Characteristic UUID
|
|
734
|
-
* @param {UUID} descriptorUUID Descriptor UUID
|
|
735
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
736
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
737
|
-
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
738
|
-
* @private
|
|
739
|
-
*/
|
|
740
|
-
writeDescriptorForService(
|
|
741
|
-
serviceIdentifier: Identifier,
|
|
742
|
-
characteristicUUID: UUID,
|
|
743
|
-
descriptorUUID: UUID,
|
|
744
|
-
valueBase64: Base64,
|
|
745
|
-
transactionId: TransactionId
|
|
746
|
-
): Promise<NativeDescriptor>;
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Write value to descriptor.
|
|
750
|
-
*
|
|
751
|
-
* @param {Identifier} characteristicIdentifier Characteristic identifier
|
|
752
|
-
* @param {UUID} descriptorUUID Descriptor UUID
|
|
753
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
754
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
755
|
-
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
756
|
-
* @private
|
|
757
|
-
*/
|
|
758
|
-
writeDescriptorForCharacteristic(
|
|
759
|
-
characteristicIdentifier: Identifier,
|
|
760
|
-
descriptorUUID: UUID,
|
|
761
|
-
valueBase64: Base64,
|
|
762
|
-
transactionId: TransactionId
|
|
763
|
-
): Promise<NativeDescriptor>;
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Write value to descriptor.
|
|
767
|
-
*
|
|
768
|
-
* @param {Identifier} descriptorIdentifier Descriptor identifier
|
|
769
|
-
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
770
|
-
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
771
|
-
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
772
|
-
* @private
|
|
773
|
-
*/
|
|
774
|
-
writeDescriptor(
|
|
775
|
-
descriptorIdentifier: Identifier,
|
|
776
|
-
valueBase64: Base64,
|
|
777
|
-
transactionId: TransactionId
|
|
778
|
-
): Promise<NativeDescriptor>;
|
|
779
|
-
|
|
780
|
-
// Other APIs
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Cancels specified transaction
|
|
784
|
-
*
|
|
785
|
-
* @param {TransactionId} transactionId Transaction handle for operation to be cancelled
|
|
786
|
-
* @returns {Promise<void>}
|
|
787
|
-
* @private
|
|
788
|
-
*/
|
|
789
|
-
cancelTransaction(transactionId: TransactionId): Promise<void>;
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* Sets new log level for native module's logging mechanism.
|
|
793
|
-
* @param {LogLevel} logLevel New log level to be set.
|
|
794
|
-
* @returns {Promise<LogLevel>} Current log level.
|
|
795
|
-
* @private
|
|
796
|
-
*/
|
|
797
|
-
setLogLevel(logLevel: $Keys<typeof LogLevel>): Promise<$Keys<typeof LogLevel> | void>;
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* Get current log level for native module's logging mechanism.
|
|
801
|
-
* @returns {Promise<LogLevel>} Current log level.
|
|
802
|
-
* @private
|
|
803
|
-
*/
|
|
804
|
-
logLevel(): Promise<$Keys<typeof LogLevel>>;
|
|
805
|
-
|
|
806
|
-
// Events
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
* New scanned event arrived as [?Error, ?NativeDevice] object.
|
|
810
|
-
* @private
|
|
811
|
-
*/
|
|
812
|
-
ScanEvent: string;
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Characteristic value update broadcasted due to registered notification as
|
|
816
|
-
* [?Error, ?NativeCharacteristic, ?TransactionId].
|
|
817
|
-
* @private
|
|
818
|
-
*/
|
|
819
|
-
ReadEvent: string;
|
|
820
|
-
|
|
821
|
-
/**
|
|
822
|
-
* BLE Manager changed its state as $Keys<typeof State>
|
|
823
|
-
* @private
|
|
824
|
-
*/
|
|
825
|
-
StateChangeEvent: string;
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* BLE Manager restored its internal state
|
|
829
|
-
* @private
|
|
830
|
-
*/
|
|
831
|
-
RestoreStateEvent: string;
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Device disconnected as [Error?, NativeDevice]
|
|
835
|
-
* @private
|
|
836
|
-
*/
|
|
837
|
-
DisconnectionEvent: string;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
/**
|
|
841
|
-
* Native module provider
|
|
842
|
-
*
|
|
843
|
-
* @private
|
|
844
|
-
*/
|
|
845
|
-
export const BleModule: BleModuleInterface = NativeModules.BlePlx
|
|
846
|
-
|
|
847
|
-
export const EventEmitter = NativeEventEmitter
|
|
1
|
+
// @flow
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { NativeModules, NativeEventEmitter } from 'react-native'
|
|
5
|
+
import { State, LogLevel, ConnectionPriority } from './TypeDefinition'
|
|
6
|
+
import type {
|
|
7
|
+
DeviceId,
|
|
8
|
+
Identifier,
|
|
9
|
+
UUID,
|
|
10
|
+
TransactionId,
|
|
11
|
+
Base64,
|
|
12
|
+
ScanOptions,
|
|
13
|
+
ConnectionOptions
|
|
14
|
+
} from './TypeDefinition'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Native device object passed from BleModule.
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
export interface NativeDevice {
|
|
21
|
+
/**
|
|
22
|
+
* Device identifier: MAC address on Android and UUID on iOS.
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
id: DeviceId;
|
|
26
|
+
/**
|
|
27
|
+
* Device name if present
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
name: ?string;
|
|
31
|
+
/**
|
|
32
|
+
* Current Received Signal Strength Indication of device
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
rssi: ?number;
|
|
36
|
+
/**
|
|
37
|
+
* Current Maximum Transmission Unit for this device. When device is not connected
|
|
38
|
+
* default value of 23 is used.
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
mtu: number;
|
|
42
|
+
|
|
43
|
+
// Advertisement
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Device's custom manufacturer data. Its format is defined by manufacturer.
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
manufacturerData: ?Base64;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Raw device scan data. When you have specific advertiser data,
|
|
53
|
+
* you can implement your own processing.
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
rawScanRecord: Base64;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Map od service UUIDs with associated data.
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
serviceData: ?{ [uuid: UUID]: Base64 };
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* List of available services visible during scanning.
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
serviceUUIDs: ?Array<UUID>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* User friendly name of device.
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
localName: ?string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Transmission power level of device.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
txPowerLevel: ?number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* List of solicited service UUIDs.
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
solicitedServiceUUIDs: ?Array<UUID>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Is device connectable.
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
isConnectable: ?boolean;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* List of overflow service UUIDs.
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
overflowServiceUUIDs: ?Array<UUID>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Native service object passed from BleModule.
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
export interface NativeService {
|
|
106
|
+
/**
|
|
107
|
+
* Service unique identifier
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
id: Identifier;
|
|
111
|
+
/**
|
|
112
|
+
* Service UUID
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
115
|
+
uuid: UUID;
|
|
116
|
+
/**
|
|
117
|
+
* Device's ID to which service belongs
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
deviceID: DeviceId;
|
|
121
|
+
/**
|
|
122
|
+
* Value indicating whether the type of service is primary or secondary.
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
isPrimary: boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Native characteristic object passed from BleModule.
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
export interface NativeCharacteristic {
|
|
133
|
+
/**
|
|
134
|
+
* Characteristic unique identifier
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
id: Identifier;
|
|
138
|
+
/**
|
|
139
|
+
* Characteristic UUID
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
uuid: UUID;
|
|
143
|
+
/**
|
|
144
|
+
* Service's ID to which characteristic belongs
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
serviceID: Identifier;
|
|
148
|
+
/**
|
|
149
|
+
* Service's UUID to which characteristic belongs
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
152
|
+
serviceUUID: UUID;
|
|
153
|
+
/**
|
|
154
|
+
* Device's ID to which characteristic belongs
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
deviceID: DeviceId;
|
|
158
|
+
/**
|
|
159
|
+
* True if characteristic can be read
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
isReadable: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* True if characteristic can be written with response
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
isWritableWithResponse: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* True if characteristic can be written without response
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
isWritableWithoutResponse: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* True if characteristic can monitor value changes.
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
isNotifiable: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* True if characteristic is monitoring value changes without ACK.
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
isNotifying: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* True if characteristic is monitoring value changes with ACK.
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
isIndicatable: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Characteristic value if present
|
|
190
|
+
* @private
|
|
191
|
+
*/
|
|
192
|
+
value: ?Base64;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Native descriptor object passed from BleModule.
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
export interface NativeDescriptor {
|
|
200
|
+
/**
|
|
201
|
+
* Descriptor unique identifier
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
id: Identifier;
|
|
205
|
+
/**
|
|
206
|
+
* Descriptor UUID
|
|
207
|
+
* @private
|
|
208
|
+
*/
|
|
209
|
+
uuid: UUID;
|
|
210
|
+
/**
|
|
211
|
+
* Characteristic's ID to which descriptor belongs
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
characteristicID: Identifier;
|
|
215
|
+
/**
|
|
216
|
+
* Characteristic's UUID to which descriptor belongs
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
characteristicUUID: UUID;
|
|
220
|
+
/**
|
|
221
|
+
* Service's ID to which descriptor belongs
|
|
222
|
+
* @private
|
|
223
|
+
*/
|
|
224
|
+
serviceID: Identifier;
|
|
225
|
+
/**
|
|
226
|
+
* Service's UUID to which descriptor belongs
|
|
227
|
+
* @private
|
|
228
|
+
*/
|
|
229
|
+
serviceUUID: UUID;
|
|
230
|
+
/**
|
|
231
|
+
* Device's ID to which descriptor belongs
|
|
232
|
+
* @private
|
|
233
|
+
*/
|
|
234
|
+
deviceID: DeviceId;
|
|
235
|
+
/**
|
|
236
|
+
* Descriptor value if present
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
239
|
+
value: ?Base64;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Object representing information about restored BLE state after application relaunch.
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
export interface NativeBleRestoredState {
|
|
247
|
+
/**
|
|
248
|
+
* List of connected devices after state restoration.
|
|
249
|
+
* @type {Array<NativeDevice>}
|
|
250
|
+
* @instance
|
|
251
|
+
* @memberof NativeBleRestoredState
|
|
252
|
+
* @private
|
|
253
|
+
*/
|
|
254
|
+
connectedPeripherals: Array<NativeDevice>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Native BLE Module interface
|
|
259
|
+
* @private
|
|
260
|
+
*/
|
|
261
|
+
export interface BleModuleInterface {
|
|
262
|
+
// NativeModule methods
|
|
263
|
+
|
|
264
|
+
addListener(string): void;
|
|
265
|
+
removeListeners(number): void;
|
|
266
|
+
|
|
267
|
+
// Lifecycle
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Creates new native module internally. Only one module
|
|
271
|
+
* is allowed to be instantiated.
|
|
272
|
+
* @param {?string} restoreIdentifierKey Optional unique Id used for state restoration of BLE manager.
|
|
273
|
+
* @private
|
|
274
|
+
*/
|
|
275
|
+
createClient(restoreIdentifierKey: ?string): void;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Destroys previously instantiated module. This function is
|
|
279
|
+
* only safe when previously BleModule was created.
|
|
280
|
+
* @returns {Promise<void>} Promise may return an error when the function cannot be called.
|
|
281
|
+
* @private
|
|
282
|
+
*/
|
|
283
|
+
destroyClient(): Promise<void>;
|
|
284
|
+
|
|
285
|
+
// Monitoring state
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Enable Bluetooth. This function blocks until BLE is in PoweredOn state. [Android only]
|
|
289
|
+
*
|
|
290
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
291
|
+
* @returns {Promise<void>} Promise completes when state transition was successful.
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
enable(transactionId: TransactionId): Promise<void>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Disable Bluetooth. This function blocks until BLE is in PoweredOff state. [Android only]
|
|
298
|
+
*
|
|
299
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
300
|
+
* @returns {Promise<void>} Promise completes when state transition was successful.
|
|
301
|
+
* @private
|
|
302
|
+
*/
|
|
303
|
+
disable(transactionId: TransactionId): Promise<void>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Current state of BLE device.
|
|
307
|
+
*
|
|
308
|
+
* @returns {Promise<State>} Current state of BLE device.
|
|
309
|
+
* @private
|
|
310
|
+
*/
|
|
311
|
+
state(): Promise<$Keys<typeof State>>;
|
|
312
|
+
|
|
313
|
+
// Scanning
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Starts device scan.
|
|
317
|
+
*
|
|
318
|
+
* @param {?Array<UUID>} filteredUUIDs List of UUIDs for services which needs to be present to detect device during
|
|
319
|
+
* scanning.
|
|
320
|
+
* @param {?ScanOptions} options Platform dependent options
|
|
321
|
+
* @returns {Promise<void>} the promise may be rejected if the operation is impossible to perform.
|
|
322
|
+
* @private
|
|
323
|
+
*/
|
|
324
|
+
startDeviceScan(filteredUUIDs: ?Array<UUID>, options: ?ScanOptions): Promise<void>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Stops device scan.
|
|
328
|
+
* @private
|
|
329
|
+
* @returns {Promise<void>} the promise may be rejected if the operation is impossible to perform.
|
|
330
|
+
*/
|
|
331
|
+
stopDeviceScan(): Promise<void>;
|
|
332
|
+
|
|
333
|
+
// Device operations
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Request a connection parameter update. This functions may update connection parameters on Android API level 21 or
|
|
337
|
+
* above.
|
|
338
|
+
*
|
|
339
|
+
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
340
|
+
* @param {ConnectionPriority} connectionPriority: Connection priority.
|
|
341
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation.
|
|
342
|
+
* @returns {Promise<NativeDevice>} Connected device.
|
|
343
|
+
* @private
|
|
344
|
+
*/
|
|
345
|
+
requestConnectionPriorityForDevice(
|
|
346
|
+
deviceIdentifier: DeviceId,
|
|
347
|
+
connectionPriority: $Values<typeof ConnectionPriority>,
|
|
348
|
+
transactionId: TransactionId
|
|
349
|
+
): Promise<NativeDevice>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Reads RSSI for connected device.
|
|
353
|
+
*
|
|
354
|
+
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
355
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
356
|
+
* @returns {Promise<NativeDevice>} Connected device with updated RSSI value.
|
|
357
|
+
* @private
|
|
358
|
+
*/
|
|
359
|
+
readRSSIForDevice(deviceIdentifier: DeviceId, transactionId: TransactionId): Promise<NativeDevice>;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Request new MTU value for this device. This function currently is not doing anything
|
|
363
|
+
* on iOS platform as MTU exchange is done automatically. Since Android 14,
|
|
364
|
+
* mtu management has been changed, more information can be found at the link:
|
|
365
|
+
* https://developer.android.com/about/versions/14/behavior-changes-all#mtu-set-to-517
|
|
366
|
+
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
367
|
+
* @param {number} mtu New MTU to negotiate.
|
|
368
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
369
|
+
* @returns {Promise<NativeDevice>} Device with updated MTU size. Default value is 23 (517 since Android 14)..
|
|
370
|
+
* @private
|
|
371
|
+
*/
|
|
372
|
+
requestMTUForDevice(deviceIdentifier: DeviceId, mtu: number, transactionId: TransactionId): Promise<NativeDevice>;
|
|
373
|
+
|
|
374
|
+
// Device management
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Returns a list of known peripherals by their identifiers.
|
|
378
|
+
* @param {Array<DeviceId>} deviceIdentifiers List of device identifiers
|
|
379
|
+
* @returns {Promise<Array<NativeDevice>>} List of known devices by their identifiers.
|
|
380
|
+
* @private
|
|
381
|
+
*/
|
|
382
|
+
devices(deviceIdentifiers: Array<DeviceId>): Promise<Array<NativeDevice>>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Returns a list of the peripherals (containing any of the specified services) currently connected to the system
|
|
386
|
+
* which have discovered services. Returned devices **may not be connected** to your application.
|
|
387
|
+
* @param {Array<UUID>} serviceUUIDs List of service UUIDs. Device must contain at least one of them to be listed.
|
|
388
|
+
* @returns {Promise<Array<NativeDevice>>} List of known devices with discovered services as stated in the parameter.
|
|
389
|
+
* @private
|
|
390
|
+
*/
|
|
391
|
+
connectedDevices(serviceUUIDs: Array<UUID>): Promise<Array<NativeDevice>>;
|
|
392
|
+
|
|
393
|
+
// Connection management
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Connect to specified device.
|
|
397
|
+
*
|
|
398
|
+
* @param {DeviceId} deviceIdentifier Device identifier to connect to.
|
|
399
|
+
* @param {?ConnectionOptions} options Connection options.
|
|
400
|
+
* @returns {Promise<NativeDevice>} Connected device.
|
|
401
|
+
* @private
|
|
402
|
+
*/
|
|
403
|
+
connectToDevice(deviceIdentifier: DeviceId, options: ?ConnectionOptions): Promise<NativeDevice>;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Cancels pending device connection.
|
|
407
|
+
*
|
|
408
|
+
* @param {DeviceId} deviceIdentifier Device identifier which is already connected.
|
|
409
|
+
* @returns {Promise<NativeDevice>} Disconnected device.
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
cancelDeviceConnection(deviceIdentifier: DeviceId): Promise<NativeDevice>;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Checks if specified device is connected.
|
|
416
|
+
*
|
|
417
|
+
* @param {DeviceId} deviceIdentifier Device identifier.
|
|
418
|
+
* @returns {Promise<boolean>} True if specified device is connected.
|
|
419
|
+
* @private
|
|
420
|
+
*/
|
|
421
|
+
isDeviceConnected(deviceIdentifier: DeviceId): Promise<boolean>;
|
|
422
|
+
|
|
423
|
+
// Discovery
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Discovers all services, characteristics and descriptors for specified device.
|
|
427
|
+
*
|
|
428
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
429
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
430
|
+
* @returns {Promise<NativeDevice>} Device which has discovered characteristics and services.
|
|
431
|
+
* @private
|
|
432
|
+
*/
|
|
433
|
+
discoverAllServicesAndCharacteristicsForDevice(
|
|
434
|
+
deviceIdentifier: DeviceId,
|
|
435
|
+
transactionId: TransactionId
|
|
436
|
+
): Promise<NativeDevice>;
|
|
437
|
+
|
|
438
|
+
// Service and characteristic getters
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* List of discovered services for specified device.
|
|
442
|
+
*
|
|
443
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
444
|
+
* @returns {Promise<Array<NativeService>>} List of services available in device.
|
|
445
|
+
* @private
|
|
446
|
+
*/
|
|
447
|
+
servicesForDevice(deviceIdentifier: DeviceId): Promise<Array<NativeService>>;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* List of discovered characteristics for specified service.
|
|
451
|
+
*
|
|
452
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
453
|
+
* @param {UUID} serviceUUID Service UUID which contains characteristics.
|
|
454
|
+
* @returns {Promise<Array<NativeCharacteristic>>} List of characteristics available in service.
|
|
455
|
+
* @private
|
|
456
|
+
*/
|
|
457
|
+
characteristicsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID): Promise<Array<NativeCharacteristic>>;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* List of discovered characteristics for specified service.
|
|
461
|
+
*
|
|
462
|
+
* @param {Identifier} serviceIdentifier Service ID which contains characteristics.
|
|
463
|
+
* @returns {Promise<Array<NativeCharacteristic>>} List of characteristics available in service.
|
|
464
|
+
* @private
|
|
465
|
+
*/
|
|
466
|
+
characteristicsForService(serviceIdentifier: Identifier): Promise<Array<NativeCharacteristic>>;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* List of discovered descriptors for specified characteristic.
|
|
470
|
+
*
|
|
471
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier.
|
|
472
|
+
* @param {UUID} serviceUUID Service UUID which contains descriptors.
|
|
473
|
+
* @param {UUID} characteristicUUID Characteristic UUID which contains descriptors.
|
|
474
|
+
* @returns {Promise<Array<NativeDescriptor>>} List of descriptors available in characteristic.
|
|
475
|
+
* @private
|
|
476
|
+
*/
|
|
477
|
+
descriptorsForDevice(
|
|
478
|
+
deviceIdentifier: DeviceId,
|
|
479
|
+
serviceUUID: UUID,
|
|
480
|
+
characteristicUUID: UUID
|
|
481
|
+
): Promise<Array<NativeDescriptor>>;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* List of discovered descriptors for specified characteristic.
|
|
485
|
+
*
|
|
486
|
+
* @param {Identifier} serviceIdentifier Service identifier which contains descriptors.
|
|
487
|
+
* @param {UUID} characteristicUUID Characteristic UUID which contains descriptors.
|
|
488
|
+
* @returns {Promise<Array<NativeDescriptor>>} List of descriptors available in characteristic.
|
|
489
|
+
* @private
|
|
490
|
+
*/
|
|
491
|
+
descriptorsForService(serviceIdentifier: Identifier, characteristicUUID: UUID): Promise<Array<NativeDescriptor>>;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* List of discovered descriptors for specified characteristic.
|
|
495
|
+
*
|
|
496
|
+
* @param {Identifier} characteristicIdentifier Characteristic identifier which contains descriptors.
|
|
497
|
+
* @returns {Promise<Array<NativeDescriptor>>} List of descriptors available in characteristic.
|
|
498
|
+
* @private
|
|
499
|
+
*/
|
|
500
|
+
descriptorsForCharacteristic(characteristicIdentifier: Identifier): Promise<Array<NativeDescriptor>>;
|
|
501
|
+
|
|
502
|
+
// Characteristics operations
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Read characteristic's value.
|
|
506
|
+
*
|
|
507
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
508
|
+
* @param {UUID} serviceUUID Service UUID
|
|
509
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
510
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
511
|
+
* @returns {Promise<NativeCharacteristic>} Characteristic for which value was read
|
|
512
|
+
* @private
|
|
513
|
+
*/
|
|
514
|
+
readCharacteristicForDevice(
|
|
515
|
+
deviceIdentifier: DeviceId,
|
|
516
|
+
serviceUUID: UUID,
|
|
517
|
+
characteristicUUID: UUID,
|
|
518
|
+
transactionId: TransactionId
|
|
519
|
+
): Promise<NativeCharacteristic>;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Read characteristic's value.
|
|
523
|
+
*
|
|
524
|
+
* @param {Identifier} serviceIdentifier Service ID
|
|
525
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
526
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
527
|
+
* @returns {Promise<NativeCharacteristic>} Characteristic for which value was read
|
|
528
|
+
* @private
|
|
529
|
+
*/
|
|
530
|
+
readCharacteristicForService(
|
|
531
|
+
serviceIdentifier: Identifier,
|
|
532
|
+
characteristicUUID: UUID,
|
|
533
|
+
transactionId: TransactionId
|
|
534
|
+
): Promise<NativeCharacteristic>;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Read characteristic's value.
|
|
538
|
+
*
|
|
539
|
+
* @param {Identifier} characteristicIdentifer Characteristic ID
|
|
540
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
541
|
+
* @returns {Promise<NativeCharacteristic>} Characteristic for which value was read
|
|
542
|
+
* @private
|
|
543
|
+
*/
|
|
544
|
+
readCharacteristic(characteristicIdentifer: Identifier, transactionId: TransactionId): Promise<NativeCharacteristic>;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Write value to characteristic.
|
|
548
|
+
*
|
|
549
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
550
|
+
* @param {UUID} serviceUUID Service UUID
|
|
551
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
552
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
553
|
+
* @param {boolean} withResponse True if write should be with response
|
|
554
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
555
|
+
* @returns {Promise<NativeCharacteristic>} Characteristic which saved passed value
|
|
556
|
+
* @private
|
|
557
|
+
*/
|
|
558
|
+
writeCharacteristicForDevice(
|
|
559
|
+
deviceIdentifier: DeviceId,
|
|
560
|
+
serviceUUID: UUID,
|
|
561
|
+
characteristicUUID: UUID,
|
|
562
|
+
valueBase64: Base64,
|
|
563
|
+
withResponse: boolean,
|
|
564
|
+
transactionId: TransactionId
|
|
565
|
+
): Promise<NativeCharacteristic>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Write value to characteristic.
|
|
569
|
+
*
|
|
570
|
+
* @param {Identifier} serviceIdentifier Service ID
|
|
571
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
572
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
573
|
+
* @param {boolean} withResponse True if write should be with response
|
|
574
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
575
|
+
* @returns {Promise<NativeCharacteristic>} Characteristic which saved passed value
|
|
576
|
+
* @private
|
|
577
|
+
*/
|
|
578
|
+
writeCharacteristicForService(
|
|
579
|
+
serviceIdentifier: Identifier,
|
|
580
|
+
characteristicUUID: UUID,
|
|
581
|
+
valueBase64: Base64,
|
|
582
|
+
withResponse: boolean,
|
|
583
|
+
transactionId: TransactionId
|
|
584
|
+
): Promise<NativeCharacteristic>;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Write value to characteristic.
|
|
588
|
+
*
|
|
589
|
+
* @param {Identifier} characteristicIdentifier Characteristic ID
|
|
590
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
591
|
+
* @param {boolean} withResponse True if write should be with response
|
|
592
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
593
|
+
* @returns {Promise<NativeCharacteristic>} Characteristic which saved passed value
|
|
594
|
+
* @private
|
|
595
|
+
*/
|
|
596
|
+
writeCharacteristic(
|
|
597
|
+
characteristicIdentifier: Identifier,
|
|
598
|
+
valueBase64: Base64,
|
|
599
|
+
withResponse: boolean,
|
|
600
|
+
transactionId: TransactionId
|
|
601
|
+
): Promise<NativeCharacteristic>;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Setup monitoring of characteristic value.
|
|
605
|
+
*
|
|
606
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
607
|
+
* @param {UUID} serviceUUID Service UUID
|
|
608
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
609
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
610
|
+
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
611
|
+
* @private
|
|
612
|
+
*/
|
|
613
|
+
monitorCharacteristicForDevice(
|
|
614
|
+
deviceIdentifier: DeviceId,
|
|
615
|
+
serviceUUID: UUID,
|
|
616
|
+
characteristicUUID: UUID,
|
|
617
|
+
transactionId: TransactionId
|
|
618
|
+
): Promise<void>;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Setup monitoring of characteristic value.
|
|
622
|
+
*
|
|
623
|
+
* @param {Identifier} serviceIdentifier Service ID
|
|
624
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
625
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
626
|
+
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
627
|
+
* @private
|
|
628
|
+
*/
|
|
629
|
+
monitorCharacteristicForService(
|
|
630
|
+
serviceIdentifier: Identifier,
|
|
631
|
+
characteristicUUID: UUID,
|
|
632
|
+
transactionId: TransactionId
|
|
633
|
+
): Promise<void>;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Setup monitoring of characteristic value.
|
|
637
|
+
*
|
|
638
|
+
* @param {Identifier} characteristicIdentifier Characteristic ID
|
|
639
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
640
|
+
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
641
|
+
* @private
|
|
642
|
+
*/
|
|
643
|
+
monitorCharacteristic(characteristicIdentifier: Identifier, transactionId: TransactionId): Promise<void>;
|
|
644
|
+
|
|
645
|
+
// Descriptor operations
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Read descriptor's value.
|
|
649
|
+
*
|
|
650
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
651
|
+
* @param {UUID} serviceUUID Service UUID
|
|
652
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
653
|
+
* @param {UUID} descriptorUUID Descriptor UUID
|
|
654
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
655
|
+
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
656
|
+
* @private
|
|
657
|
+
*/
|
|
658
|
+
readDescriptorForDevice(
|
|
659
|
+
deviceIdentifier: DeviceId,
|
|
660
|
+
serviceUUID: UUID,
|
|
661
|
+
characteristicUUID: UUID,
|
|
662
|
+
descriptorUUID: UUID,
|
|
663
|
+
transactionId: TransactionId
|
|
664
|
+
): Promise<NativeDescriptor>;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Read descriptor's value.
|
|
668
|
+
*
|
|
669
|
+
* @param {Identifier} serviceIdentifier Service identifier
|
|
670
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
671
|
+
* @param {UUID} descriptorUUID Descriptor UUID
|
|
672
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
673
|
+
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
674
|
+
* @private
|
|
675
|
+
*/
|
|
676
|
+
readDescriptorForService(
|
|
677
|
+
serviceIdentifier: Identifier,
|
|
678
|
+
characteristicUUID: UUID,
|
|
679
|
+
descriptorUUID: UUID,
|
|
680
|
+
transactionId: TransactionId
|
|
681
|
+
): Promise<NativeDescriptor>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Read descriptor's value.
|
|
685
|
+
*
|
|
686
|
+
* @param {Identifier} characteristicIdentifier Characteristic identifier
|
|
687
|
+
* @param {UUID} descriptorUUID Descriptor UUID
|
|
688
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
689
|
+
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
690
|
+
* @private
|
|
691
|
+
*/
|
|
692
|
+
readDescriptorForCharacteristic(
|
|
693
|
+
characteristicIdentifier: Identifier,
|
|
694
|
+
descriptorUUID: UUID,
|
|
695
|
+
transactionId: TransactionId
|
|
696
|
+
): Promise<NativeDescriptor>;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Read descriptor's value.
|
|
700
|
+
*
|
|
701
|
+
* @param {Identifier} descriptorIdentifier Descriptor identifier
|
|
702
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
703
|
+
* @returns {Promise<NativeDescriptor>} Descriptor for which value was read
|
|
704
|
+
* @private
|
|
705
|
+
*/
|
|
706
|
+
readDescriptor(descriptorIdentifier: Identifier, transactionId: TransactionId): Promise<NativeDescriptor>;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Write value to descriptor.
|
|
710
|
+
*
|
|
711
|
+
* @param {DeviceId} deviceIdentifier Connected device identifier
|
|
712
|
+
* @param {UUID} serviceUUID Service UUID
|
|
713
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
714
|
+
* @param {UUID} descriptorUUID Descriptor UUID
|
|
715
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
716
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
717
|
+
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
718
|
+
* @private
|
|
719
|
+
*/
|
|
720
|
+
writeDescriptorForDevice(
|
|
721
|
+
deviceIdentifier: DeviceId,
|
|
722
|
+
serviceUUID: UUID,
|
|
723
|
+
characteristicUUID: UUID,
|
|
724
|
+
descriptorUUID: UUID,
|
|
725
|
+
valueBase64: Base64,
|
|
726
|
+
transactionId: TransactionId
|
|
727
|
+
): Promise<NativeDescriptor>;
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Write value to descriptor.
|
|
731
|
+
*
|
|
732
|
+
* @param {Identifier} serviceIdentifier Service identifier
|
|
733
|
+
* @param {UUID} characteristicUUID Characteristic UUID
|
|
734
|
+
* @param {UUID} descriptorUUID Descriptor UUID
|
|
735
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
736
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
737
|
+
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
738
|
+
* @private
|
|
739
|
+
*/
|
|
740
|
+
writeDescriptorForService(
|
|
741
|
+
serviceIdentifier: Identifier,
|
|
742
|
+
characteristicUUID: UUID,
|
|
743
|
+
descriptorUUID: UUID,
|
|
744
|
+
valueBase64: Base64,
|
|
745
|
+
transactionId: TransactionId
|
|
746
|
+
): Promise<NativeDescriptor>;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Write value to descriptor.
|
|
750
|
+
*
|
|
751
|
+
* @param {Identifier} characteristicIdentifier Characteristic identifier
|
|
752
|
+
* @param {UUID} descriptorUUID Descriptor UUID
|
|
753
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
754
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
755
|
+
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
756
|
+
* @private
|
|
757
|
+
*/
|
|
758
|
+
writeDescriptorForCharacteristic(
|
|
759
|
+
characteristicIdentifier: Identifier,
|
|
760
|
+
descriptorUUID: UUID,
|
|
761
|
+
valueBase64: Base64,
|
|
762
|
+
transactionId: TransactionId
|
|
763
|
+
): Promise<NativeDescriptor>;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Write value to descriptor.
|
|
767
|
+
*
|
|
768
|
+
* @param {Identifier} descriptorIdentifier Descriptor identifier
|
|
769
|
+
* @param {Base64} valueBase64 Value to be set coded in Base64
|
|
770
|
+
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
771
|
+
* @returns {Promise<NativeDescriptor>} Descriptor which saved passed value
|
|
772
|
+
* @private
|
|
773
|
+
*/
|
|
774
|
+
writeDescriptor(
|
|
775
|
+
descriptorIdentifier: Identifier,
|
|
776
|
+
valueBase64: Base64,
|
|
777
|
+
transactionId: TransactionId
|
|
778
|
+
): Promise<NativeDescriptor>;
|
|
779
|
+
|
|
780
|
+
// Other APIs
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Cancels specified transaction
|
|
784
|
+
*
|
|
785
|
+
* @param {TransactionId} transactionId Transaction handle for operation to be cancelled
|
|
786
|
+
* @returns {Promise<void>}
|
|
787
|
+
* @private
|
|
788
|
+
*/
|
|
789
|
+
cancelTransaction(transactionId: TransactionId): Promise<void>;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Sets new log level for native module's logging mechanism.
|
|
793
|
+
* @param {LogLevel} logLevel New log level to be set.
|
|
794
|
+
* @returns {Promise<LogLevel>} Current log level.
|
|
795
|
+
* @private
|
|
796
|
+
*/
|
|
797
|
+
setLogLevel(logLevel: $Keys<typeof LogLevel>): Promise<$Keys<typeof LogLevel> | void>;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Get current log level for native module's logging mechanism.
|
|
801
|
+
* @returns {Promise<LogLevel>} Current log level.
|
|
802
|
+
* @private
|
|
803
|
+
*/
|
|
804
|
+
logLevel(): Promise<$Keys<typeof LogLevel>>;
|
|
805
|
+
|
|
806
|
+
// Events
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* New scanned event arrived as [?Error, ?NativeDevice] object.
|
|
810
|
+
* @private
|
|
811
|
+
*/
|
|
812
|
+
ScanEvent: string;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Characteristic value update broadcasted due to registered notification as
|
|
816
|
+
* [?Error, ?NativeCharacteristic, ?TransactionId].
|
|
817
|
+
* @private
|
|
818
|
+
*/
|
|
819
|
+
ReadEvent: string;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* BLE Manager changed its state as $Keys<typeof State>
|
|
823
|
+
* @private
|
|
824
|
+
*/
|
|
825
|
+
StateChangeEvent: string;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* BLE Manager restored its internal state
|
|
829
|
+
* @private
|
|
830
|
+
*/
|
|
831
|
+
RestoreStateEvent: string;
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Device disconnected as [Error?, NativeDevice]
|
|
835
|
+
* @private
|
|
836
|
+
*/
|
|
837
|
+
DisconnectionEvent: string;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Native module provider
|
|
842
|
+
*
|
|
843
|
+
* @private
|
|
844
|
+
*/
|
|
845
|
+
export const BleModule: BleModuleInterface = NativeModules.BlePlx
|
|
846
|
+
|
|
847
|
+
export const EventEmitter = NativeEventEmitter
|