@capgo/capacitor-bluetooth-low-energy 8.1.7 → 8.2.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 +262 -0
- package/android/src/main/java/ee/forgr/plugin/bluetooth_low_energy/BluetoothLowEnergyPlugin.java +366 -1
- package/dist/docs.json +765 -27
- package/dist/esm/definitions.d.ts +300 -0
- package/dist/esm/definitions.js +0 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -1
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +12 -5
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +12 -5
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/BluetoothLowEnergyPlugin/BluetoothLowEnergy.swift +214 -0
- package/ios/Sources/BluetoothLowEnergyPlugin/BluetoothLowEnergyPlugin.swift +103 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -145,6 +145,10 @@ Current native limitation: `requestDevice()` resolves the first matching scanned
|
|
|
145
145
|
* [`requestConnectionPriority(...)`](#requestconnectionpriority)
|
|
146
146
|
* [`startAdvertising(...)`](#startadvertising)
|
|
147
147
|
* [`stopAdvertising()`](#stopadvertising)
|
|
148
|
+
* [`addGattService(...)`](#addgattservice)
|
|
149
|
+
* [`removeGattService(...)`](#removegattservice)
|
|
150
|
+
* [`setGattCharacteristicValue(...)`](#setgattcharacteristicvalue)
|
|
151
|
+
* [`notifyGattCharacteristicChanged(...)`](#notifygattcharacteristicchanged)
|
|
148
152
|
* [`startForegroundService(...)`](#startforegroundservice)
|
|
149
153
|
* [`stopForegroundService()`](#stopforegroundservice)
|
|
150
154
|
* [`getPluginVersion()`](#getpluginversion)
|
|
@@ -152,6 +156,10 @@ Current native limitation: `requestDevice()` resolves the first matching scanned
|
|
|
152
156
|
* [`addListener('deviceConnected', ...)`](#addlistenerdeviceconnected-)
|
|
153
157
|
* [`addListener('deviceDisconnected', ...)`](#addlistenerdevicedisconnected-)
|
|
154
158
|
* [`addListener('characteristicChanged', ...)`](#addlistenercharacteristicchanged-)
|
|
159
|
+
* [`addListener('centralConnected', ...)`](#addlistenercentralconnected-)
|
|
160
|
+
* [`addListener('centralDisconnected', ...)`](#addlistenercentraldisconnected-)
|
|
161
|
+
* [`addListener('gattCharacteristicReadRequest', ...)`](#addlistenergattcharacteristicreadrequest-)
|
|
162
|
+
* [`addListener('gattCharacteristicWriteRequest', ...)`](#addlistenergattcharacteristicwriterequest-)
|
|
155
163
|
* [`removeAllListeners()`](#removealllisteners)
|
|
156
164
|
* [Interfaces](#interfaces)
|
|
157
165
|
* [Type Aliases](#type-aliases)
|
|
@@ -651,6 +659,75 @@ Stop advertising.
|
|
|
651
659
|
--------------------
|
|
652
660
|
|
|
653
661
|
|
|
662
|
+
### addGattService(...)
|
|
663
|
+
|
|
664
|
+
```typescript
|
|
665
|
+
addGattService(options: AddGattServiceOptions) => Promise<void>
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
Add a GATT service with characteristics to the local GATT server.
|
|
669
|
+
Must be called in peripheral mode before starting advertising.
|
|
670
|
+
|
|
671
|
+
| Param | Type | Description |
|
|
672
|
+
| ------------- | ----------------------------------------------------------------------- | ------------------------- |
|
|
673
|
+
| **`options`** | <code><a href="#addgattserviceoptions">AddGattServiceOptions</a></code> | - GATT service definition |
|
|
674
|
+
|
|
675
|
+
**Since:** 8.2.0
|
|
676
|
+
|
|
677
|
+
--------------------
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
### removeGattService(...)
|
|
681
|
+
|
|
682
|
+
```typescript
|
|
683
|
+
removeGattService(options: RemoveGattServiceOptions) => Promise<void>
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
Remove a GATT service from the local GATT server.
|
|
687
|
+
|
|
688
|
+
| Param | Type | Description |
|
|
689
|
+
| ------------- | ----------------------------------------------------------------------------- | ------------------------- |
|
|
690
|
+
| **`options`** | <code><a href="#removegattserviceoptions">RemoveGattServiceOptions</a></code> | - Service removal options |
|
|
691
|
+
|
|
692
|
+
**Since:** 8.2.0
|
|
693
|
+
|
|
694
|
+
--------------------
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
### setGattCharacteristicValue(...)
|
|
698
|
+
|
|
699
|
+
```typescript
|
|
700
|
+
setGattCharacteristicValue(options: SetGattCharacteristicValueOptions) => Promise<void>
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
Set the value of a local GATT characteristic.
|
|
704
|
+
|
|
705
|
+
| Param | Type | Description |
|
|
706
|
+
| ------------- | ----------------------------------------------------------------------------------------------- | ------------------------------ |
|
|
707
|
+
| **`options`** | <code><a href="#setgattcharacteristicvalueoptions">SetGattCharacteristicValueOptions</a></code> | - Characteristic value options |
|
|
708
|
+
|
|
709
|
+
**Since:** 8.2.0
|
|
710
|
+
|
|
711
|
+
--------------------
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
### notifyGattCharacteristicChanged(...)
|
|
715
|
+
|
|
716
|
+
```typescript
|
|
717
|
+
notifyGattCharacteristicChanged(options: NotifyGattCharacteristicChangedOptions) => Promise<void>
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
Notify connected centrals that a local GATT characteristic value changed.
|
|
721
|
+
|
|
722
|
+
| Param | Type | Description |
|
|
723
|
+
| ------------- | --------------------------------------------------------------------------------------------------------- | ---------------------- |
|
|
724
|
+
| **`options`** | <code><a href="#notifygattcharacteristicchangedoptions">NotifyGattCharacteristicChangedOptions</a></code> | - Notification options |
|
|
725
|
+
|
|
726
|
+
**Since:** 8.2.0
|
|
727
|
+
|
|
728
|
+
--------------------
|
|
729
|
+
|
|
730
|
+
|
|
654
731
|
### startForegroundService(...)
|
|
655
732
|
|
|
656
733
|
```typescript
|
|
@@ -776,6 +853,86 @@ Add a listener for characteristic changed events.
|
|
|
776
853
|
--------------------
|
|
777
854
|
|
|
778
855
|
|
|
856
|
+
### addListener('centralConnected', ...)
|
|
857
|
+
|
|
858
|
+
```typescript
|
|
859
|
+
addListener(eventName: 'centralConnected', listenerFunc: (event: CentralConnectedEvent) => void) => Promise<PluginListenerHandle>
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
Add a listener for central connected events (peripheral mode).
|
|
863
|
+
|
|
864
|
+
| Param | Type | Description |
|
|
865
|
+
| ------------------ | ------------------------------------------------------------------------------------------- | ----------------------- |
|
|
866
|
+
| **`eventName`** | <code>'centralConnected'</code> | - The event name |
|
|
867
|
+
| **`listenerFunc`** | <code>(event: <a href="#centralconnectedevent">CentralConnectedEvent</a>) => void</code> | - The listener function |
|
|
868
|
+
|
|
869
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
870
|
+
|
|
871
|
+
**Since:** 8.2.0
|
|
872
|
+
|
|
873
|
+
--------------------
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
### addListener('centralDisconnected', ...)
|
|
877
|
+
|
|
878
|
+
```typescript
|
|
879
|
+
addListener(eventName: 'centralDisconnected', listenerFunc: (event: CentralDisconnectedEvent) => void) => Promise<PluginListenerHandle>
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
Add a listener for central disconnected events (peripheral mode).
|
|
883
|
+
|
|
884
|
+
| Param | Type | Description |
|
|
885
|
+
| ------------------ | ------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
886
|
+
| **`eventName`** | <code>'centralDisconnected'</code> | - The event name |
|
|
887
|
+
| **`listenerFunc`** | <code>(event: <a href="#centraldisconnectedevent">CentralDisconnectedEvent</a>) => void</code> | - The listener function |
|
|
888
|
+
|
|
889
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
890
|
+
|
|
891
|
+
**Since:** 8.2.0
|
|
892
|
+
|
|
893
|
+
--------------------
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
### addListener('gattCharacteristicReadRequest', ...)
|
|
897
|
+
|
|
898
|
+
```typescript
|
|
899
|
+
addListener(eventName: 'gattCharacteristicReadRequest', listenerFunc: (event: GattCharacteristicReadRequestEvent) => void) => Promise<PluginListenerHandle>
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
Add a listener for GATT characteristic read requests (peripheral mode).
|
|
903
|
+
|
|
904
|
+
| Param | Type | Description |
|
|
905
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
906
|
+
| **`eventName`** | <code>'gattCharacteristicReadRequest'</code> | - The event name |
|
|
907
|
+
| **`listenerFunc`** | <code>(event: <a href="#gattcharacteristicreadrequestevent">GattCharacteristicReadRequestEvent</a>) => void</code> | - The listener function |
|
|
908
|
+
|
|
909
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
910
|
+
|
|
911
|
+
**Since:** 8.2.0
|
|
912
|
+
|
|
913
|
+
--------------------
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
### addListener('gattCharacteristicWriteRequest', ...)
|
|
917
|
+
|
|
918
|
+
```typescript
|
|
919
|
+
addListener(eventName: 'gattCharacteristicWriteRequest', listenerFunc: (event: GattCharacteristicWriteRequestEvent) => void) => Promise<PluginListenerHandle>
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
Add a listener for GATT characteristic write requests (peripheral mode).
|
|
923
|
+
|
|
924
|
+
| Param | Type | Description |
|
|
925
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
926
|
+
| **`eventName`** | <code>'gattCharacteristicWriteRequest'</code> | - The event name |
|
|
927
|
+
| **`listenerFunc`** | <code>(event: <a href="#gattcharacteristicwriterequestevent">GattCharacteristicWriteRequestEvent</a>) => void</code> | - The listener function |
|
|
928
|
+
|
|
929
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
930
|
+
|
|
931
|
+
**Since:** 8.2.0
|
|
932
|
+
|
|
933
|
+
--------------------
|
|
934
|
+
|
|
935
|
+
|
|
779
936
|
### removeAllListeners()
|
|
780
937
|
|
|
781
938
|
```typescript
|
|
@@ -1139,6 +1296,70 @@ Options for starting advertising.
|
|
|
1139
1296
|
| **`includeTxPowerLevel`** | <code>boolean</code> | Whether to include TX power level in the advertisement. | <code>false</code> | 1.0.0 |
|
|
1140
1297
|
|
|
1141
1298
|
|
|
1299
|
+
#### AddGattServiceOptions
|
|
1300
|
+
|
|
1301
|
+
Options for adding a GATT service.
|
|
1302
|
+
|
|
1303
|
+
| Prop | Type | Description | Since |
|
|
1304
|
+
| --------------------- | ------------------------------------------- | ------------------------------------------ | ----- |
|
|
1305
|
+
| **`service`** | <code>string</code> | The service UUID. | 8.2.0 |
|
|
1306
|
+
| **`characteristics`** | <code>GattCharacteristicDefinition[]</code> | Characteristics to expose in this service. | 8.2.0 |
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
#### GattCharacteristicDefinition
|
|
1310
|
+
|
|
1311
|
+
A GATT characteristic definition for the local GATT server.
|
|
1312
|
+
|
|
1313
|
+
| Prop | Type | Description | Since |
|
|
1314
|
+
| ----------------- | ----------------------------------------------------------------------------- | --------------------------------------------- | ----- |
|
|
1315
|
+
| **`uuid`** | <code>string</code> | The characteristic UUID. | 8.2.0 |
|
|
1316
|
+
| **`properties`** | <code><a href="#characteristicproperties">CharacteristicProperties</a></code> | Properties of this characteristic. | 8.2.0 |
|
|
1317
|
+
| **`value`** | <code>number[]</code> | Initial value as an array of bytes. | 8.2.0 |
|
|
1318
|
+
| **`descriptors`** | <code>GattDescriptorDefinition[]</code> | Optional descriptors for this characteristic. | 8.2.0 |
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
#### GattDescriptorDefinition
|
|
1322
|
+
|
|
1323
|
+
A GATT descriptor definition for the local GATT server.
|
|
1324
|
+
|
|
1325
|
+
| Prop | Type | Description | Since |
|
|
1326
|
+
| ----------- | --------------------- | ----------------------------------- | ----- |
|
|
1327
|
+
| **`uuid`** | <code>string</code> | The descriptor UUID. | 8.2.0 |
|
|
1328
|
+
| **`value`** | <code>number[]</code> | Initial value as an array of bytes. | 8.2.0 |
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
#### RemoveGattServiceOptions
|
|
1332
|
+
|
|
1333
|
+
Options for removing a GATT service.
|
|
1334
|
+
|
|
1335
|
+
| Prop | Type | Description | Since |
|
|
1336
|
+
| ------------- | ------------------- | ----------------- | ----- |
|
|
1337
|
+
| **`service`** | <code>string</code> | The service UUID. | 8.2.0 |
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
#### SetGattCharacteristicValueOptions
|
|
1341
|
+
|
|
1342
|
+
Options for setting a local GATT characteristic value.
|
|
1343
|
+
|
|
1344
|
+
| Prop | Type | Description | Since |
|
|
1345
|
+
| -------------------- | --------------------- | ------------------------------- | ----- |
|
|
1346
|
+
| **`service`** | <code>string</code> | The service UUID. | 8.2.0 |
|
|
1347
|
+
| **`characteristic`** | <code>string</code> | The characteristic UUID. | 8.2.0 |
|
|
1348
|
+
| **`value`** | <code>number[]</code> | The value as an array of bytes. | 8.2.0 |
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
#### NotifyGattCharacteristicChangedOptions
|
|
1352
|
+
|
|
1353
|
+
Options for notifying connected centrals of a characteristic change.
|
|
1354
|
+
|
|
1355
|
+
| Prop | Type | Description | Since |
|
|
1356
|
+
| -------------------- | --------------------- | ------------------------------------------------------------------------------- | ----- |
|
|
1357
|
+
| **`service`** | <code>string</code> | The service UUID. | 8.2.0 |
|
|
1358
|
+
| **`characteristic`** | <code>string</code> | The characteristic UUID. | 8.2.0 |
|
|
1359
|
+
| **`value`** | <code>number[]</code> | The value as an array of bytes. | 8.2.0 |
|
|
1360
|
+
| **`deviceId`** | <code>string</code> | Optional central device ID. When omitted, all subscribed centrals are notified. | 8.2.0 |
|
|
1361
|
+
|
|
1362
|
+
|
|
1142
1363
|
#### StartForegroundServiceOptions
|
|
1143
1364
|
|
|
1144
1365
|
Options for starting the foreground service.
|
|
@@ -1205,6 +1426,47 @@ Event emitted when a characteristic value changes.
|
|
|
1205
1426
|
| **`value`** | <code>number[]</code> | The new value as an array of bytes. | 1.0.0 |
|
|
1206
1427
|
|
|
1207
1428
|
|
|
1429
|
+
#### CentralConnectedEvent
|
|
1430
|
+
|
|
1431
|
+
Event emitted when a central connects to the local GATT server.
|
|
1432
|
+
|
|
1433
|
+
| Prop | Type | Description | Since |
|
|
1434
|
+
| -------------- | ------------------- | ---------------------- | ----- |
|
|
1435
|
+
| **`deviceId`** | <code>string</code> | The central device ID. | 8.2.0 |
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
#### CentralDisconnectedEvent
|
|
1439
|
+
|
|
1440
|
+
Event emitted when a central disconnects from the local GATT server.
|
|
1441
|
+
|
|
1442
|
+
| Prop | Type | Description | Since |
|
|
1443
|
+
| -------------- | ------------------- | ---------------------- | ----- |
|
|
1444
|
+
| **`deviceId`** | <code>string</code> | The central device ID. | 8.2.0 |
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
#### GattCharacteristicReadRequestEvent
|
|
1448
|
+
|
|
1449
|
+
Event emitted when a central reads a local GATT characteristic.
|
|
1450
|
+
|
|
1451
|
+
| Prop | Type | Description | Since |
|
|
1452
|
+
| -------------------- | ------------------- | ------------------------ | ----- |
|
|
1453
|
+
| **`deviceId`** | <code>string</code> | The central device ID. | 8.2.0 |
|
|
1454
|
+
| **`service`** | <code>string</code> | The service UUID. | 8.2.0 |
|
|
1455
|
+
| **`characteristic`** | <code>string</code> | The characteristic UUID. | 8.2.0 |
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
#### GattCharacteristicWriteRequestEvent
|
|
1459
|
+
|
|
1460
|
+
Event emitted when a central writes to a local GATT characteristic.
|
|
1461
|
+
|
|
1462
|
+
| Prop | Type | Description | Since |
|
|
1463
|
+
| -------------------- | --------------------- | --------------------------------------- | ----- |
|
|
1464
|
+
| **`deviceId`** | <code>string</code> | The central device ID. | 8.2.0 |
|
|
1465
|
+
| **`service`** | <code>string</code> | The service UUID. | 8.2.0 |
|
|
1466
|
+
| **`characteristic`** | <code>string</code> | The characteristic UUID. | 8.2.0 |
|
|
1467
|
+
| **`value`** | <code>number[]</code> | The written value as an array of bytes. | 8.2.0 |
|
|
1468
|
+
|
|
1469
|
+
|
|
1208
1470
|
### Type Aliases
|
|
1209
1471
|
|
|
1210
1472
|
|