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