react-native-ble-manager 12.4.3 → 12.4.4
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/android/src/main/java/it/innove/Peripheral.java +28 -9
- package/dist/cjs/index.d.ts +202 -56
- package/dist/cjs/index.js +202 -56
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.d.ts +58 -65
- package/dist/cjs/types.js +11 -32
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/index.d.ts +202 -56
- package/dist/esm/index.js +202 -56
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +58 -65
- package/dist/esm/types.js +10 -31
- package/dist/esm/types.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +212 -66
- package/src/types.ts +58 -66
package/src/index.ts
CHANGED
|
@@ -43,11 +43,12 @@ class BleManager {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @
|
|
46
|
+
* Read the current value of the specified characteristic, you need to call `retrieveServices` method before.
|
|
47
|
+
*
|
|
48
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
49
|
+
* @param serviceUUID The UUID of the service.
|
|
50
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
51
|
+
* @returns Data as an array of numbers (which can be converted back to a Uint8Array (ByteArray) using something like [Buffer.from()](https://github.com/feross/buffer))
|
|
51
52
|
*/
|
|
52
53
|
read(peripheralId: string, serviceUUID: string, characteristicUUID: string) {
|
|
53
54
|
return new Promise<number[]>((fulfill, reject) => {
|
|
@@ -67,11 +68,12 @@ class BleManager {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
71
|
+
* Read the current value of the specified descriptor, you need to call `retrieveServices` method before.
|
|
72
|
+
*
|
|
73
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
74
|
+
* @param serviceUUID The UUID of the service.
|
|
75
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
76
|
+
* @param descriptorUUID The UUID of the descriptor.
|
|
75
77
|
* @returns data as an array of numbers (which can be converted back to a Uint8Array (ByteArray) using something like [Buffer.from()](https://github.com/feross/buffer))
|
|
76
78
|
*/
|
|
77
79
|
readDescriptor(
|
|
@@ -98,12 +100,13 @@ class BleManager {
|
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
103
|
+
* Write a value to the specified descriptor, you need to call `retrieveServices` method before.
|
|
104
|
+
*
|
|
105
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
106
|
+
* @param serviceUUID The UUID of the service.
|
|
107
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
108
|
+
* @param descriptorUUID The UUID of the descriptor.
|
|
109
|
+
* @param data Data to write as an array of numbers (which can be converted from a Uint8Array (ByteArray) using something like [Buffer.toJSON().data](https://github.com/feross/buffer))
|
|
107
110
|
* @returns
|
|
108
111
|
*/
|
|
109
112
|
writeDescriptor(
|
|
@@ -132,9 +135,10 @@ class BleManager {
|
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @
|
|
138
|
+
* Read the current value of the RSSI.
|
|
139
|
+
*
|
|
140
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
141
|
+
* @returns A promise resolving with the updated RSSI (`number`) if it succeeds.
|
|
138
142
|
*/
|
|
139
143
|
readRSSI(peripheralId: string) {
|
|
140
144
|
return new Promise<number>((fulfill, reject) => {
|
|
@@ -153,8 +157,11 @@ class BleManager {
|
|
|
153
157
|
|
|
154
158
|
/**
|
|
155
159
|
* [Android only]
|
|
156
|
-
*
|
|
157
|
-
*
|
|
160
|
+
*
|
|
161
|
+
* Refreshes the peripheral's services and characteristics cache.
|
|
162
|
+
*
|
|
163
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
164
|
+
* @returns A promise that resolves to a boolean indicating if gatt was successfully refreshed or not.
|
|
158
165
|
*/
|
|
159
166
|
refreshCache(peripheralId: string) {
|
|
160
167
|
return new Promise<boolean>((fulfill, reject) => {
|
|
@@ -172,9 +179,10 @@ class BleManager {
|
|
|
172
179
|
}
|
|
173
180
|
|
|
174
181
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* @param
|
|
182
|
+
* Retrieve the peripheral's services and characteristics.
|
|
183
|
+
*
|
|
184
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
185
|
+
* @param serviceUUIDs [iOS only] Optional filter of services to retrieve.
|
|
178
186
|
* @returns
|
|
179
187
|
*/
|
|
180
188
|
retrieveServices(peripheralId: string, serviceUUIDs: string[] = []) {
|
|
@@ -194,12 +202,13 @@ class BleManager {
|
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* @param
|
|
200
|
-
* @param
|
|
201
|
-
* @param
|
|
202
|
-
* @param
|
|
205
|
+
* Write with response to the specified characteristic, you need to call `retrieveServices` method before.
|
|
206
|
+
*
|
|
207
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
208
|
+
* @param serviceUUID The UUID of the service.
|
|
209
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
210
|
+
* @param data Data to write as an array of numbers (which can be converted from a Uint8Array (ByteArray) using something like [Buffer.toJSON().data](https://github.com/feross/buffer))
|
|
211
|
+
* @param maxByteSize Optional, defaults to 20
|
|
203
212
|
* @returns
|
|
204
213
|
*/
|
|
205
214
|
write(
|
|
@@ -228,13 +237,14 @@ class BleManager {
|
|
|
228
237
|
}
|
|
229
238
|
|
|
230
239
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* @param
|
|
234
|
-
* @param
|
|
235
|
-
* @param
|
|
236
|
-
* @param
|
|
237
|
-
* @param
|
|
240
|
+
* Write without response to the specified characteristic, you need to call `retrieveServices` method before.
|
|
241
|
+
*
|
|
242
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
243
|
+
* @param serviceUUID The UUID of the service.
|
|
244
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
245
|
+
* @param data Data to write as an array of numbers (which can be converted from a Uint8Array (ByteArray) using something like [Buffer.toJSON().data](https://github.com/feross/buffer))
|
|
246
|
+
* @param maxByteSize Optional, defaults to 20
|
|
247
|
+
* @param queueSleepTime Optional, defaults to 10. Only useful if data length is greater than maxByteSize.
|
|
238
248
|
* @returns
|
|
239
249
|
*/
|
|
240
250
|
writeWithoutResponse(
|
|
@@ -264,6 +274,11 @@ class BleManager {
|
|
|
264
274
|
});
|
|
265
275
|
}
|
|
266
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Attempts to connect to a peripheral. In many case if you can't connect you have to scan for the peripheral before.
|
|
279
|
+
*
|
|
280
|
+
* > In iOS, attempts to connect to a peripheral do not time out (please see [Apple's doc](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518766-connect)), so you might need to set a timer explicitly if you don't want this behavior.
|
|
281
|
+
*/
|
|
267
282
|
connect(peripheralId: string, options?: ConnectOptions) {
|
|
268
283
|
return new Promise<void>((fulfill, reject) => {
|
|
269
284
|
if (!options) {
|
|
@@ -285,8 +300,13 @@ class BleManager {
|
|
|
285
300
|
|
|
286
301
|
/**
|
|
287
302
|
* [Android only]
|
|
288
|
-
*
|
|
289
|
-
*
|
|
303
|
+
*
|
|
304
|
+
* Start the bonding (pairing) process with the remote device.
|
|
305
|
+
* If you pass peripheralPin (optional), bonding will be auto (without manually entering the pin).
|
|
306
|
+
* > Ensure to make one bond request at a time.
|
|
307
|
+
*
|
|
308
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
309
|
+
* @param peripheralPin Optional. will be used to auto-bond if possible.
|
|
290
310
|
* @returns
|
|
291
311
|
*/
|
|
292
312
|
createBond(peripheralId: string, peripheralPin: string | null = null) {
|
|
@@ -307,7 +327,10 @@ class BleManager {
|
|
|
307
327
|
|
|
308
328
|
/**
|
|
309
329
|
* [Android only]
|
|
310
|
-
*
|
|
330
|
+
*
|
|
331
|
+
* Remove a paired device.
|
|
332
|
+
*
|
|
333
|
+
* @param peripheralId The id/mac address of the peripheral
|
|
311
334
|
* @returns
|
|
312
335
|
*/
|
|
313
336
|
removeBond(peripheralId: string) {
|
|
@@ -323,9 +346,10 @@ class BleManager {
|
|
|
323
346
|
}
|
|
324
347
|
|
|
325
348
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* @param
|
|
349
|
+
* Disconnect from a peripheral.
|
|
350
|
+
*
|
|
351
|
+
* @param peripheralId The id/mac address of the peripheral to disconnect.
|
|
352
|
+
* @param force [Android only] Defaults to true. Don't wait for the disconnect state to close the Gatt client.
|
|
329
353
|
* @returns
|
|
330
354
|
*/
|
|
331
355
|
disconnect(peripheralId: string, force: boolean = true) {
|
|
@@ -344,6 +368,16 @@ class BleManager {
|
|
|
344
368
|
});
|
|
345
369
|
}
|
|
346
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Start the notification on the specified characteristic, you need to call `retrieveServices` method before.
|
|
373
|
+
*
|
|
374
|
+
* Events will be send to `onDidUpdateValueForCharacteristic` when the peripheral notifies a new value for the characteristic.
|
|
375
|
+
*
|
|
376
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
377
|
+
* @param serviceUUID The UUID of the service.
|
|
378
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
379
|
+
* @returns
|
|
380
|
+
*/
|
|
347
381
|
startNotification(
|
|
348
382
|
peripheralId: string,
|
|
349
383
|
serviceUUID: string,
|
|
@@ -367,10 +401,15 @@ class BleManager {
|
|
|
367
401
|
|
|
368
402
|
/**
|
|
369
403
|
* [Android only]
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
404
|
+
*
|
|
405
|
+
* Start the notification on the specified characteristic, you need to call `retrieveServices` method before.
|
|
406
|
+
* The buffer collect messages until the buffer of messages bytes reaches the limit defined with the `buffer` argument and then emit all the collected data.
|
|
407
|
+
* Useful to reduce the number of calls between the native and the react-native part in case of many messages.
|
|
408
|
+
*
|
|
409
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
410
|
+
* @param serviceUUID The UUID of the service.
|
|
411
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
412
|
+
* @param buffer The capacity of the buffer (bytes) stored before emitting the data for the characteristic.
|
|
374
413
|
* @returns
|
|
375
414
|
*/
|
|
376
415
|
startNotificationWithBuffer(
|
|
@@ -396,6 +435,14 @@ class BleManager {
|
|
|
396
435
|
});
|
|
397
436
|
}
|
|
398
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Stop the notification on the specified characteristic.
|
|
440
|
+
*
|
|
441
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
442
|
+
* @param serviceUUID The UUID of the service.
|
|
443
|
+
* @param characteristicUUID The UUID of the characteristic.
|
|
444
|
+
* @returns
|
|
445
|
+
*/
|
|
399
446
|
stopNotification(
|
|
400
447
|
peripheralId: string,
|
|
401
448
|
serviceUUID: string,
|
|
@@ -417,6 +464,10 @@ class BleManager {
|
|
|
417
464
|
});
|
|
418
465
|
}
|
|
419
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Force the module to check the state of the native BLE manager and trigger an event for `onDidUpdateState`.
|
|
469
|
+
* @returns A promise containing the current BleState
|
|
470
|
+
*/
|
|
420
471
|
checkState() {
|
|
421
472
|
return new Promise<BleState>((fulfill, _) => {
|
|
422
473
|
BleManagerModule.checkState((state: BleState) => {
|
|
@@ -425,6 +476,9 @@ class BleManager {
|
|
|
425
476
|
});
|
|
426
477
|
}
|
|
427
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Init the module. Don't call this multiple times.
|
|
481
|
+
*/
|
|
428
482
|
start(options?: StartOptions) {
|
|
429
483
|
return new Promise<void>((fulfill, reject) => {
|
|
430
484
|
if (options == null) {
|
|
@@ -457,8 +511,13 @@ class BleManager {
|
|
|
457
511
|
}
|
|
458
512
|
|
|
459
513
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
514
|
+
* Scan for available peripherals.
|
|
515
|
+
*
|
|
516
|
+
* See `onDiscoverPeripheral` to get live updates of devices being discovered.
|
|
517
|
+
*
|
|
518
|
+
* See `getDiscoveredPeripherals` to get a list of discovered devices after a scan is completed.
|
|
519
|
+
*
|
|
520
|
+
* @param scanningOptions Optional map of properties to fine-tune scan behavior, see DOCS.
|
|
462
521
|
* @returns
|
|
463
522
|
*/
|
|
464
523
|
scan(scanningOptions: ScanOptions = {}) {
|
|
@@ -524,6 +583,9 @@ class BleManager {
|
|
|
524
583
|
});
|
|
525
584
|
}
|
|
526
585
|
|
|
586
|
+
/**
|
|
587
|
+
* Stop the scanning.
|
|
588
|
+
*/
|
|
527
589
|
stopScan() {
|
|
528
590
|
return new Promise<void>((fulfill, reject) => {
|
|
529
591
|
BleManagerModule.stopScan((error: string | null) => {
|
|
@@ -553,8 +615,13 @@ class BleManager {
|
|
|
553
615
|
}
|
|
554
616
|
|
|
555
617
|
/**
|
|
556
|
-
*
|
|
557
|
-
*
|
|
618
|
+
* Return the connected peripherals.
|
|
619
|
+
*
|
|
620
|
+
* > In Android, Peripherals "advertising" property can be not set!
|
|
621
|
+
* > Will be available if peripheral was found through scan before connect.
|
|
622
|
+
* > This matches to current Android Bluetooth design specification.
|
|
623
|
+
*
|
|
624
|
+
* @param serviceUUIDs [iOS only] Optional, only retrieve peripherals with these services. Ignored in Android.
|
|
558
625
|
* @returns
|
|
559
626
|
*/
|
|
560
627
|
getConnectedPeripherals(serviceUUIDs: string[] = []) {
|
|
@@ -578,6 +645,9 @@ class BleManager {
|
|
|
578
645
|
|
|
579
646
|
/**
|
|
580
647
|
* [Android only]
|
|
648
|
+
*
|
|
649
|
+
* Return the bonded peripherals.
|
|
650
|
+
*
|
|
581
651
|
* @returns
|
|
582
652
|
*/
|
|
583
653
|
getBondedPeripherals() {
|
|
@@ -598,6 +668,9 @@ class BleManager {
|
|
|
598
668
|
});
|
|
599
669
|
}
|
|
600
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Return the discovered peripherals after a scan.
|
|
673
|
+
*/
|
|
601
674
|
getDiscoveredPeripherals() {
|
|
602
675
|
return new Promise<Peripheral[]>((fulfill, reject) => {
|
|
603
676
|
BleManagerModule.getDiscoveredPeripherals(
|
|
@@ -618,7 +691,11 @@ class BleManager {
|
|
|
618
691
|
|
|
619
692
|
/**
|
|
620
693
|
* [Android only]
|
|
621
|
-
*
|
|
694
|
+
*
|
|
695
|
+
* Removes a disconnected peripheral from the cached list.
|
|
696
|
+
* It is useful if the device is turned off, because it will be re-discovered upon turning on again.
|
|
697
|
+
*
|
|
698
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
622
699
|
* @returns
|
|
623
700
|
*/
|
|
624
701
|
removePeripheral(peripheralId: string) {
|
|
@@ -637,8 +714,10 @@ class BleManager {
|
|
|
637
714
|
}
|
|
638
715
|
|
|
639
716
|
/**
|
|
640
|
-
*
|
|
641
|
-
*
|
|
717
|
+
* Check whether a specific peripheral is connected and return `true` or `false`.
|
|
718
|
+
*
|
|
719
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
720
|
+
* @param serviceUUIDs [iOS only] Optional, only retrieve peripherals with these services. Ignored in Android.
|
|
642
721
|
* @returns
|
|
643
722
|
*/
|
|
644
723
|
isPeripheralConnected(peripheralId: string, serviceUUIDs: string[] = []) {
|
|
@@ -652,8 +731,7 @@ class BleManager {
|
|
|
652
731
|
}
|
|
653
732
|
|
|
654
733
|
/**
|
|
655
|
-
*
|
|
656
|
-
* @param serviceUUIDs [optional] not used on android, optional on ios.
|
|
734
|
+
* Checks whether the scan is in progress and return `true` or `false`.
|
|
657
735
|
* @returns
|
|
658
736
|
*/
|
|
659
737
|
isScanning() {
|
|
@@ -670,9 +748,9 @@ class BleManager {
|
|
|
670
748
|
|
|
671
749
|
/**
|
|
672
750
|
* [Android only, API 21+]
|
|
673
|
-
* @param peripheralId
|
|
674
|
-
* @param connectionPriority
|
|
675
|
-
* @returns
|
|
751
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
752
|
+
* @param connectionPriority The connection priority to be requested
|
|
753
|
+
* @returns A promise that resolves with a boolean indicating of the connection priority was changed successfully, or rejects with an error message.
|
|
676
754
|
*/
|
|
677
755
|
requestConnectionPriority(
|
|
678
756
|
peripheralId: string,
|
|
@@ -695,9 +773,12 @@ class BleManager {
|
|
|
695
773
|
|
|
696
774
|
/**
|
|
697
775
|
* [Android only, API 21+]
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
776
|
+
*
|
|
777
|
+
* Request an MTU size used for a given connection.
|
|
778
|
+
*
|
|
779
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
780
|
+
* @param mtu Size to be requested, in bytes.
|
|
781
|
+
* @returns A promise resolving with the negotiated MTU if it succeeded. Beware that it might not be the one requested due to device's BLE limitations on both side of the negotiation.
|
|
701
782
|
*/
|
|
702
783
|
requestMTU(peripheralId: string, mtu: number) {
|
|
703
784
|
return new Promise<number>((fulfill, reject) => {
|
|
@@ -717,6 +798,8 @@ class BleManager {
|
|
|
717
798
|
|
|
718
799
|
/**
|
|
719
800
|
* [Android only, API 26+]
|
|
801
|
+
*
|
|
802
|
+
* Retrieve associated peripherals (from companion manager).
|
|
720
803
|
*
|
|
721
804
|
* @returns
|
|
722
805
|
*/
|
|
@@ -736,6 +819,9 @@ class BleManager {
|
|
|
736
819
|
|
|
737
820
|
/**
|
|
738
821
|
* [Android only, API 26+]
|
|
822
|
+
*
|
|
823
|
+
* Remove an associated peripheral.
|
|
824
|
+
*
|
|
739
825
|
* @param peripheralId Peripheral to remove
|
|
740
826
|
* @returns Promise that resolves once the peripheral has been removed. Rejects
|
|
741
827
|
* if no association is found.
|
|
@@ -758,7 +844,7 @@ class BleManager {
|
|
|
758
844
|
/**
|
|
759
845
|
* [Android only]
|
|
760
846
|
*
|
|
761
|
-
* Check if current device supports companion device manager.
|
|
847
|
+
* Check if current device supports the companion device manager.
|
|
762
848
|
*
|
|
763
849
|
* @return Promise resolving to a boolean.
|
|
764
850
|
*/
|
|
@@ -773,7 +859,20 @@ class BleManager {
|
|
|
773
859
|
/**
|
|
774
860
|
* [Android only, API 26+]
|
|
775
861
|
*
|
|
776
|
-
*
|
|
862
|
+
* Scan for companion devices.
|
|
863
|
+
*
|
|
864
|
+
* Rejects if the companion device manager is not supported on this device.
|
|
865
|
+
*
|
|
866
|
+
* The promise it will eventually resolve with either:
|
|
867
|
+
*
|
|
868
|
+
* 1. peripheral if user selects one
|
|
869
|
+
* 2. null if user "cancels" (i.e. doesn't select anything)
|
|
870
|
+
*
|
|
871
|
+
* See `BleManager.supportsCompanion`.
|
|
872
|
+
*
|
|
873
|
+
* See: https://developer.android.com/develop/connectivity/bluetooth/companion-device-pairing
|
|
874
|
+
*
|
|
875
|
+
* @param serviceUUIDs List of service UUIDs to use as a filter
|
|
777
876
|
*/
|
|
778
877
|
companionScan(serviceUUIDs: string[], options: CompanionScanOptions = {}) {
|
|
779
878
|
return new Promise<Peripheral | null>((fulfill, reject) => {
|
|
@@ -793,6 +892,9 @@ class BleManager {
|
|
|
793
892
|
|
|
794
893
|
/**
|
|
795
894
|
* [Android only]
|
|
895
|
+
*
|
|
896
|
+
* Create the request to set the name of the bluetooth adapter. (https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#setName(java.lang.String))
|
|
897
|
+
*
|
|
796
898
|
* @param name
|
|
797
899
|
*/
|
|
798
900
|
setName(name: string) {
|
|
@@ -801,7 +903,7 @@ class BleManager {
|
|
|
801
903
|
|
|
802
904
|
/**
|
|
803
905
|
* [iOS only]
|
|
804
|
-
* @param peripheralId
|
|
906
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
805
907
|
* @returns
|
|
806
908
|
*/
|
|
807
909
|
getMaximumWriteValueLengthForWithoutResponse(peripheralId: string) {
|
|
@@ -821,7 +923,7 @@ class BleManager {
|
|
|
821
923
|
|
|
822
924
|
/**
|
|
823
925
|
* [iOS only]
|
|
824
|
-
* @param peripheralId
|
|
926
|
+
* @param peripheralId The id/mac address of the peripheral.
|
|
825
927
|
* @returns
|
|
826
928
|
*/
|
|
827
929
|
getMaximumWriteValueLengthForWithResponse(peripheralId: string) {
|
|
@@ -839,42 +941,86 @@ class BleManager {
|
|
|
839
941
|
});
|
|
840
942
|
}
|
|
841
943
|
|
|
944
|
+
/**
|
|
945
|
+
* The scanning found a new peripheral.
|
|
946
|
+
*/
|
|
842
947
|
onDiscoverPeripheral(callback: EventCallback<BleDiscoverPeripheralEvent>): EventSubscription {
|
|
843
948
|
return BleManagerModule.onDiscoverPeripheral(callback);
|
|
844
949
|
}
|
|
845
950
|
|
|
951
|
+
/**
|
|
952
|
+
* The scanning for peripherals is ended.
|
|
953
|
+
*/
|
|
846
954
|
onStopScan(callback: EventCallback<BleStopScanEvent>): EventSubscription {
|
|
847
955
|
return BleManagerModule.onStopScan(callback);
|
|
848
956
|
}
|
|
849
957
|
|
|
958
|
+
/**
|
|
959
|
+
* The BLE state changed.
|
|
960
|
+
*/
|
|
850
961
|
onDidUpdateState(callback: EventCallback<BleManagerDidUpdateStateEvent>): EventSubscription {
|
|
851
962
|
return BleManagerModule.onDidUpdateState(callback);
|
|
852
963
|
}
|
|
853
964
|
|
|
965
|
+
/**
|
|
966
|
+
* A peripheral was connected.
|
|
967
|
+
*/
|
|
854
968
|
onConnectPeripheral(callback: EventCallback<BleConnectPeripheralEvent>): EventSubscription {
|
|
855
969
|
return BleManagerModule.onConnectPeripheral(callback);
|
|
856
970
|
}
|
|
857
971
|
|
|
972
|
+
/**
|
|
973
|
+
* A peripheral was disconnected.
|
|
974
|
+
*/
|
|
858
975
|
onDisconnectPeripheral(callback: EventCallback<BleDisconnectPeripheralEvent>): EventSubscription {
|
|
859
976
|
return BleManagerModule.onDisconnectPeripheral(callback);
|
|
860
977
|
}
|
|
861
978
|
|
|
979
|
+
/**
|
|
980
|
+
* A characteristic notified a new value.
|
|
981
|
+
*
|
|
982
|
+
* > Event will only be emitted after successful `startNotification`.
|
|
983
|
+
*/
|
|
862
984
|
onDidUpdateValueForCharacteristic(callback: EventCallback<BleManagerDidUpdateValueForCharacteristicEvent>): EventSubscription {
|
|
863
985
|
return BleManagerModule.onDidUpdateValueForCharacteristic(callback);
|
|
864
986
|
}
|
|
865
987
|
|
|
988
|
+
/**
|
|
989
|
+
* A bond with a peripheral was established.
|
|
990
|
+
*/
|
|
866
991
|
onPeripheralDidBond(callback: EventCallback<BleBondedPeripheralEvent>): EventSubscription {
|
|
867
992
|
return BleManagerModule.onPeripheralDidBond(callback);
|
|
868
993
|
}
|
|
869
994
|
|
|
995
|
+
/**
|
|
996
|
+
* [iOS only]
|
|
997
|
+
*
|
|
998
|
+
* This is fired when [`centralManager:WillRestoreState:`](https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/1518819-centralmanager) is called (app relaunched in the background to handle a bluetooth event).
|
|
999
|
+
*
|
|
1000
|
+
* _For more on performing long-term bluetooth actions in the background:_
|
|
1001
|
+
*
|
|
1002
|
+
* [iOS Bluetooth State Preservation and Restoration](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW10)
|
|
1003
|
+
*
|
|
1004
|
+
* [iOS Relaunch Conditions](https://developer.apple.com/documentation/technotes/tn3115-bluetooth-state-restoration-app-relaunch-rules/)
|
|
1005
|
+
*/
|
|
870
1006
|
onCentralManagerWillRestoreState(callback: EventCallback<BleManagerCentralManagerWillRestoreState>): EventSubscription {
|
|
871
1007
|
return BleManagerModule.onCentralManagerWillRestoreState(callback);
|
|
872
1008
|
}
|
|
873
1009
|
|
|
1010
|
+
/**
|
|
1011
|
+
* [iOS only]
|
|
1012
|
+
*
|
|
1013
|
+
* The peripheral received a request to start or stop providing notifications for a specified characteristic's value.
|
|
1014
|
+
*/
|
|
874
1015
|
onDidUpdateNotificationStateFor(callback: EventCallback<BleManagerDidUpdateNotificationStateForEvent>): EventSubscription {
|
|
875
1016
|
return BleManagerModule.onDidUpdateNotificationStateFor(callback);
|
|
876
1017
|
}
|
|
877
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* User picked a device to associate with.
|
|
1021
|
+
*
|
|
1022
|
+
* Null if the request was cancelled by the user.
|
|
1023
|
+
*/
|
|
878
1024
|
onCompanionPeripheral(callback: EventCallback<BleManagerCompanionPeripheral>): EventSubscription {
|
|
879
1025
|
return BleManagerModule.onCompanionPeripheral(callback);
|
|
880
1026
|
}
|