@capgo/capacitor-bluetooth-low-energy 1.0.0

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/README.md ADDED
@@ -0,0 +1,1154 @@
1
+ # @capgo/capacitor-bluetooth-low-energy
2
+ <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin_bluetooth_low_energy"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin_bluetooth_low_energy"> Missing a feature? We'll build the plugin for you 💪</a></h2>
7
+ </div>
8
+
9
+ Bluetooth Low Energy (BLE) plugin for Capacitor with support for scanning, connecting, reading, writing, and notifications.
10
+
11
+ ## Why Capacitor Bluetooth Low Energy?
12
+
13
+ A comprehensive, **free**, and **powerful** BLE plugin:
14
+
15
+ - **Full BLE support** - Scan, connect, read, write, and receive notifications
16
+ - **Peripheral mode** - Act as a BLE server and advertise services (Android/iOS)
17
+ - **Service discovery** - Automatically discover services, characteristics, and descriptors
18
+ - **Background support** - Foreground service for Android, background modes for iOS
19
+ - **Permission handling** - Built-in permission management for Android 12+ and iOS
20
+ - **Modern package management** - Supports both Swift Package Manager (SPM) and CocoaPods
21
+ - **Cross-platform** - Works on iOS, Android, and Web (Chrome Web Bluetooth API)
22
+
23
+ Perfect for IoT applications, wearables, health devices, smart home, and any BLE-connected peripherals.
24
+
25
+ ## Documentation
26
+
27
+ The most complete doc is available here: https://capgo.app/docs/plugins/bluetooth-low-energy/
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ npm install @capgo/capacitor-bluetooth-low-energy
33
+ npx cap sync
34
+ ```
35
+
36
+ ## iOS
37
+
38
+ Add the following to your `Info.plist`:
39
+
40
+ ```xml
41
+ <key>NSBluetoothAlwaysUsageDescription</key>
42
+ <string>This app uses Bluetooth to communicate with BLE devices.</string>
43
+ <key>NSBluetoothPeripheralUsageDescription</key>
44
+ <string>This app uses Bluetooth to communicate with BLE devices.</string>
45
+ ```
46
+
47
+ For background BLE support, add the following to your `Info.plist`:
48
+
49
+ ```xml
50
+ <key>UIBackgroundModes</key>
51
+ <array>
52
+ <string>bluetooth-central</string>
53
+ <string>bluetooth-peripheral</string>
54
+ </array>
55
+ ```
56
+
57
+ ## Android
58
+
59
+ Works out of the box. The plugin automatically adds the required permissions to your `AndroidManifest.xml`. For Android 12+, you may need to request runtime permissions before using BLE features:
60
+
61
+ ```typescript
62
+ await BluetoothLowEnergy.requestPermissions();
63
+ ```
64
+
65
+ ## Web
66
+
67
+ Works in Chrome and Chromium-based browsers using the Web Bluetooth API. Note that Web Bluetooth requires HTTPS and user interaction to scan for devices.
68
+
69
+ ## API
70
+
71
+ <docgen-index>
72
+
73
+ * [`initialize(...)`](#initialize)
74
+ * [`isAvailable()`](#isavailable)
75
+ * [`isEnabled()`](#isenabled)
76
+ * [`isLocationEnabled()`](#islocationenabled)
77
+ * [`openAppSettings()`](#openappsettings)
78
+ * [`openBluetoothSettings()`](#openbluetoothsettings)
79
+ * [`openLocationSettings()`](#openlocationsettings)
80
+ * [`checkPermissions()`](#checkpermissions)
81
+ * [`requestPermissions()`](#requestpermissions)
82
+ * [`startScan(...)`](#startscan)
83
+ * [`stopScan()`](#stopscan)
84
+ * [`connect(...)`](#connect)
85
+ * [`disconnect(...)`](#disconnect)
86
+ * [`createBond(...)`](#createbond)
87
+ * [`isBonded(...)`](#isbonded)
88
+ * [`discoverServices(...)`](#discoverservices)
89
+ * [`getServices(...)`](#getservices)
90
+ * [`getConnectedDevices()`](#getconnecteddevices)
91
+ * [`readCharacteristic(...)`](#readcharacteristic)
92
+ * [`writeCharacteristic(...)`](#writecharacteristic)
93
+ * [`startCharacteristicNotifications(...)`](#startcharacteristicnotifications)
94
+ * [`stopCharacteristicNotifications(...)`](#stopcharacteristicnotifications)
95
+ * [`readDescriptor(...)`](#readdescriptor)
96
+ * [`writeDescriptor(...)`](#writedescriptor)
97
+ * [`readRssi(...)`](#readrssi)
98
+ * [`requestMtu(...)`](#requestmtu)
99
+ * [`requestConnectionPriority(...)`](#requestconnectionpriority)
100
+ * [`startAdvertising(...)`](#startadvertising)
101
+ * [`stopAdvertising()`](#stopadvertising)
102
+ * [`startForegroundService(...)`](#startforegroundservice)
103
+ * [`stopForegroundService()`](#stopforegroundservice)
104
+ * [`getPluginVersion()`](#getpluginversion)
105
+ * [`addListener('deviceScanned', ...)`](#addlistenerdevicescanned-)
106
+ * [`addListener('deviceConnected', ...)`](#addlistenerdeviceconnected-)
107
+ * [`addListener('deviceDisconnected', ...)`](#addlistenerdevicedisconnected-)
108
+ * [`addListener('characteristicChanged', ...)`](#addlistenercharacteristicchanged-)
109
+ * [`removeAllListeners()`](#removealllisteners)
110
+ * [Interfaces](#interfaces)
111
+ * [Type Aliases](#type-aliases)
112
+
113
+ </docgen-index>
114
+
115
+ <docgen-api>
116
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
117
+
118
+ Capacitor Bluetooth Low Energy Plugin for BLE communication.
119
+
120
+ ### initialize(...)
121
+
122
+ ```typescript
123
+ initialize(options?: InitializeOptions | undefined) => Promise<void>
124
+ ```
125
+
126
+ Initialize the BLE plugin.
127
+ Must be called before any other method.
128
+
129
+ | Param | Type | Description |
130
+ | ------------- | --------------------------------------------------------------- | ------------------------ |
131
+ | **`options`** | <code><a href="#initializeoptions">InitializeOptions</a></code> | - Initialization options |
132
+
133
+ **Since:** 1.0.0
134
+
135
+ --------------------
136
+
137
+
138
+ ### isAvailable()
139
+
140
+ ```typescript
141
+ isAvailable() => Promise<IsAvailableResult>
142
+ ```
143
+
144
+ Check if Bluetooth is available on the device.
145
+
146
+ **Returns:** <code>Promise&lt;<a href="#isavailableresult">IsAvailableResult</a>&gt;</code>
147
+
148
+ **Since:** 1.0.0
149
+
150
+ --------------------
151
+
152
+
153
+ ### isEnabled()
154
+
155
+ ```typescript
156
+ isEnabled() => Promise<IsEnabledResult>
157
+ ```
158
+
159
+ Check if Bluetooth is enabled on the device.
160
+
161
+ **Returns:** <code>Promise&lt;<a href="#isenabledresult">IsEnabledResult</a>&gt;</code>
162
+
163
+ **Since:** 1.0.0
164
+
165
+ --------------------
166
+
167
+
168
+ ### isLocationEnabled()
169
+
170
+ ```typescript
171
+ isLocationEnabled() => Promise<IsLocationEnabledResult>
172
+ ```
173
+
174
+ Check if location services are enabled (Android only).
175
+
176
+ **Returns:** <code>Promise&lt;<a href="#islocationenabledresult">IsLocationEnabledResult</a>&gt;</code>
177
+
178
+ **Since:** 1.0.0
179
+
180
+ --------------------
181
+
182
+
183
+ ### openAppSettings()
184
+
185
+ ```typescript
186
+ openAppSettings() => Promise<void>
187
+ ```
188
+
189
+ Open the app settings page.
190
+
191
+ **Since:** 1.0.0
192
+
193
+ --------------------
194
+
195
+
196
+ ### openBluetoothSettings()
197
+
198
+ ```typescript
199
+ openBluetoothSettings() => Promise<void>
200
+ ```
201
+
202
+ Open the Bluetooth settings page (Android only).
203
+
204
+ **Since:** 1.0.0
205
+
206
+ --------------------
207
+
208
+
209
+ ### openLocationSettings()
210
+
211
+ ```typescript
212
+ openLocationSettings() => Promise<void>
213
+ ```
214
+
215
+ Open the location settings page (Android only).
216
+
217
+ **Since:** 1.0.0
218
+
219
+ --------------------
220
+
221
+
222
+ ### checkPermissions()
223
+
224
+ ```typescript
225
+ checkPermissions() => Promise<PermissionStatus>
226
+ ```
227
+
228
+ Check the current permission status.
229
+
230
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
231
+
232
+ **Since:** 1.0.0
233
+
234
+ --------------------
235
+
236
+
237
+ ### requestPermissions()
238
+
239
+ ```typescript
240
+ requestPermissions() => Promise<PermissionStatus>
241
+ ```
242
+
243
+ Request Bluetooth permissions.
244
+
245
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
246
+
247
+ **Since:** 1.0.0
248
+
249
+ --------------------
250
+
251
+
252
+ ### startScan(...)
253
+
254
+ ```typescript
255
+ startScan(options?: StartScanOptions | undefined) => Promise<void>
256
+ ```
257
+
258
+ Start scanning for BLE devices.
259
+
260
+ | Param | Type | Description |
261
+ | ------------- | ------------------------------------------------------------- | -------------- |
262
+ | **`options`** | <code><a href="#startscanoptions">StartScanOptions</a></code> | - Scan options |
263
+
264
+ **Since:** 1.0.0
265
+
266
+ --------------------
267
+
268
+
269
+ ### stopScan()
270
+
271
+ ```typescript
272
+ stopScan() => Promise<void>
273
+ ```
274
+
275
+ Stop scanning for BLE devices.
276
+
277
+ **Since:** 1.0.0
278
+
279
+ --------------------
280
+
281
+
282
+ ### connect(...)
283
+
284
+ ```typescript
285
+ connect(options: ConnectOptions) => Promise<void>
286
+ ```
287
+
288
+ Connect to a BLE device.
289
+
290
+ | Param | Type | Description |
291
+ | ------------- | --------------------------------------------------------- | -------------------- |
292
+ | **`options`** | <code><a href="#connectoptions">ConnectOptions</a></code> | - Connection options |
293
+
294
+ **Since:** 1.0.0
295
+
296
+ --------------------
297
+
298
+
299
+ ### disconnect(...)
300
+
301
+ ```typescript
302
+ disconnect(options: DisconnectOptions) => Promise<void>
303
+ ```
304
+
305
+ Disconnect from a BLE device.
306
+
307
+ | Param | Type | Description |
308
+ | ------------- | --------------------------------------------------------------- | -------------------- |
309
+ | **`options`** | <code><a href="#disconnectoptions">DisconnectOptions</a></code> | - Disconnect options |
310
+
311
+ **Since:** 1.0.0
312
+
313
+ --------------------
314
+
315
+
316
+ ### createBond(...)
317
+
318
+ ```typescript
319
+ createBond(options: CreateBondOptions) => Promise<void>
320
+ ```
321
+
322
+ Create a bond with a BLE device (Android only).
323
+
324
+ | Param | Type | Description |
325
+ | ------------- | --------------------------------------------------------------- | -------------- |
326
+ | **`options`** | <code><a href="#createbondoptions">CreateBondOptions</a></code> | - Bond options |
327
+
328
+ **Since:** 1.0.0
329
+
330
+ --------------------
331
+
332
+
333
+ ### isBonded(...)
334
+
335
+ ```typescript
336
+ isBonded(options: IsBondedOptions) => Promise<IsBondedResult>
337
+ ```
338
+
339
+ Check if a device is bonded (Android only).
340
+
341
+ | Param | Type | Description |
342
+ | ------------- | ----------------------------------------------------------- | -------------------- |
343
+ | **`options`** | <code><a href="#isbondedoptions">IsBondedOptions</a></code> | - Bond check options |
344
+
345
+ **Returns:** <code>Promise&lt;<a href="#isbondedresult">IsBondedResult</a>&gt;</code>
346
+
347
+ **Since:** 1.0.0
348
+
349
+ --------------------
350
+
351
+
352
+ ### discoverServices(...)
353
+
354
+ ```typescript
355
+ discoverServices(options: DiscoverServicesOptions) => Promise<void>
356
+ ```
357
+
358
+ Discover services on a connected device.
359
+
360
+ | Param | Type | Description |
361
+ | ------------- | --------------------------------------------------------------------------- | ------------------ |
362
+ | **`options`** | <code><a href="#discoverservicesoptions">DiscoverServicesOptions</a></code> | - Discover options |
363
+
364
+ **Since:** 1.0.0
365
+
366
+ --------------------
367
+
368
+
369
+ ### getServices(...)
370
+
371
+ ```typescript
372
+ getServices(options: GetServicesOptions) => Promise<GetServicesResult>
373
+ ```
374
+
375
+ Get discovered services for a device.
376
+
377
+ | Param | Type | Description |
378
+ | ------------- | ----------------------------------------------------------------- | ---------------------- |
379
+ | **`options`** | <code><a href="#getservicesoptions">GetServicesOptions</a></code> | - Get services options |
380
+
381
+ **Returns:** <code>Promise&lt;<a href="#getservicesresult">GetServicesResult</a>&gt;</code>
382
+
383
+ **Since:** 1.0.0
384
+
385
+ --------------------
386
+
387
+
388
+ ### getConnectedDevices()
389
+
390
+ ```typescript
391
+ getConnectedDevices() => Promise<GetConnectedDevicesResult>
392
+ ```
393
+
394
+ Get a list of connected devices.
395
+
396
+ **Returns:** <code>Promise&lt;<a href="#getconnecteddevicesresult">GetConnectedDevicesResult</a>&gt;</code>
397
+
398
+ **Since:** 1.0.0
399
+
400
+ --------------------
401
+
402
+
403
+ ### readCharacteristic(...)
404
+
405
+ ```typescript
406
+ readCharacteristic(options: ReadCharacteristicOptions) => Promise<ReadCharacteristicResult>
407
+ ```
408
+
409
+ Read a characteristic value.
410
+
411
+ | Param | Type | Description |
412
+ | ------------- | ------------------------------------------------------------------------------- | -------------- |
413
+ | **`options`** | <code><a href="#readcharacteristicoptions">ReadCharacteristicOptions</a></code> | - Read options |
414
+
415
+ **Returns:** <code>Promise&lt;<a href="#readcharacteristicresult">ReadCharacteristicResult</a>&gt;</code>
416
+
417
+ **Since:** 1.0.0
418
+
419
+ --------------------
420
+
421
+
422
+ ### writeCharacteristic(...)
423
+
424
+ ```typescript
425
+ writeCharacteristic(options: WriteCharacteristicOptions) => Promise<void>
426
+ ```
427
+
428
+ Write a value to a characteristic.
429
+
430
+ | Param | Type | Description |
431
+ | ------------- | --------------------------------------------------------------------------------- | --------------- |
432
+ | **`options`** | <code><a href="#writecharacteristicoptions">WriteCharacteristicOptions</a></code> | - Write options |
433
+
434
+ **Since:** 1.0.0
435
+
436
+ --------------------
437
+
438
+
439
+ ### startCharacteristicNotifications(...)
440
+
441
+ ```typescript
442
+ startCharacteristicNotifications(options: StartCharacteristicNotificationsOptions) => Promise<void>
443
+ ```
444
+
445
+ Start notifications for a characteristic.
446
+
447
+ | Param | Type | Description |
448
+ | ------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------- |
449
+ | **`options`** | <code><a href="#startcharacteristicnotificationsoptions">StartCharacteristicNotificationsOptions</a></code> | - Notification options |
450
+
451
+ **Since:** 1.0.0
452
+
453
+ --------------------
454
+
455
+
456
+ ### stopCharacteristicNotifications(...)
457
+
458
+ ```typescript
459
+ stopCharacteristicNotifications(options: StopCharacteristicNotificationsOptions) => Promise<void>
460
+ ```
461
+
462
+ Stop notifications for a characteristic.
463
+
464
+ | Param | Type | Description |
465
+ | ------------- | --------------------------------------------------------------------------------------------------------- | --------------------------- |
466
+ | **`options`** | <code><a href="#stopcharacteristicnotificationsoptions">StopCharacteristicNotificationsOptions</a></code> | - Stop notification options |
467
+
468
+ **Since:** 1.0.0
469
+
470
+ --------------------
471
+
472
+
473
+ ### readDescriptor(...)
474
+
475
+ ```typescript
476
+ readDescriptor(options: ReadDescriptorOptions) => Promise<ReadDescriptorResult>
477
+ ```
478
+
479
+ Read a descriptor value.
480
+
481
+ | Param | Type | Description |
482
+ | ------------- | ----------------------------------------------------------------------- | ------------------------- |
483
+ | **`options`** | <code><a href="#readdescriptoroptions">ReadDescriptorOptions</a></code> | - Read descriptor options |
484
+
485
+ **Returns:** <code>Promise&lt;<a href="#readdescriptorresult">ReadDescriptorResult</a>&gt;</code>
486
+
487
+ **Since:** 1.0.0
488
+
489
+ --------------------
490
+
491
+
492
+ ### writeDescriptor(...)
493
+
494
+ ```typescript
495
+ writeDescriptor(options: WriteDescriptorOptions) => Promise<void>
496
+ ```
497
+
498
+ Write a value to a descriptor.
499
+
500
+ | Param | Type | Description |
501
+ | ------------- | ------------------------------------------------------------------------- | -------------------------- |
502
+ | **`options`** | <code><a href="#writedescriptoroptions">WriteDescriptorOptions</a></code> | - Write descriptor options |
503
+
504
+ **Since:** 1.0.0
505
+
506
+ --------------------
507
+
508
+
509
+ ### readRssi(...)
510
+
511
+ ```typescript
512
+ readRssi(options: ReadRssiOptions) => Promise<ReadRssiResult>
513
+ ```
514
+
515
+ Read the RSSI (signal strength) of a connected device.
516
+
517
+ | Param | Type | Description |
518
+ | ------------- | ----------------------------------------------------------- | ------------------- |
519
+ | **`options`** | <code><a href="#readrssioptions">ReadRssiOptions</a></code> | - Read RSSI options |
520
+
521
+ **Returns:** <code>Promise&lt;<a href="#readrssiresult">ReadRssiResult</a>&gt;</code>
522
+
523
+ **Since:** 1.0.0
524
+
525
+ --------------------
526
+
527
+
528
+ ### requestMtu(...)
529
+
530
+ ```typescript
531
+ requestMtu(options: RequestMtuOptions) => Promise<RequestMtuResult>
532
+ ```
533
+
534
+ Request MTU size change (Android only).
535
+
536
+ | Param | Type | Description |
537
+ | ------------- | --------------------------------------------------------------- | --------------------- |
538
+ | **`options`** | <code><a href="#requestmtuoptions">RequestMtuOptions</a></code> | - Request MTU options |
539
+
540
+ **Returns:** <code>Promise&lt;<a href="#requestmturesult">RequestMtuResult</a>&gt;</code>
541
+
542
+ **Since:** 1.0.0
543
+
544
+ --------------------
545
+
546
+
547
+ ### requestConnectionPriority(...)
548
+
549
+ ```typescript
550
+ requestConnectionPriority(options: RequestConnectionPriorityOptions) => Promise<void>
551
+ ```
552
+
553
+ Request connection priority (Android only).
554
+
555
+ | Param | Type | Description |
556
+ | ------------- | --------------------------------------------------------------------------------------------- | -------------------------- |
557
+ | **`options`** | <code><a href="#requestconnectionpriorityoptions">RequestConnectionPriorityOptions</a></code> | - Request priority options |
558
+
559
+ **Since:** 1.0.0
560
+
561
+ --------------------
562
+
563
+
564
+ ### startAdvertising(...)
565
+
566
+ ```typescript
567
+ startAdvertising(options: StartAdvertisingOptions) => Promise<void>
568
+ ```
569
+
570
+ Start advertising as a peripheral (BLE server).
571
+
572
+ | Param | Type | Description |
573
+ | ------------- | --------------------------------------------------------------------------- | --------------------- |
574
+ | **`options`** | <code><a href="#startadvertisingoptions">StartAdvertisingOptions</a></code> | - Advertising options |
575
+
576
+ **Since:** 1.0.0
577
+
578
+ --------------------
579
+
580
+
581
+ ### stopAdvertising()
582
+
583
+ ```typescript
584
+ stopAdvertising() => Promise<void>
585
+ ```
586
+
587
+ Stop advertising.
588
+
589
+ **Since:** 1.0.0
590
+
591
+ --------------------
592
+
593
+
594
+ ### startForegroundService(...)
595
+
596
+ ```typescript
597
+ startForegroundService(options: StartForegroundServiceOptions) => Promise<void>
598
+ ```
599
+
600
+ Start a foreground service to maintain BLE connections in background (Android only).
601
+
602
+ | Param | Type | Description |
603
+ | ------------- | --------------------------------------------------------------------------------------- | ---------------------------- |
604
+ | **`options`** | <code><a href="#startforegroundserviceoptions">StartForegroundServiceOptions</a></code> | - Foreground service options |
605
+
606
+ **Since:** 1.0.0
607
+
608
+ --------------------
609
+
610
+
611
+ ### stopForegroundService()
612
+
613
+ ```typescript
614
+ stopForegroundService() => Promise<void>
615
+ ```
616
+
617
+ Stop the foreground service (Android only).
618
+
619
+ **Since:** 1.0.0
620
+
621
+ --------------------
622
+
623
+
624
+ ### getPluginVersion()
625
+
626
+ ```typescript
627
+ getPluginVersion() => Promise<GetPluginVersionResult>
628
+ ```
629
+
630
+ Get the native Capacitor plugin version.
631
+
632
+ **Returns:** <code>Promise&lt;<a href="#getpluginversionresult">GetPluginVersionResult</a>&gt;</code>
633
+
634
+ **Since:** 1.0.0
635
+
636
+ --------------------
637
+
638
+
639
+ ### addListener('deviceScanned', ...)
640
+
641
+ ```typescript
642
+ addListener(eventName: 'deviceScanned', listenerFunc: (event: DeviceScannedEvent) => void) => Promise<PluginListenerHandle>
643
+ ```
644
+
645
+ Add a listener for device scanned events.
646
+
647
+ | Param | Type | Description |
648
+ | ------------------ | ------------------------------------------------------------------------------------- | ----------------------- |
649
+ | **`eventName`** | <code>'deviceScanned'</code> | - The event name |
650
+ | **`listenerFunc`** | <code>(event: <a href="#devicescannedevent">DeviceScannedEvent</a>) =&gt; void</code> | - The listener function |
651
+
652
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
653
+
654
+ **Since:** 1.0.0
655
+
656
+ --------------------
657
+
658
+
659
+ ### addListener('deviceConnected', ...)
660
+
661
+ ```typescript
662
+ addListener(eventName: 'deviceConnected', listenerFunc: (event: DeviceConnectedEvent) => void) => Promise<PluginListenerHandle>
663
+ ```
664
+
665
+ Add a listener for device connected events.
666
+
667
+ | Param | Type | Description |
668
+ | ------------------ | ----------------------------------------------------------------------------------------- | ----------------------- |
669
+ | **`eventName`** | <code>'deviceConnected'</code> | - The event name |
670
+ | **`listenerFunc`** | <code>(event: <a href="#deviceconnectedevent">DeviceConnectedEvent</a>) =&gt; void</code> | - The listener function |
671
+
672
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
673
+
674
+ **Since:** 1.0.0
675
+
676
+ --------------------
677
+
678
+
679
+ ### addListener('deviceDisconnected', ...)
680
+
681
+ ```typescript
682
+ addListener(eventName: 'deviceDisconnected', listenerFunc: (event: DeviceDisconnectedEvent) => void) => Promise<PluginListenerHandle>
683
+ ```
684
+
685
+ Add a listener for device disconnected events.
686
+
687
+ | Param | Type | Description |
688
+ | ------------------ | ----------------------------------------------------------------------------------------------- | ----------------------- |
689
+ | **`eventName`** | <code>'deviceDisconnected'</code> | - The event name |
690
+ | **`listenerFunc`** | <code>(event: <a href="#devicedisconnectedevent">DeviceDisconnectedEvent</a>) =&gt; void</code> | - The listener function |
691
+
692
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
693
+
694
+ **Since:** 1.0.0
695
+
696
+ --------------------
697
+
698
+
699
+ ### addListener('characteristicChanged', ...)
700
+
701
+ ```typescript
702
+ addListener(eventName: 'characteristicChanged', listenerFunc: (event: CharacteristicChangedEvent) => void) => Promise<PluginListenerHandle>
703
+ ```
704
+
705
+ Add a listener for characteristic changed events.
706
+
707
+ | Param | Type | Description |
708
+ | ------------------ | ----------------------------------------------------------------------------------------------------- | ----------------------- |
709
+ | **`eventName`** | <code>'characteristicChanged'</code> | - The event name |
710
+ | **`listenerFunc`** | <code>(event: <a href="#characteristicchangedevent">CharacteristicChangedEvent</a>) =&gt; void</code> | - The listener function |
711
+
712
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
713
+
714
+ **Since:** 1.0.0
715
+
716
+ --------------------
717
+
718
+
719
+ ### removeAllListeners()
720
+
721
+ ```typescript
722
+ removeAllListeners() => Promise<void>
723
+ ```
724
+
725
+ Remove all listeners for this plugin.
726
+
727
+ **Since:** 1.0.0
728
+
729
+ --------------------
730
+
731
+
732
+ ### Interfaces
733
+
734
+
735
+ #### InitializeOptions
736
+
737
+ Initialization options for the plugin.
738
+
739
+ | Prop | Type | Description | Default | Since |
740
+ | ---------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----- |
741
+ | **`mode`** | <code>'central' \| 'peripheral'</code> | The mode to initialize the plugin in. - 'central': Act as a BLE central (client) - 'peripheral': Act as a BLE peripheral (server) | <code>'central'</code> | 1.0.0 |
742
+
743
+
744
+ #### IsAvailableResult
745
+
746
+ Result of the isAvailable method.
747
+
748
+ | Prop | Type | Description | Since |
749
+ | --------------- | -------------------- | --------------------------------------------- | ----- |
750
+ | **`available`** | <code>boolean</code> | Whether Bluetooth is available on the device. | 1.0.0 |
751
+
752
+
753
+ #### IsEnabledResult
754
+
755
+ Result of the isEnabled method.
756
+
757
+ | Prop | Type | Description | Since |
758
+ | ------------- | -------------------- | ------------------------------------------- | ----- |
759
+ | **`enabled`** | <code>boolean</code> | Whether Bluetooth is enabled on the device. | 1.0.0 |
760
+
761
+
762
+ #### IsLocationEnabledResult
763
+
764
+ Result of the isLocationEnabled method.
765
+
766
+ | Prop | Type | Description | Since |
767
+ | ------------- | -------------------- | ---------------------------------------------------- | ----- |
768
+ | **`enabled`** | <code>boolean</code> | Whether location services are enabled on the device. | 1.0.0 |
769
+
770
+
771
+ #### PermissionStatus
772
+
773
+ Permission status for Bluetooth and location.
774
+
775
+ | Prop | Type | Description | Since |
776
+ | --------------- | ----------------------------------------------------------- | ------------------------------------------ | ----- |
777
+ | **`bluetooth`** | <code><a href="#permissionstate">PermissionState</a></code> | Bluetooth permission status. | 1.0.0 |
778
+ | **`location`** | <code><a href="#permissionstate">PermissionState</a></code> | Location permission status (Android only). | 1.0.0 |
779
+
780
+
781
+ #### StartScanOptions
782
+
783
+ Options for starting a scan.
784
+
785
+ | Prop | Type | Description | Default | Since |
786
+ | --------------------- | --------------------- | --------------------------------------------------------------------------------------------- | ------------------ | ----- |
787
+ | **`services`** | <code>string[]</code> | List of service UUIDs to filter by. Only devices advertising these services will be returned. | | 1.0.0 |
788
+ | **`timeout`** | <code>number</code> | Scan timeout in milliseconds. Set to 0 for no timeout. | <code>0</code> | 1.0.0 |
789
+ | **`allowDuplicates`** | <code>boolean</code> | Whether to allow duplicate scan results. | <code>false</code> | 1.0.0 |
790
+
791
+
792
+ #### ConnectOptions
793
+
794
+ Options for connecting to a device.
795
+
796
+ | Prop | Type | Description | Default | Since |
797
+ | ----------------- | -------------------- | ------------------------------------------------------------------- | ------------------ | ----- |
798
+ | **`deviceId`** | <code>string</code> | The device ID (MAC address on Android, UUID on iOS). | | 1.0.0 |
799
+ | **`autoConnect`** | <code>boolean</code> | Whether to automatically connect when the device becomes available. | <code>false</code> | 1.0.0 |
800
+
801
+
802
+ #### DisconnectOptions
803
+
804
+ Options for disconnecting from a device.
805
+
806
+ | Prop | Type | Description | Since |
807
+ | -------------- | ------------------- | --------------------------------- | ----- |
808
+ | **`deviceId`** | <code>string</code> | The device ID to disconnect from. | 1.0.0 |
809
+
810
+
811
+ #### CreateBondOptions
812
+
813
+ Options for creating a bond.
814
+
815
+ | Prop | Type | Description | Since |
816
+ | -------------- | ------------------- | --------------------------- | ----- |
817
+ | **`deviceId`** | <code>string</code> | The device ID to bond with. | 1.0.0 |
818
+
819
+
820
+ #### IsBondedResult
821
+
822
+ Result of the isBonded method.
823
+
824
+ | Prop | Type | Description | Since |
825
+ | ------------ | -------------------- | ----------------------------- | ----- |
826
+ | **`bonded`** | <code>boolean</code> | Whether the device is bonded. | 1.0.0 |
827
+
828
+
829
+ #### IsBondedOptions
830
+
831
+ Options for checking bond status.
832
+
833
+ | Prop | Type | Description | Since |
834
+ | -------------- | ------------------- | ----------------------- | ----- |
835
+ | **`deviceId`** | <code>string</code> | The device ID to check. | 1.0.0 |
836
+
837
+
838
+ #### DiscoverServicesOptions
839
+
840
+ Options for discovering services.
841
+
842
+ | Prop | Type | Description | Since |
843
+ | -------------- | ------------------- | -------------------------------------- | ----- |
844
+ | **`deviceId`** | <code>string</code> | The device ID to discover services on. | 1.0.0 |
845
+
846
+
847
+ #### GetServicesResult
848
+
849
+ Result of the getServices method.
850
+
851
+ | Prop | Type | Description | Since |
852
+ | -------------- | ------------------------- | ---------------------------- | ----- |
853
+ | **`services`** | <code>BleService[]</code> | List of discovered services. | 1.0.0 |
854
+
855
+
856
+ #### BleService
857
+
858
+ A BLE service.
859
+
860
+ | Prop | Type | Description | Since |
861
+ | --------------------- | -------------------------------- | ---------------------------------------- | ----- |
862
+ | **`uuid`** | <code>string</code> | The service UUID. | 1.0.0 |
863
+ | **`characteristics`** | <code>BleCharacteristic[]</code> | List of characteristics in this service. | 1.0.0 |
864
+
865
+
866
+ #### BleCharacteristic
867
+
868
+ A BLE characteristic.
869
+
870
+ | Prop | Type | Description | Since |
871
+ | ----------------- | ----------------------------------------------------------------------------- | ------------------------------------------- | ----- |
872
+ | **`uuid`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
873
+ | **`properties`** | <code><a href="#characteristicproperties">CharacteristicProperties</a></code> | Properties of this characteristic. | 1.0.0 |
874
+ | **`descriptors`** | <code>BleDescriptor[]</code> | List of descriptors in this characteristic. | 1.0.0 |
875
+
876
+
877
+ #### CharacteristicProperties
878
+
879
+ Properties of a BLE characteristic.
880
+
881
+ | Prop | Type | Description | Since |
882
+ | ------------------------------- | -------------------- | ---------------------------------------------------------------- | ----- |
883
+ | **`broadcast`** | <code>boolean</code> | Whether the characteristic supports broadcast. | 1.0.0 |
884
+ | **`read`** | <code>boolean</code> | Whether the characteristic supports read. | 1.0.0 |
885
+ | **`writeWithoutResponse`** | <code>boolean</code> | Whether the characteristic supports write without response. | 1.0.0 |
886
+ | **`write`** | <code>boolean</code> | Whether the characteristic supports write. | 1.0.0 |
887
+ | **`notify`** | <code>boolean</code> | Whether the characteristic supports notify. | 1.0.0 |
888
+ | **`indicate`** | <code>boolean</code> | Whether the characteristic supports indicate. | 1.0.0 |
889
+ | **`authenticatedSignedWrites`** | <code>boolean</code> | Whether the characteristic supports authenticated signed writes. | 1.0.0 |
890
+ | **`extendedProperties`** | <code>boolean</code> | Whether the characteristic has extended properties. | 1.0.0 |
891
+
892
+
893
+ #### BleDescriptor
894
+
895
+ A BLE descriptor.
896
+
897
+ | Prop | Type | Description | Since |
898
+ | ---------- | ------------------- | -------------------- | ----- |
899
+ | **`uuid`** | <code>string</code> | The descriptor UUID. | 1.0.0 |
900
+
901
+
902
+ #### GetServicesOptions
903
+
904
+ Options for getting services.
905
+
906
+ | Prop | Type | Description | Since |
907
+ | -------------- | ------------------- | ---------------------------------- | ----- |
908
+ | **`deviceId`** | <code>string</code> | The device ID to get services for. | 1.0.0 |
909
+
910
+
911
+ #### GetConnectedDevicesResult
912
+
913
+ Result of the getConnectedDevices method.
914
+
915
+ | Prop | Type | Description | Since |
916
+ | ------------- | ------------------------ | -------------------------- | ----- |
917
+ | **`devices`** | <code>BleDevice[]</code> | List of connected devices. | 1.0.0 |
918
+
919
+
920
+ #### BleDevice
921
+
922
+ A BLE device.
923
+
924
+ | Prop | Type | Description | Since |
925
+ | ---------------------- | --------------------------- | ----------------------------------------------------- | ----- |
926
+ | **`deviceId`** | <code>string</code> | The device ID (MAC address on Android, UUID on iOS). | 1.0.0 |
927
+ | **`name`** | <code>string \| null</code> | The device name (may be null if not available). | 1.0.0 |
928
+ | **`rssi`** | <code>number</code> | The RSSI (signal strength) at time of discovery. | 1.0.0 |
929
+ | **`manufacturerData`** | <code>string</code> | Manufacturer data from advertisement (as hex string). | 1.0.0 |
930
+ | **`serviceUuids`** | <code>string[]</code> | Service UUIDs advertised by the device. | 1.0.0 |
931
+
932
+
933
+ #### ReadCharacteristicResult
934
+
935
+ Result of reading a characteristic.
936
+
937
+ | Prop | Type | Description | Since |
938
+ | ----------- | --------------------- | ---------------------------------------------- | ----- |
939
+ | **`value`** | <code>number[]</code> | The characteristic value as an array of bytes. | 1.0.0 |
940
+
941
+
942
+ #### ReadCharacteristicOptions
943
+
944
+ Options for reading a characteristic.
945
+
946
+ | Prop | Type | Description | Since |
947
+ | -------------------- | ------------------- | ------------------------ | ----- |
948
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
949
+ | **`service`** | <code>string</code> | The service UUID. | 1.0.0 |
950
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
951
+
952
+
953
+ #### WriteCharacteristicOptions
954
+
955
+ Options for writing to a characteristic.
956
+
957
+ | Prop | Type | Description | Default | Since |
958
+ | -------------------- | ------------------------------------------------ | ---------------------------------------- | --------------------------- | ----- |
959
+ | **`deviceId`** | <code>string</code> | The device ID. | | 1.0.0 |
960
+ | **`service`** | <code>string</code> | The service UUID. | | 1.0.0 |
961
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | | 1.0.0 |
962
+ | **`value`** | <code>number[]</code> | The value to write as an array of bytes. | | 1.0.0 |
963
+ | **`type`** | <code>'withResponse' \| 'withoutResponse'</code> | Write type. | <code>'withResponse'</code> | 1.0.0 |
964
+
965
+
966
+ #### StartCharacteristicNotificationsOptions
967
+
968
+ Options for starting characteristic notifications.
969
+
970
+ | Prop | Type | Description | Since |
971
+ | -------------------- | ------------------- | ------------------------ | ----- |
972
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
973
+ | **`service`** | <code>string</code> | The service UUID. | 1.0.0 |
974
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
975
+
976
+
977
+ #### StopCharacteristicNotificationsOptions
978
+
979
+ Options for stopping characteristic notifications.
980
+
981
+ | Prop | Type | Description | Since |
982
+ | -------------------- | ------------------- | ------------------------ | ----- |
983
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
984
+ | **`service`** | <code>string</code> | The service UUID. | 1.0.0 |
985
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
986
+
987
+
988
+ #### ReadDescriptorResult
989
+
990
+ Result of reading a descriptor.
991
+
992
+ | Prop | Type | Description | Since |
993
+ | ----------- | --------------------- | ------------------------------------------ | ----- |
994
+ | **`value`** | <code>number[]</code> | The descriptor value as an array of bytes. | 1.0.0 |
995
+
996
+
997
+ #### ReadDescriptorOptions
998
+
999
+ Options for reading a descriptor.
1000
+
1001
+ | Prop | Type | Description | Since |
1002
+ | -------------------- | ------------------- | ------------------------ | ----- |
1003
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1004
+ | **`service`** | <code>string</code> | The service UUID. | 1.0.0 |
1005
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
1006
+ | **`descriptor`** | <code>string</code> | The descriptor UUID. | 1.0.0 |
1007
+
1008
+
1009
+ #### WriteDescriptorOptions
1010
+
1011
+ Options for writing to a descriptor.
1012
+
1013
+ | Prop | Type | Description | Since |
1014
+ | -------------------- | --------------------- | ---------------------------------------- | ----- |
1015
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1016
+ | **`service`** | <code>string</code> | The service UUID. | 1.0.0 |
1017
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
1018
+ | **`descriptor`** | <code>string</code> | The descriptor UUID. | 1.0.0 |
1019
+ | **`value`** | <code>number[]</code> | The value to write as an array of bytes. | 1.0.0 |
1020
+
1021
+
1022
+ #### ReadRssiResult
1023
+
1024
+ Result of reading RSSI.
1025
+
1026
+ | Prop | Type | Description | Since |
1027
+ | ---------- | ------------------- | ---------------------- | ----- |
1028
+ | **`rssi`** | <code>number</code> | The RSSI value in dBm. | 1.0.0 |
1029
+
1030
+
1031
+ #### ReadRssiOptions
1032
+
1033
+ Options for reading RSSI.
1034
+
1035
+ | Prop | Type | Description | Since |
1036
+ | -------------- | ------------------- | -------------- | ----- |
1037
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1038
+
1039
+
1040
+ #### RequestMtuResult
1041
+
1042
+ Result of requesting MTU.
1043
+
1044
+ | Prop | Type | Description | Since |
1045
+ | --------- | ------------------- | ------------------------ | ----- |
1046
+ | **`mtu`** | <code>number</code> | The negotiated MTU size. | 1.0.0 |
1047
+
1048
+
1049
+ #### RequestMtuOptions
1050
+
1051
+ Options for requesting MTU.
1052
+
1053
+ | Prop | Type | Description | Since |
1054
+ | -------------- | ------------------- | ----------------------- | ----- |
1055
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1056
+ | **`mtu`** | <code>number</code> | The requested MTU size. | 1.0.0 |
1057
+
1058
+
1059
+ #### RequestConnectionPriorityOptions
1060
+
1061
+ Options for requesting connection priority.
1062
+
1063
+ | Prop | Type | Description | Since |
1064
+ | -------------- | ------------------------------------------ | ---------------------------------- | ----- |
1065
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1066
+ | **`priority`** | <code>'low' \| 'balanced' \| 'high'</code> | The requested connection priority. | 1.0.0 |
1067
+
1068
+
1069
+ #### StartAdvertisingOptions
1070
+
1071
+ Options for starting advertising.
1072
+
1073
+ | Prop | Type | Description | Default | Since |
1074
+ | ------------------------- | --------------------- | -------------------------------------------------------- | ------------------ | ----- |
1075
+ | **`name`** | <code>string</code> | The device name to advertise. | | 1.0.0 |
1076
+ | **`services`** | <code>string[]</code> | Service UUIDs to advertise. | | 1.0.0 |
1077
+ | **`includeName`** | <code>boolean</code> | Whether to include the device name in the advertisement. | <code>true</code> | 1.0.0 |
1078
+ | **`includeTxPowerLevel`** | <code>boolean</code> | Whether to include TX power level in the advertisement. | <code>false</code> | 1.0.0 |
1079
+
1080
+
1081
+ #### StartForegroundServiceOptions
1082
+
1083
+ Options for starting the foreground service.
1084
+
1085
+ | Prop | Type | Description | Since |
1086
+ | --------------- | ------------------- | ------------------------------------------ | ----- |
1087
+ | **`title`** | <code>string</code> | The notification title. | 1.0.0 |
1088
+ | **`body`** | <code>string</code> | The notification body. | 1.0.0 |
1089
+ | **`smallIcon`** | <code>string</code> | The notification small icon resource name. | 1.0.0 |
1090
+
1091
+
1092
+ #### GetPluginVersionResult
1093
+
1094
+ Result of getPluginVersion.
1095
+
1096
+ | Prop | Type | Description | Since |
1097
+ | ------------- | ------------------- | ------------------- | ----- |
1098
+ | **`version`** | <code>string</code> | The plugin version. | 1.0.0 |
1099
+
1100
+
1101
+ #### PluginListenerHandle
1102
+
1103
+ | Prop | Type |
1104
+ | ------------ | ----------------------------------------- |
1105
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
1106
+
1107
+
1108
+ #### DeviceScannedEvent
1109
+
1110
+ Event emitted when a device is scanned.
1111
+
1112
+ | Prop | Type | Description | Since |
1113
+ | ------------ | ----------------------------------------------- | ------------------- | ----- |
1114
+ | **`device`** | <code><a href="#bledevice">BleDevice</a></code> | The scanned device. | 1.0.0 |
1115
+
1116
+
1117
+ #### DeviceConnectedEvent
1118
+
1119
+ Event emitted when a device is connected.
1120
+
1121
+ | Prop | Type | Description | Since |
1122
+ | -------------- | ------------------- | -------------- | ----- |
1123
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1124
+
1125
+
1126
+ #### DeviceDisconnectedEvent
1127
+
1128
+ Event emitted when a device is disconnected.
1129
+
1130
+ | Prop | Type | Description | Since |
1131
+ | -------------- | ------------------- | -------------- | ----- |
1132
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1133
+
1134
+
1135
+ #### CharacteristicChangedEvent
1136
+
1137
+ Event emitted when a characteristic value changes.
1138
+
1139
+ | Prop | Type | Description | Since |
1140
+ | -------------------- | --------------------- | ----------------------------------- | ----- |
1141
+ | **`deviceId`** | <code>string</code> | The device ID. | 1.0.0 |
1142
+ | **`service`** | <code>string</code> | The service UUID. | 1.0.0 |
1143
+ | **`characteristic`** | <code>string</code> | The characteristic UUID. | 1.0.0 |
1144
+ | **`value`** | <code>number[]</code> | The new value as an array of bytes. | 1.0.0 |
1145
+
1146
+
1147
+ ### Type Aliases
1148
+
1149
+
1150
+ #### PermissionState
1151
+
1152
+ <code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>
1153
+
1154
+ </docgen-api>