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