@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.
@@ -0,0 +1,1333 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ /**
3
+ * Capacitor Bluetooth Low Energy Plugin for BLE communication.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ export interface BluetoothLowEnergyPlugin {
8
+ /**
9
+ * Initialize the BLE plugin.
10
+ * Must be called before any other method.
11
+ *
12
+ * @param options - Initialization options
13
+ * @returns Promise that resolves when initialization is complete
14
+ * @throws Error if initialization fails
15
+ * @since 1.0.0
16
+ * @example
17
+ * ```typescript
18
+ * await BluetoothLowEnergy.initialize({ mode: 'central' });
19
+ * ```
20
+ */
21
+ initialize(options?: InitializeOptions): Promise<void>;
22
+ /**
23
+ * Check if Bluetooth is available on the device.
24
+ *
25
+ * @returns Promise that resolves with availability status
26
+ * @since 1.0.0
27
+ * @example
28
+ * ```typescript
29
+ * const { available } = await BluetoothLowEnergy.isAvailable();
30
+ * ```
31
+ */
32
+ isAvailable(): Promise<IsAvailableResult>;
33
+ /**
34
+ * Check if Bluetooth is enabled on the device.
35
+ *
36
+ * @returns Promise that resolves with enabled status
37
+ * @since 1.0.0
38
+ * @example
39
+ * ```typescript
40
+ * const { enabled } = await BluetoothLowEnergy.isEnabled();
41
+ * ```
42
+ */
43
+ isEnabled(): Promise<IsEnabledResult>;
44
+ /**
45
+ * Check if location services are enabled (Android only).
46
+ *
47
+ * @returns Promise that resolves with location enabled status
48
+ * @since 1.0.0
49
+ * @example
50
+ * ```typescript
51
+ * const { enabled } = await BluetoothLowEnergy.isLocationEnabled();
52
+ * ```
53
+ */
54
+ isLocationEnabled(): Promise<IsLocationEnabledResult>;
55
+ /**
56
+ * Open the app settings page.
57
+ *
58
+ * @returns Promise that resolves when settings are opened
59
+ * @since 1.0.0
60
+ * @example
61
+ * ```typescript
62
+ * await BluetoothLowEnergy.openAppSettings();
63
+ * ```
64
+ */
65
+ openAppSettings(): Promise<void>;
66
+ /**
67
+ * Open the Bluetooth settings page (Android only).
68
+ *
69
+ * @returns Promise that resolves when settings are opened
70
+ * @since 1.0.0
71
+ * @example
72
+ * ```typescript
73
+ * await BluetoothLowEnergy.openBluetoothSettings();
74
+ * ```
75
+ */
76
+ openBluetoothSettings(): Promise<void>;
77
+ /**
78
+ * Open the location settings page (Android only).
79
+ *
80
+ * @returns Promise that resolves when settings are opened
81
+ * @since 1.0.0
82
+ * @example
83
+ * ```typescript
84
+ * await BluetoothLowEnergy.openLocationSettings();
85
+ * ```
86
+ */
87
+ openLocationSettings(): Promise<void>;
88
+ /**
89
+ * Check the current permission status.
90
+ *
91
+ * @returns Promise that resolves with permission status
92
+ * @since 1.0.0
93
+ * @example
94
+ * ```typescript
95
+ * const { bluetooth, location } = await BluetoothLowEnergy.checkPermissions();
96
+ * ```
97
+ */
98
+ checkPermissions(): Promise<PermissionStatus>;
99
+ /**
100
+ * Request Bluetooth permissions.
101
+ *
102
+ * @returns Promise that resolves with permission status
103
+ * @since 1.0.0
104
+ * @example
105
+ * ```typescript
106
+ * const { bluetooth, location } = await BluetoothLowEnergy.requestPermissions();
107
+ * ```
108
+ */
109
+ requestPermissions(): Promise<PermissionStatus>;
110
+ /**
111
+ * Start scanning for BLE devices.
112
+ *
113
+ * @param options - Scan options
114
+ * @returns Promise that resolves when scanning starts
115
+ * @since 1.0.0
116
+ * @example
117
+ * ```typescript
118
+ * await BluetoothLowEnergy.startScan({
119
+ * services: ['180D'], // Heart Rate Service
120
+ * timeout: 10000
121
+ * });
122
+ * ```
123
+ */
124
+ startScan(options?: StartScanOptions): Promise<void>;
125
+ /**
126
+ * Stop scanning for BLE devices.
127
+ *
128
+ * @returns Promise that resolves when scanning stops
129
+ * @since 1.0.0
130
+ * @example
131
+ * ```typescript
132
+ * await BluetoothLowEnergy.stopScan();
133
+ * ```
134
+ */
135
+ stopScan(): Promise<void>;
136
+ /**
137
+ * Connect to a BLE device.
138
+ *
139
+ * @param options - Connection options
140
+ * @returns Promise that resolves when connected
141
+ * @since 1.0.0
142
+ * @example
143
+ * ```typescript
144
+ * await BluetoothLowEnergy.connect({ deviceId: 'AA:BB:CC:DD:EE:FF' });
145
+ * ```
146
+ */
147
+ connect(options: ConnectOptions): Promise<void>;
148
+ /**
149
+ * Disconnect from a BLE device.
150
+ *
151
+ * @param options - Disconnect options
152
+ * @returns Promise that resolves when disconnected
153
+ * @since 1.0.0
154
+ * @example
155
+ * ```typescript
156
+ * await BluetoothLowEnergy.disconnect({ deviceId: 'AA:BB:CC:DD:EE:FF' });
157
+ * ```
158
+ */
159
+ disconnect(options: DisconnectOptions): Promise<void>;
160
+ /**
161
+ * Create a bond with a BLE device (Android only).
162
+ *
163
+ * @param options - Bond options
164
+ * @returns Promise that resolves when bond is created
165
+ * @since 1.0.0
166
+ * @example
167
+ * ```typescript
168
+ * await BluetoothLowEnergy.createBond({ deviceId: 'AA:BB:CC:DD:EE:FF' });
169
+ * ```
170
+ */
171
+ createBond(options: CreateBondOptions): Promise<void>;
172
+ /**
173
+ * Check if a device is bonded (Android only).
174
+ *
175
+ * @param options - Bond check options
176
+ * @returns Promise that resolves with bonded status
177
+ * @since 1.0.0
178
+ * @example
179
+ * ```typescript
180
+ * const { bonded } = await BluetoothLowEnergy.isBonded({ deviceId: 'AA:BB:CC:DD:EE:FF' });
181
+ * ```
182
+ */
183
+ isBonded(options: IsBondedOptions): Promise<IsBondedResult>;
184
+ /**
185
+ * Discover services on a connected device.
186
+ *
187
+ * @param options - Discover options
188
+ * @returns Promise that resolves when discovery is complete
189
+ * @since 1.0.0
190
+ * @example
191
+ * ```typescript
192
+ * await BluetoothLowEnergy.discoverServices({ deviceId: 'AA:BB:CC:DD:EE:FF' });
193
+ * ```
194
+ */
195
+ discoverServices(options: DiscoverServicesOptions): Promise<void>;
196
+ /**
197
+ * Get discovered services for a device.
198
+ *
199
+ * @param options - Get services options
200
+ * @returns Promise that resolves with services list
201
+ * @since 1.0.0
202
+ * @example
203
+ * ```typescript
204
+ * const { services } = await BluetoothLowEnergy.getServices({ deviceId: 'AA:BB:CC:DD:EE:FF' });
205
+ * ```
206
+ */
207
+ getServices(options: GetServicesOptions): Promise<GetServicesResult>;
208
+ /**
209
+ * Get a list of connected devices.
210
+ *
211
+ * @returns Promise that resolves with connected devices
212
+ * @since 1.0.0
213
+ * @example
214
+ * ```typescript
215
+ * const { devices } = await BluetoothLowEnergy.getConnectedDevices();
216
+ * ```
217
+ */
218
+ getConnectedDevices(): Promise<GetConnectedDevicesResult>;
219
+ /**
220
+ * Read a characteristic value.
221
+ *
222
+ * @param options - Read options
223
+ * @returns Promise that resolves with the characteristic value
224
+ * @since 1.0.0
225
+ * @example
226
+ * ```typescript
227
+ * const { value } = await BluetoothLowEnergy.readCharacteristic({
228
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
229
+ * service: '180D',
230
+ * characteristic: '2A37'
231
+ * });
232
+ * ```
233
+ */
234
+ readCharacteristic(options: ReadCharacteristicOptions): Promise<ReadCharacteristicResult>;
235
+ /**
236
+ * Write a value to a characteristic.
237
+ *
238
+ * @param options - Write options
239
+ * @returns Promise that resolves when write is complete
240
+ * @since 1.0.0
241
+ * @example
242
+ * ```typescript
243
+ * await BluetoothLowEnergy.writeCharacteristic({
244
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
245
+ * service: '180D',
246
+ * characteristic: '2A39',
247
+ * value: [0x01]
248
+ * });
249
+ * ```
250
+ */
251
+ writeCharacteristic(options: WriteCharacteristicOptions): Promise<void>;
252
+ /**
253
+ * Start notifications for a characteristic.
254
+ *
255
+ * @param options - Notification options
256
+ * @returns Promise that resolves when notifications start
257
+ * @since 1.0.0
258
+ * @example
259
+ * ```typescript
260
+ * await BluetoothLowEnergy.startCharacteristicNotifications({
261
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
262
+ * service: '180D',
263
+ * characteristic: '2A37'
264
+ * });
265
+ * ```
266
+ */
267
+ startCharacteristicNotifications(options: StartCharacteristicNotificationsOptions): Promise<void>;
268
+ /**
269
+ * Stop notifications for a characteristic.
270
+ *
271
+ * @param options - Stop notification options
272
+ * @returns Promise that resolves when notifications stop
273
+ * @since 1.0.0
274
+ * @example
275
+ * ```typescript
276
+ * await BluetoothLowEnergy.stopCharacteristicNotifications({
277
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
278
+ * service: '180D',
279
+ * characteristic: '2A37'
280
+ * });
281
+ * ```
282
+ */
283
+ stopCharacteristicNotifications(options: StopCharacteristicNotificationsOptions): Promise<void>;
284
+ /**
285
+ * Read a descriptor value.
286
+ *
287
+ * @param options - Read descriptor options
288
+ * @returns Promise that resolves with the descriptor value
289
+ * @since 1.0.0
290
+ * @example
291
+ * ```typescript
292
+ * const { value } = await BluetoothLowEnergy.readDescriptor({
293
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
294
+ * service: '180D',
295
+ * characteristic: '2A37',
296
+ * descriptor: '2902'
297
+ * });
298
+ * ```
299
+ */
300
+ readDescriptor(options: ReadDescriptorOptions): Promise<ReadDescriptorResult>;
301
+ /**
302
+ * Write a value to a descriptor.
303
+ *
304
+ * @param options - Write descriptor options
305
+ * @returns Promise that resolves when write is complete
306
+ * @since 1.0.0
307
+ * @example
308
+ * ```typescript
309
+ * await BluetoothLowEnergy.writeDescriptor({
310
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
311
+ * service: '180D',
312
+ * characteristic: '2A37',
313
+ * descriptor: '2902',
314
+ * value: [0x01, 0x00]
315
+ * });
316
+ * ```
317
+ */
318
+ writeDescriptor(options: WriteDescriptorOptions): Promise<void>;
319
+ /**
320
+ * Read the RSSI (signal strength) of a connected device.
321
+ *
322
+ * @param options - Read RSSI options
323
+ * @returns Promise that resolves with the RSSI value
324
+ * @since 1.0.0
325
+ * @example
326
+ * ```typescript
327
+ * const { rssi } = await BluetoothLowEnergy.readRssi({ deviceId: 'AA:BB:CC:DD:EE:FF' });
328
+ * ```
329
+ */
330
+ readRssi(options: ReadRssiOptions): Promise<ReadRssiResult>;
331
+ /**
332
+ * Request MTU size change (Android only).
333
+ *
334
+ * @param options - Request MTU options
335
+ * @returns Promise that resolves with the new MTU value
336
+ * @since 1.0.0
337
+ * @example
338
+ * ```typescript
339
+ * const { mtu } = await BluetoothLowEnergy.requestMtu({
340
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
341
+ * mtu: 512
342
+ * });
343
+ * ```
344
+ */
345
+ requestMtu(options: RequestMtuOptions): Promise<RequestMtuResult>;
346
+ /**
347
+ * Request connection priority (Android only).
348
+ *
349
+ * @param options - Request priority options
350
+ * @returns Promise that resolves when priority is set
351
+ * @since 1.0.0
352
+ * @example
353
+ * ```typescript
354
+ * await BluetoothLowEnergy.requestConnectionPriority({
355
+ * deviceId: 'AA:BB:CC:DD:EE:FF',
356
+ * priority: 'high'
357
+ * });
358
+ * ```
359
+ */
360
+ requestConnectionPriority(options: RequestConnectionPriorityOptions): Promise<void>;
361
+ /**
362
+ * Start advertising as a peripheral (BLE server).
363
+ *
364
+ * @param options - Advertising options
365
+ * @returns Promise that resolves when advertising starts
366
+ * @since 1.0.0
367
+ * @example
368
+ * ```typescript
369
+ * await BluetoothLowEnergy.startAdvertising({
370
+ * name: 'MyDevice',
371
+ * services: ['180D']
372
+ * });
373
+ * ```
374
+ */
375
+ startAdvertising(options: StartAdvertisingOptions): Promise<void>;
376
+ /**
377
+ * Stop advertising.
378
+ *
379
+ * @returns Promise that resolves when advertising stops
380
+ * @since 1.0.0
381
+ * @example
382
+ * ```typescript
383
+ * await BluetoothLowEnergy.stopAdvertising();
384
+ * ```
385
+ */
386
+ stopAdvertising(): Promise<void>;
387
+ /**
388
+ * Start a foreground service to maintain BLE connections in background (Android only).
389
+ *
390
+ * @param options - Foreground service options
391
+ * @returns Promise that resolves when service starts
392
+ * @since 1.0.0
393
+ * @example
394
+ * ```typescript
395
+ * await BluetoothLowEnergy.startForegroundService({
396
+ * title: 'BLE Connection',
397
+ * body: 'Maintaining connection...'
398
+ * });
399
+ * ```
400
+ */
401
+ startForegroundService(options: StartForegroundServiceOptions): Promise<void>;
402
+ /**
403
+ * Stop the foreground service (Android only).
404
+ *
405
+ * @returns Promise that resolves when service stops
406
+ * @since 1.0.0
407
+ * @example
408
+ * ```typescript
409
+ * await BluetoothLowEnergy.stopForegroundService();
410
+ * ```
411
+ */
412
+ stopForegroundService(): Promise<void>;
413
+ /**
414
+ * Get the native Capacitor plugin version.
415
+ *
416
+ * @returns Promise that resolves with the plugin version
417
+ * @since 1.0.0
418
+ * @example
419
+ * ```typescript
420
+ * const { version } = await BluetoothLowEnergy.getPluginVersion();
421
+ * ```
422
+ */
423
+ getPluginVersion(): Promise<GetPluginVersionResult>;
424
+ /**
425
+ * Add a listener for device scanned events.
426
+ *
427
+ * @param eventName - The event name
428
+ * @param listenerFunc - The listener function
429
+ * @returns Promise that resolves with a handle to remove the listener
430
+ * @since 1.0.0
431
+ */
432
+ addListener(eventName: 'deviceScanned', listenerFunc: (event: DeviceScannedEvent) => void): Promise<PluginListenerHandle>;
433
+ /**
434
+ * Add a listener for device connected events.
435
+ *
436
+ * @param eventName - The event name
437
+ * @param listenerFunc - The listener function
438
+ * @returns Promise that resolves with a handle to remove the listener
439
+ * @since 1.0.0
440
+ */
441
+ addListener(eventName: 'deviceConnected', listenerFunc: (event: DeviceConnectedEvent) => void): Promise<PluginListenerHandle>;
442
+ /**
443
+ * Add a listener for device disconnected events.
444
+ *
445
+ * @param eventName - The event name
446
+ * @param listenerFunc - The listener function
447
+ * @returns Promise that resolves with a handle to remove the listener
448
+ * @since 1.0.0
449
+ */
450
+ addListener(eventName: 'deviceDisconnected', listenerFunc: (event: DeviceDisconnectedEvent) => void): Promise<PluginListenerHandle>;
451
+ /**
452
+ * Add a listener for characteristic changed events.
453
+ *
454
+ * @param eventName - The event name
455
+ * @param listenerFunc - The listener function
456
+ * @returns Promise that resolves with a handle to remove the listener
457
+ * @since 1.0.0
458
+ */
459
+ addListener(eventName: 'characteristicChanged', listenerFunc: (event: CharacteristicChangedEvent) => void): Promise<PluginListenerHandle>;
460
+ /**
461
+ * Remove all listeners for this plugin.
462
+ *
463
+ * @returns Promise that resolves when all listeners are removed
464
+ * @since 1.0.0
465
+ */
466
+ removeAllListeners(): Promise<void>;
467
+ }
468
+ /**
469
+ * Initialization options for the plugin.
470
+ *
471
+ * @since 1.0.0
472
+ */
473
+ export interface InitializeOptions {
474
+ /**
475
+ * The mode to initialize the plugin in.
476
+ * - 'central': Act as a BLE central (client)
477
+ * - 'peripheral': Act as a BLE peripheral (server)
478
+ *
479
+ * @default 'central'
480
+ * @since 1.0.0
481
+ */
482
+ mode?: 'central' | 'peripheral';
483
+ }
484
+ /**
485
+ * Result of the isAvailable method.
486
+ *
487
+ * @since 1.0.0
488
+ */
489
+ export interface IsAvailableResult {
490
+ /**
491
+ * Whether Bluetooth is available on the device.
492
+ *
493
+ * @since 1.0.0
494
+ */
495
+ available: boolean;
496
+ }
497
+ /**
498
+ * Result of the isEnabled method.
499
+ *
500
+ * @since 1.0.0
501
+ */
502
+ export interface IsEnabledResult {
503
+ /**
504
+ * Whether Bluetooth is enabled on the device.
505
+ *
506
+ * @since 1.0.0
507
+ */
508
+ enabled: boolean;
509
+ }
510
+ /**
511
+ * Result of the isLocationEnabled method.
512
+ *
513
+ * @since 1.0.0
514
+ */
515
+ export interface IsLocationEnabledResult {
516
+ /**
517
+ * Whether location services are enabled on the device.
518
+ *
519
+ * @since 1.0.0
520
+ */
521
+ enabled: boolean;
522
+ }
523
+ /**
524
+ * Permission status for Bluetooth and location.
525
+ *
526
+ * @since 1.0.0
527
+ */
528
+ export interface PermissionStatus {
529
+ /**
530
+ * Bluetooth permission status.
531
+ *
532
+ * @since 1.0.0
533
+ */
534
+ bluetooth: PermissionState;
535
+ /**
536
+ * Location permission status (Android only).
537
+ *
538
+ * @since 1.0.0
539
+ */
540
+ location: PermissionState;
541
+ }
542
+ /**
543
+ * Permission state values.
544
+ *
545
+ * @since 1.0.0
546
+ */
547
+ export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';
548
+ /**
549
+ * Options for starting a scan.
550
+ *
551
+ * @since 1.0.0
552
+ */
553
+ export interface StartScanOptions {
554
+ /**
555
+ * List of service UUIDs to filter by.
556
+ * Only devices advertising these services will be returned.
557
+ *
558
+ * @since 1.0.0
559
+ */
560
+ services?: string[];
561
+ /**
562
+ * Scan timeout in milliseconds.
563
+ * Set to 0 for no timeout.
564
+ *
565
+ * @default 0
566
+ * @since 1.0.0
567
+ */
568
+ timeout?: number;
569
+ /**
570
+ * Whether to allow duplicate scan results.
571
+ *
572
+ * @default false
573
+ * @since 1.0.0
574
+ */
575
+ allowDuplicates?: boolean;
576
+ }
577
+ /**
578
+ * Options for connecting to a device.
579
+ *
580
+ * @since 1.0.0
581
+ */
582
+ export interface ConnectOptions {
583
+ /**
584
+ * The device ID (MAC address on Android, UUID on iOS).
585
+ *
586
+ * @since 1.0.0
587
+ */
588
+ deviceId: string;
589
+ /**
590
+ * Whether to automatically connect when the device becomes available.
591
+ *
592
+ * @default false
593
+ * @since 1.0.0
594
+ */
595
+ autoConnect?: boolean;
596
+ }
597
+ /**
598
+ * Options for disconnecting from a device.
599
+ *
600
+ * @since 1.0.0
601
+ */
602
+ export interface DisconnectOptions {
603
+ /**
604
+ * The device ID to disconnect from.
605
+ *
606
+ * @since 1.0.0
607
+ */
608
+ deviceId: string;
609
+ }
610
+ /**
611
+ * Options for creating a bond.
612
+ *
613
+ * @since 1.0.0
614
+ */
615
+ export interface CreateBondOptions {
616
+ /**
617
+ * The device ID to bond with.
618
+ *
619
+ * @since 1.0.0
620
+ */
621
+ deviceId: string;
622
+ }
623
+ /**
624
+ * Options for checking bond status.
625
+ *
626
+ * @since 1.0.0
627
+ */
628
+ export interface IsBondedOptions {
629
+ /**
630
+ * The device ID to check.
631
+ *
632
+ * @since 1.0.0
633
+ */
634
+ deviceId: string;
635
+ }
636
+ /**
637
+ * Result of the isBonded method.
638
+ *
639
+ * @since 1.0.0
640
+ */
641
+ export interface IsBondedResult {
642
+ /**
643
+ * Whether the device is bonded.
644
+ *
645
+ * @since 1.0.0
646
+ */
647
+ bonded: boolean;
648
+ }
649
+ /**
650
+ * Options for discovering services.
651
+ *
652
+ * @since 1.0.0
653
+ */
654
+ export interface DiscoverServicesOptions {
655
+ /**
656
+ * The device ID to discover services on.
657
+ *
658
+ * @since 1.0.0
659
+ */
660
+ deviceId: string;
661
+ }
662
+ /**
663
+ * Options for getting services.
664
+ *
665
+ * @since 1.0.0
666
+ */
667
+ export interface GetServicesOptions {
668
+ /**
669
+ * The device ID to get services for.
670
+ *
671
+ * @since 1.0.0
672
+ */
673
+ deviceId: string;
674
+ }
675
+ /**
676
+ * Result of the getServices method.
677
+ *
678
+ * @since 1.0.0
679
+ */
680
+ export interface GetServicesResult {
681
+ /**
682
+ * List of discovered services.
683
+ *
684
+ * @since 1.0.0
685
+ */
686
+ services: BleService[];
687
+ }
688
+ /**
689
+ * A BLE service.
690
+ *
691
+ * @since 1.0.0
692
+ */
693
+ export interface BleService {
694
+ /**
695
+ * The service UUID.
696
+ *
697
+ * @since 1.0.0
698
+ */
699
+ uuid: string;
700
+ /**
701
+ * List of characteristics in this service.
702
+ *
703
+ * @since 1.0.0
704
+ */
705
+ characteristics: BleCharacteristic[];
706
+ }
707
+ /**
708
+ * A BLE characteristic.
709
+ *
710
+ * @since 1.0.0
711
+ */
712
+ export interface BleCharacteristic {
713
+ /**
714
+ * The characteristic UUID.
715
+ *
716
+ * @since 1.0.0
717
+ */
718
+ uuid: string;
719
+ /**
720
+ * Properties of this characteristic.
721
+ *
722
+ * @since 1.0.0
723
+ */
724
+ properties: CharacteristicProperties;
725
+ /**
726
+ * List of descriptors in this characteristic.
727
+ *
728
+ * @since 1.0.0
729
+ */
730
+ descriptors: BleDescriptor[];
731
+ }
732
+ /**
733
+ * Properties of a BLE characteristic.
734
+ *
735
+ * @since 1.0.0
736
+ */
737
+ export interface CharacteristicProperties {
738
+ /**
739
+ * Whether the characteristic supports broadcast.
740
+ *
741
+ * @since 1.0.0
742
+ */
743
+ broadcast: boolean;
744
+ /**
745
+ * Whether the characteristic supports read.
746
+ *
747
+ * @since 1.0.0
748
+ */
749
+ read: boolean;
750
+ /**
751
+ * Whether the characteristic supports write without response.
752
+ *
753
+ * @since 1.0.0
754
+ */
755
+ writeWithoutResponse: boolean;
756
+ /**
757
+ * Whether the characteristic supports write.
758
+ *
759
+ * @since 1.0.0
760
+ */
761
+ write: boolean;
762
+ /**
763
+ * Whether the characteristic supports notify.
764
+ *
765
+ * @since 1.0.0
766
+ */
767
+ notify: boolean;
768
+ /**
769
+ * Whether the characteristic supports indicate.
770
+ *
771
+ * @since 1.0.0
772
+ */
773
+ indicate: boolean;
774
+ /**
775
+ * Whether the characteristic supports authenticated signed writes.
776
+ *
777
+ * @since 1.0.0
778
+ */
779
+ authenticatedSignedWrites: boolean;
780
+ /**
781
+ * Whether the characteristic has extended properties.
782
+ *
783
+ * @since 1.0.0
784
+ */
785
+ extendedProperties: boolean;
786
+ }
787
+ /**
788
+ * A BLE descriptor.
789
+ *
790
+ * @since 1.0.0
791
+ */
792
+ export interface BleDescriptor {
793
+ /**
794
+ * The descriptor UUID.
795
+ *
796
+ * @since 1.0.0
797
+ */
798
+ uuid: string;
799
+ }
800
+ /**
801
+ * Result of the getConnectedDevices method.
802
+ *
803
+ * @since 1.0.0
804
+ */
805
+ export interface GetConnectedDevicesResult {
806
+ /**
807
+ * List of connected devices.
808
+ *
809
+ * @since 1.0.0
810
+ */
811
+ devices: BleDevice[];
812
+ }
813
+ /**
814
+ * A BLE device.
815
+ *
816
+ * @since 1.0.0
817
+ */
818
+ export interface BleDevice {
819
+ /**
820
+ * The device ID (MAC address on Android, UUID on iOS).
821
+ *
822
+ * @since 1.0.0
823
+ */
824
+ deviceId: string;
825
+ /**
826
+ * The device name (may be null if not available).
827
+ *
828
+ * @since 1.0.0
829
+ */
830
+ name: string | null;
831
+ /**
832
+ * The RSSI (signal strength) at time of discovery.
833
+ *
834
+ * @since 1.0.0
835
+ */
836
+ rssi?: number;
837
+ /**
838
+ * Manufacturer data from advertisement (as hex string).
839
+ *
840
+ * @since 1.0.0
841
+ */
842
+ manufacturerData?: string;
843
+ /**
844
+ * Service UUIDs advertised by the device.
845
+ *
846
+ * @since 1.0.0
847
+ */
848
+ serviceUuids?: string[];
849
+ }
850
+ /**
851
+ * Options for reading a characteristic.
852
+ *
853
+ * @since 1.0.0
854
+ */
855
+ export interface ReadCharacteristicOptions {
856
+ /**
857
+ * The device ID.
858
+ *
859
+ * @since 1.0.0
860
+ */
861
+ deviceId: string;
862
+ /**
863
+ * The service UUID.
864
+ *
865
+ * @since 1.0.0
866
+ */
867
+ service: string;
868
+ /**
869
+ * The characteristic UUID.
870
+ *
871
+ * @since 1.0.0
872
+ */
873
+ characteristic: string;
874
+ }
875
+ /**
876
+ * Result of reading a characteristic.
877
+ *
878
+ * @since 1.0.0
879
+ */
880
+ export interface ReadCharacteristicResult {
881
+ /**
882
+ * The characteristic value as an array of bytes.
883
+ *
884
+ * @since 1.0.0
885
+ */
886
+ value: number[];
887
+ }
888
+ /**
889
+ * Options for writing to a characteristic.
890
+ *
891
+ * @since 1.0.0
892
+ */
893
+ export interface WriteCharacteristicOptions {
894
+ /**
895
+ * The device ID.
896
+ *
897
+ * @since 1.0.0
898
+ */
899
+ deviceId: string;
900
+ /**
901
+ * The service UUID.
902
+ *
903
+ * @since 1.0.0
904
+ */
905
+ service: string;
906
+ /**
907
+ * The characteristic UUID.
908
+ *
909
+ * @since 1.0.0
910
+ */
911
+ characteristic: string;
912
+ /**
913
+ * The value to write as an array of bytes.
914
+ *
915
+ * @since 1.0.0
916
+ */
917
+ value: number[];
918
+ /**
919
+ * Write type.
920
+ *
921
+ * @default 'withResponse'
922
+ * @since 1.0.0
923
+ */
924
+ type?: 'withResponse' | 'withoutResponse';
925
+ }
926
+ /**
927
+ * Options for starting characteristic notifications.
928
+ *
929
+ * @since 1.0.0
930
+ */
931
+ export interface StartCharacteristicNotificationsOptions {
932
+ /**
933
+ * The device ID.
934
+ *
935
+ * @since 1.0.0
936
+ */
937
+ deviceId: string;
938
+ /**
939
+ * The service UUID.
940
+ *
941
+ * @since 1.0.0
942
+ */
943
+ service: string;
944
+ /**
945
+ * The characteristic UUID.
946
+ *
947
+ * @since 1.0.0
948
+ */
949
+ characteristic: string;
950
+ }
951
+ /**
952
+ * Options for stopping characteristic notifications.
953
+ *
954
+ * @since 1.0.0
955
+ */
956
+ export interface StopCharacteristicNotificationsOptions {
957
+ /**
958
+ * The device ID.
959
+ *
960
+ * @since 1.0.0
961
+ */
962
+ deviceId: string;
963
+ /**
964
+ * The service UUID.
965
+ *
966
+ * @since 1.0.0
967
+ */
968
+ service: string;
969
+ /**
970
+ * The characteristic UUID.
971
+ *
972
+ * @since 1.0.0
973
+ */
974
+ characteristic: string;
975
+ }
976
+ /**
977
+ * Options for reading a descriptor.
978
+ *
979
+ * @since 1.0.0
980
+ */
981
+ export interface ReadDescriptorOptions {
982
+ /**
983
+ * The device ID.
984
+ *
985
+ * @since 1.0.0
986
+ */
987
+ deviceId: string;
988
+ /**
989
+ * The service UUID.
990
+ *
991
+ * @since 1.0.0
992
+ */
993
+ service: string;
994
+ /**
995
+ * The characteristic UUID.
996
+ *
997
+ * @since 1.0.0
998
+ */
999
+ characteristic: string;
1000
+ /**
1001
+ * The descriptor UUID.
1002
+ *
1003
+ * @since 1.0.0
1004
+ */
1005
+ descriptor: string;
1006
+ }
1007
+ /**
1008
+ * Result of reading a descriptor.
1009
+ *
1010
+ * @since 1.0.0
1011
+ */
1012
+ export interface ReadDescriptorResult {
1013
+ /**
1014
+ * The descriptor value as an array of bytes.
1015
+ *
1016
+ * @since 1.0.0
1017
+ */
1018
+ value: number[];
1019
+ }
1020
+ /**
1021
+ * Options for writing to a descriptor.
1022
+ *
1023
+ * @since 1.0.0
1024
+ */
1025
+ export interface WriteDescriptorOptions {
1026
+ /**
1027
+ * The device ID.
1028
+ *
1029
+ * @since 1.0.0
1030
+ */
1031
+ deviceId: string;
1032
+ /**
1033
+ * The service UUID.
1034
+ *
1035
+ * @since 1.0.0
1036
+ */
1037
+ service: string;
1038
+ /**
1039
+ * The characteristic UUID.
1040
+ *
1041
+ * @since 1.0.0
1042
+ */
1043
+ characteristic: string;
1044
+ /**
1045
+ * The descriptor UUID.
1046
+ *
1047
+ * @since 1.0.0
1048
+ */
1049
+ descriptor: string;
1050
+ /**
1051
+ * The value to write as an array of bytes.
1052
+ *
1053
+ * @since 1.0.0
1054
+ */
1055
+ value: number[];
1056
+ }
1057
+ /**
1058
+ * Options for reading RSSI.
1059
+ *
1060
+ * @since 1.0.0
1061
+ */
1062
+ export interface ReadRssiOptions {
1063
+ /**
1064
+ * The device ID.
1065
+ *
1066
+ * @since 1.0.0
1067
+ */
1068
+ deviceId: string;
1069
+ }
1070
+ /**
1071
+ * Result of reading RSSI.
1072
+ *
1073
+ * @since 1.0.0
1074
+ */
1075
+ export interface ReadRssiResult {
1076
+ /**
1077
+ * The RSSI value in dBm.
1078
+ *
1079
+ * @since 1.0.0
1080
+ */
1081
+ rssi: number;
1082
+ }
1083
+ /**
1084
+ * Options for requesting MTU.
1085
+ *
1086
+ * @since 1.0.0
1087
+ */
1088
+ export interface RequestMtuOptions {
1089
+ /**
1090
+ * The device ID.
1091
+ *
1092
+ * @since 1.0.0
1093
+ */
1094
+ deviceId: string;
1095
+ /**
1096
+ * The requested MTU size.
1097
+ *
1098
+ * @since 1.0.0
1099
+ */
1100
+ mtu: number;
1101
+ }
1102
+ /**
1103
+ * Result of requesting MTU.
1104
+ *
1105
+ * @since 1.0.0
1106
+ */
1107
+ export interface RequestMtuResult {
1108
+ /**
1109
+ * The negotiated MTU size.
1110
+ *
1111
+ * @since 1.0.0
1112
+ */
1113
+ mtu: number;
1114
+ }
1115
+ /**
1116
+ * Options for requesting connection priority.
1117
+ *
1118
+ * @since 1.0.0
1119
+ */
1120
+ export interface RequestConnectionPriorityOptions {
1121
+ /**
1122
+ * The device ID.
1123
+ *
1124
+ * @since 1.0.0
1125
+ */
1126
+ deviceId: string;
1127
+ /**
1128
+ * The requested connection priority.
1129
+ *
1130
+ * @since 1.0.0
1131
+ */
1132
+ priority: 'low' | 'balanced' | 'high';
1133
+ }
1134
+ /**
1135
+ * Options for starting advertising.
1136
+ *
1137
+ * @since 1.0.0
1138
+ */
1139
+ export interface StartAdvertisingOptions {
1140
+ /**
1141
+ * The device name to advertise.
1142
+ *
1143
+ * @since 1.0.0
1144
+ */
1145
+ name?: string;
1146
+ /**
1147
+ * Service UUIDs to advertise.
1148
+ *
1149
+ * @since 1.0.0
1150
+ */
1151
+ services?: string[];
1152
+ /**
1153
+ * Whether to include the device name in the advertisement.
1154
+ *
1155
+ * @default true
1156
+ * @since 1.0.0
1157
+ */
1158
+ includeName?: boolean;
1159
+ /**
1160
+ * Whether to include TX power level in the advertisement.
1161
+ *
1162
+ * @default false
1163
+ * @since 1.0.0
1164
+ */
1165
+ includeTxPowerLevel?: boolean;
1166
+ }
1167
+ /**
1168
+ * Options for starting the foreground service.
1169
+ *
1170
+ * @since 1.0.0
1171
+ */
1172
+ export interface StartForegroundServiceOptions {
1173
+ /**
1174
+ * The notification title.
1175
+ *
1176
+ * @since 1.0.0
1177
+ */
1178
+ title: string;
1179
+ /**
1180
+ * The notification body.
1181
+ *
1182
+ * @since 1.0.0
1183
+ */
1184
+ body: string;
1185
+ /**
1186
+ * The notification small icon resource name.
1187
+ *
1188
+ * @since 1.0.0
1189
+ */
1190
+ smallIcon?: string;
1191
+ }
1192
+ /**
1193
+ * Result of getPluginVersion.
1194
+ *
1195
+ * @since 1.0.0
1196
+ */
1197
+ export interface GetPluginVersionResult {
1198
+ /**
1199
+ * The plugin version.
1200
+ *
1201
+ * @since 1.0.0
1202
+ */
1203
+ version: string;
1204
+ }
1205
+ /**
1206
+ * Event emitted when a device is scanned.
1207
+ *
1208
+ * @since 1.0.0
1209
+ */
1210
+ export interface DeviceScannedEvent {
1211
+ /**
1212
+ * The scanned device.
1213
+ *
1214
+ * @since 1.0.0
1215
+ */
1216
+ device: BleDevice;
1217
+ }
1218
+ /**
1219
+ * Event emitted when a device is connected.
1220
+ *
1221
+ * @since 1.0.0
1222
+ */
1223
+ export interface DeviceConnectedEvent {
1224
+ /**
1225
+ * The device ID.
1226
+ *
1227
+ * @since 1.0.0
1228
+ */
1229
+ deviceId: string;
1230
+ }
1231
+ /**
1232
+ * Event emitted when a device is disconnected.
1233
+ *
1234
+ * @since 1.0.0
1235
+ */
1236
+ export interface DeviceDisconnectedEvent {
1237
+ /**
1238
+ * The device ID.
1239
+ *
1240
+ * @since 1.0.0
1241
+ */
1242
+ deviceId: string;
1243
+ }
1244
+ /**
1245
+ * Event emitted when a characteristic value changes.
1246
+ *
1247
+ * @since 1.0.0
1248
+ */
1249
+ export interface CharacteristicChangedEvent {
1250
+ /**
1251
+ * The device ID.
1252
+ *
1253
+ * @since 1.0.0
1254
+ */
1255
+ deviceId: string;
1256
+ /**
1257
+ * The service UUID.
1258
+ *
1259
+ * @since 1.0.0
1260
+ */
1261
+ service: string;
1262
+ /**
1263
+ * The characteristic UUID.
1264
+ *
1265
+ * @since 1.0.0
1266
+ */
1267
+ characteristic: string;
1268
+ /**
1269
+ * The new value as an array of bytes.
1270
+ *
1271
+ * @since 1.0.0
1272
+ */
1273
+ value: number[];
1274
+ }
1275
+ /**
1276
+ * Utility class for BLE operations.
1277
+ *
1278
+ * @since 1.0.0
1279
+ */
1280
+ export declare class BluetoothLowEnergyUtils {
1281
+ /**
1282
+ * Convert a byte array to a hex string.
1283
+ *
1284
+ * @param bytes - The byte array to convert
1285
+ * @returns The hex string
1286
+ * @since 1.0.0
1287
+ * @example
1288
+ * ```typescript
1289
+ * const hex = BluetoothLowEnergyUtils.convertBytesToHex([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
1290
+ * console.log(hex); // "48656c6c6f"
1291
+ * ```
1292
+ */
1293
+ static convertBytesToHex(bytes: number[]): string;
1294
+ /**
1295
+ * Convert a hex string to a byte array.
1296
+ *
1297
+ * @param hex - The hex string to convert
1298
+ * @returns The byte array
1299
+ * @since 1.0.0
1300
+ * @example
1301
+ * ```typescript
1302
+ * const bytes = BluetoothLowEnergyUtils.convertHexToBytes("48656c6c6f");
1303
+ * console.log(bytes); // [72, 101, 108, 108, 111]
1304
+ * ```
1305
+ */
1306
+ static convertHexToBytes(hex: string): number[];
1307
+ /**
1308
+ * Convert a string to a byte array (UTF-8).
1309
+ *
1310
+ * @param str - The string to convert
1311
+ * @returns The byte array
1312
+ * @since 1.0.0
1313
+ * @example
1314
+ * ```typescript
1315
+ * const bytes = BluetoothLowEnergyUtils.convertStringToBytes("Hello");
1316
+ * console.log(bytes); // [72, 101, 108, 108, 111]
1317
+ * ```
1318
+ */
1319
+ static convertStringToBytes(str: string): number[];
1320
+ /**
1321
+ * Convert a byte array to a string (UTF-8).
1322
+ *
1323
+ * @param bytes - The byte array to convert
1324
+ * @returns The string
1325
+ * @since 1.0.0
1326
+ * @example
1327
+ * ```typescript
1328
+ * const str = BluetoothLowEnergyUtils.convertBytesToString([72, 101, 108, 108, 111]);
1329
+ * console.log(str); // "Hello"
1330
+ * ```
1331
+ */
1332
+ static convertBytesToString(bytes: number[]): string;
1333
+ }