@capacitor-community/bluetooth-le 7.3.0 → 7.3.1

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/dist/docs.json CHANGED
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "returns": "Promise<void>",
19
19
  "tags": [],
20
- "docs": "Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\nOn **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\nFor an example, see [usage](#usage).",
20
+ "docs": "Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\r\nOn **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\r\nFor an example, see [usage](#usage).",
21
21
  "complexTypes": [
22
22
  "InitializeOptions"
23
23
  ],
@@ -29,7 +29,7 @@
29
29
  "parameters": [],
30
30
  "returns": "Promise<boolean>",
31
31
  "tags": [],
32
- "docs": "Reports whether Bluetooth is enabled on this device.\nAlways returns `true` on **web**.",
32
+ "docs": "Reports whether Bluetooth is enabled on this device.\r\nAlways returns `true` on **web**.",
33
33
  "complexTypes": [],
34
34
  "slug": "isenabled"
35
35
  },
@@ -39,7 +39,7 @@
39
39
  "parameters": [],
40
40
  "returns": "Promise<void>",
41
41
  "tags": [],
42
- "docs": "Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE\nOnly available on **Android**.",
42
+ "docs": "Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE\r\nOnly available on **Android**.",
43
43
  "complexTypes": [],
44
44
  "slug": "requestenable"
45
45
  },
@@ -54,7 +54,7 @@
54
54
  "text": "Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()"
55
55
  }
56
56
  ],
57
- "docs": "Enable Bluetooth.\nOnly available on **Android**.\n**Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()",
57
+ "docs": "Enable Bluetooth.\r\nOnly available on **Android**.\r\n**Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()",
58
58
  "complexTypes": [],
59
59
  "slug": "enable"
60
60
  },
@@ -69,7 +69,7 @@
69
69
  "text": "Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()"
70
70
  }
71
71
  ],
72
- "docs": "Disable Bluetooth.\nOnly available on **Android**.\n**Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()",
72
+ "docs": "Disable Bluetooth.\r\nOnly available on **Android**.\r\n**Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()",
73
73
  "complexTypes": [],
74
74
  "slug": "disable"
75
75
  },
@@ -90,7 +90,7 @@
90
90
  "text": "callback Callback function to use when the Bluetooth state changes."
91
91
  }
92
92
  ],
93
- "docs": "Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\nNot available on **web** (the callback will never be invoked).",
93
+ "docs": "Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\r\nNot available on **web** (the callback will never be invoked).",
94
94
  "complexTypes": [],
95
95
  "slug": "startenablednotifications"
96
96
  },
@@ -110,7 +110,7 @@
110
110
  "parameters": [],
111
111
  "returns": "Promise<boolean>",
112
112
  "tags": [],
113
- "docs": "Reports whether Location Services are enabled on this device.\nOnly available on **Android**.",
113
+ "docs": "Reports whether Location Services are enabled on this device.\r\nOnly available on **Android**.",
114
114
  "complexTypes": [],
115
115
  "slug": "islocationenabled"
116
116
  },
@@ -120,7 +120,7 @@
120
120
  "parameters": [],
121
121
  "returns": "Promise<void>",
122
122
  "tags": [],
123
- "docs": "Open Location settings.\nOnly available on **Android**.",
123
+ "docs": "Open Location settings.\r\nOnly available on **Android**.",
124
124
  "complexTypes": [],
125
125
  "slug": "openlocationsettings"
126
126
  },
@@ -130,7 +130,7 @@
130
130
  "parameters": [],
131
131
  "returns": "Promise<void>",
132
132
  "tags": [],
133
- "docs": "Open Bluetooth settings.\nOnly available on **Android**.",
133
+ "docs": "Open Bluetooth settings.\r\nOnly available on **Android**.",
134
134
  "complexTypes": [],
135
135
  "slug": "openbluetoothsettings"
136
136
  },
@@ -140,7 +140,7 @@
140
140
  "parameters": [],
141
141
  "returns": "Promise<void>",
142
142
  "tags": [],
143
- "docs": "Open App settings.\nNot available on **web**.\nOn **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\nto request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\nfor the app to be able use it.",
143
+ "docs": "Open App settings.\r\nNot available on **web**.\r\nOn **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\r\nto request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\r\nfor the app to be able use it.",
144
144
  "complexTypes": [],
145
145
  "slug": "openappsettings"
146
146
  },
@@ -184,7 +184,7 @@
184
184
  "text": "options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)"
185
185
  }
186
186
  ],
187
- "docs": "Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\nFor an example, see [usage](#usage).",
187
+ "docs": "Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\r\nFor an example, see [usage](#usage).",
188
188
  "complexTypes": [
189
189
  "BleDevice",
190
190
  "RequestBleDeviceOptions"
@@ -217,7 +217,7 @@
217
217
  "text": "callback"
218
218
  }
219
219
  ],
220
- "docs": "Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\nScanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\n**Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.",
220
+ "docs": "Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\r\nScanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\r\n**Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.",
221
221
  "complexTypes": [
222
222
  "RequestBleDeviceOptions",
223
223
  "ScanResult"
@@ -251,7 +251,7 @@
251
251
  "text": "deviceIds List of device IDs, e.g. saved from a previous app run."
252
252
  }
253
253
  ],
254
- "docs": "On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\nUses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and\n[getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\nOn Android, you can directly connect to the device with the deviceId.",
254
+ "docs": "On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\r\nUses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and\r\n[getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\r\nOn Android, you can directly connect to the device with the deviceId.",
255
255
  "complexTypes": [
256
256
  "BleDevice"
257
257
  ],
@@ -263,7 +263,7 @@
263
263
  "parameters": [],
264
264
  "returns": "Promise<BleDevice[]>",
265
265
  "tags": [],
266
- "docs": "Get a list of currently bonded devices.\nOnly available on **Android**.\nUses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android",
266
+ "docs": "Get a list of currently bonded devices.\r\nOnly available on **Android**.\r\nUses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android",
267
267
  "complexTypes": [
268
268
  "BleDevice"
269
269
  ],
@@ -286,7 +286,7 @@
286
286
  "text": "services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS."
287
287
  }
288
288
  ],
289
- "docs": "Get a list of currently connected devices.\nUses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,\n[getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android\nand [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.",
289
+ "docs": "Get a list of currently connected devices.\r\nUses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,\r\n[getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android\r\nand [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.",
290
290
  "complexTypes": [
291
291
  "BleDevice"
292
292
  ],
@@ -359,7 +359,7 @@
359
359
  "text": "options Options for plugin call"
360
360
  }
361
361
  ],
362
- "docs": "Create a bond with a peripheral BLE device.\nOnly available on **Android**. On iOS bonding is handled by the OS.",
362
+ "docs": "Create a bond with a peripheral BLE device.\r\nOnly available on **Android**. On iOS bonding is handled by the OS.",
363
363
  "complexTypes": [
364
364
  "TimeoutOptions"
365
365
  ],
@@ -382,7 +382,7 @@
382
382
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
383
383
  }
384
384
  ],
385
- "docs": "Report whether a peripheral BLE device is bonded.\nOnly available on **Android**. On iOS bonding is handled by the OS.",
385
+ "docs": "Report whether a peripheral BLE device is bonded.\r\nOnly available on **Android**. On iOS bonding is handled by the OS.",
386
386
  "complexTypes": [],
387
387
  "slug": "isbonded"
388
388
  },
@@ -447,7 +447,7 @@
447
447
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
448
448
  }
449
449
  ],
450
- "docs": "Discover services, characteristics and descriptors of a device.\nYou only need this method if your peripheral device changes its services and characteristics at runtime.\nIf the discovery was successful, the remote services can be retrieved using the getServices function.\nNot available on **web**.",
450
+ "docs": "Discover services, characteristics and descriptors of a device.\r\nYou only need this method if your peripheral device changes its services and characteristics at runtime.\r\nIf the discovery was successful, the remote services can be retrieved using the getServices function.\r\nNot available on **web**.",
451
451
  "complexTypes": [],
452
452
  "slug": "discoverservices"
453
453
  },
@@ -468,7 +468,7 @@
468
468
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
469
469
  }
470
470
  ],
471
- "docs": "Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\nNot available on **web**.",
471
+ "docs": "Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\r\nNot available on **web**.",
472
472
  "complexTypes": [],
473
473
  "slug": "getmtu"
474
474
  },
@@ -498,7 +498,7 @@
498
498
  "text": "connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)"
499
499
  }
500
500
  ],
501
- "docs": "Request a connection parameter update.\nOnly available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)",
501
+ "docs": "Request a connection parameter update.\r\nOnly available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)",
502
502
  "complexTypes": [
503
503
  "ConnectionPriority"
504
504
  ],
@@ -521,7 +521,7 @@
521
521
  "text": "deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))"
522
522
  }
523
523
  ],
524
- "docs": "Read the RSSI value of a connected device.\nNot available on **web**.",
524
+ "docs": "Read the RSSI value of a connected device.\r\nNot available on **web**.",
525
525
  "complexTypes": [],
526
526
  "slug": "readrssi"
527
527
  },
@@ -878,7 +878,7 @@
878
878
  "text": "options Options for plugin call. Timeout not supported on **web**."
879
879
  }
880
880
  ],
881
- "docs": "Start listening to changes of the value of a characteristic.\nNote that you should only start the notifications once per characteristic in your app and share the data and\nnot call `startNotifications` in every component that needs the data.\nFor an example, see [usage](#usage).",
881
+ "docs": "Start listening to changes of the value of a characteristic.\r\nNote that you should only start the notifications once per characteristic in your app and share the data and\r\nnot call `startNotifications` in every component that needs the data.\r\nFor an example, see [usage](#usage).",
882
882
  "complexTypes": [
883
883
  "DataView",
884
884
  "TimeoutOptions"
@@ -943,7 +943,7 @@
943
943
  "name": "default"
944
944
  }
945
945
  ],
946
- "docs": "If your app doesn't use Bluetooth scan results to derive physical\nlocation information, you can strongly assert that your app\ndoesn't derive physical location. (Android only)\nRequires adding 'neverForLocation' to AndroidManifest.xml\nhttps://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location",
946
+ "docs": "If your app doesn't use Bluetooth scan results to derive physical\r\nlocation information, you can strongly assert that your app\r\ndoesn't derive physical location. (Android only)\r\nRequires adding 'neverForLocation' to AndroidManifest.xml\r\nhttps://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location",
947
947
  "complexTypes": [],
948
948
  "type": "boolean | undefined"
949
949
  }
@@ -1048,7 +1048,7 @@
1048
1048
  {
1049
1049
  "name": "deviceId",
1050
1050
  "tags": [],
1051
- "docs": "ID of the device, which will be needed for further calls.\nOn **Android** this is the BLE MAC address.\nOn **iOS** and **web** it is an identifier.",
1051
+ "docs": "ID of the device, which will be needed for further calls.\r\nOn **Android** this is the BLE MAC address.\r\nOn **iOS** and **web** it is an identifier.",
1052
1052
  "complexTypes": [],
1053
1053
  "type": "string"
1054
1054
  },
@@ -1078,7 +1078,7 @@
1078
1078
  {
1079
1079
  "name": "services",
1080
1080
  "tags": [],
1081
- "docs": "Filter devices by service UUIDs.\nUUIDs have to be specified as 128 bit UUID strings,\ne.g. ['0000180d-0000-1000-8000-00805f9b34fb']\nThere is a helper function to convert numbers to UUIDs.\ne.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))",
1081
+ "docs": "Filter devices by service UUIDs.\r\nUUIDs have to be specified as 128 bit UUID strings,\r\ne.g. ['0000180d-0000-1000-8000-00805f9b34fb']\r\nThere is a helper function to convert numbers to UUIDs.\r\ne.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))",
1082
1082
  "complexTypes": [],
1083
1083
  "type": "string[] | undefined"
1084
1084
  },
@@ -1099,14 +1099,14 @@
1099
1099
  {
1100
1100
  "name": "optionalServices",
1101
1101
  "tags": [],
1102
- "docs": "For **web**, all services that will be used have to be listed under services or optionalServices,\ne.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))",
1102
+ "docs": "For **web**, all services that will be used have to be listed under services or optionalServices,\r\ne.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))",
1103
1103
  "complexTypes": [],
1104
1104
  "type": "string[] | undefined"
1105
1105
  },
1106
1106
  {
1107
1107
  "name": "allowDuplicates",
1108
1108
  "tags": [],
1109
- "docs": "Normally scans will discard the second and subsequent advertisements from a single device.\nIf you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\n(default: false)",
1109
+ "docs": "Normally scans will discard the second and subsequent advertisements from a single device.\r\nIf you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\r\n(default: false)",
1110
1110
  "complexTypes": [],
1111
1111
  "type": "boolean | undefined"
1112
1112
  },
@@ -1122,7 +1122,7 @@
1122
1122
  {
1123
1123
  "name": "manufacturerData",
1124
1124
  "tags": [],
1125
- "docs": "Allow scanning for devices with a specific manufacturer data\nhttps://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata",
1125
+ "docs": "Allow scanning for devices with a specific manufacturer data\r\nhttps://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata",
1126
1126
  "complexTypes": [
1127
1127
  "ManufacturerDataFilter"
1128
1128
  ],
@@ -1136,14 +1136,14 @@
1136
1136
  "name": "default"
1137
1137
  }
1138
1138
  ],
1139
- "docs": "Display mode for the device list in `requestDevice` (**iOS** only).\n- `\"alert\"`: Classic alert dialog (default)\n- `\"list\"`: Scrollable list view",
1139
+ "docs": "Display mode for the device list in `requestDevice` (**iOS** only).\r\n- `\"alert\"`: Classic alert dialog (default)\r\n- `\"list\"`: Scrollable list view",
1140
1140
  "complexTypes": [],
1141
1141
  "type": "'alert' | 'list' | undefined"
1142
1142
  },
1143
1143
  {
1144
1144
  "name": "serviceData",
1145
1145
  "tags": [],
1146
- "docs": "Allow scanning for devices with specific service data.\nService data is data associated with a specific service UUID in the advertisement packet.\nUseful for protocols like OpenDroneID, EddyStone, and Open Beacon.",
1146
+ "docs": "Allow scanning for devices with specific service data.\r\nService data is data associated with a specific service UUID in the advertisement packet.\r\nUseful for protocols like OpenDroneID, EddyStone, and Open Beacon.",
1147
1147
  "complexTypes": [
1148
1148
  "ServiceDataFilter"
1149
1149
  ],
@@ -1168,7 +1168,7 @@
1168
1168
  {
1169
1169
  "name": "dataPrefix",
1170
1170
  "tags": [],
1171
- "docs": "Prefix to match in the manufacturer data field.\nOn **Android** this field is mandatory.\nandroid, ios: DataView\nweb: Uint8Array",
1171
+ "docs": "Prefix to match in the manufacturer data field.\r\nOn **Android** this field is mandatory.\r\nandroid, ios: DataView\r\nweb: Uint8Array",
1172
1172
  "complexTypes": [
1173
1173
  "DataView",
1174
1174
  "Uint8Array"
@@ -1178,7 +1178,7 @@
1178
1178
  {
1179
1179
  "name": "mask",
1180
1180
  "tags": [],
1181
- "docs": "Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.\nThe `mask` must have the same length of dataPrefix.\nandroid, ios: DataView\nweb: Uint8Array",
1181
+ "docs": "Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.\r\nThe `mask` must have the same length of dataPrefix.\r\nandroid, ios: DataView\r\nweb: Uint8Array",
1182
1182
  "complexTypes": [
1183
1183
  "DataView",
1184
1184
  "Uint8Array"
@@ -2553,14 +2553,14 @@
2553
2553
  {
2554
2554
  "name": "serviceUuid",
2555
2555
  "tags": [],
2556
- "docs": "Service UUID to filter by. The service data must be associated with this UUID.\nUUIDs have to be specified as 128 bit UUID strings,\ne.g. '0000fffa-0000-1000-8000-00805f9b34fb'",
2556
+ "docs": "Service UUID to filter by. The service data must be associated with this UUID.\r\nUUIDs have to be specified as 128 bit UUID strings,\r\ne.g. '0000fffa-0000-1000-8000-00805f9b34fb'",
2557
2557
  "complexTypes": [],
2558
2558
  "type": "string"
2559
2559
  },
2560
2560
  {
2561
2561
  "name": "dataPrefix",
2562
2562
  "tags": [],
2563
- "docs": "Prefix to match in the service data field.\nFor example, OpenDroneID uses [0x0D] as the advertisement code.\nandroid, ios: string\nweb: DataView",
2563
+ "docs": "Prefix to match in the service data field.\r\nFor example, OpenDroneID uses [0x0D] as the advertisement code.\r\nandroid, ios: string\r\nweb: DataView",
2564
2564
  "complexTypes": [
2565
2565
  "DataView"
2566
2566
  ],
@@ -2569,7 +2569,7 @@
2569
2569
  {
2570
2570
  "name": "mask",
2571
2571
  "tags": [],
2572
- "docs": "Set filter on partial service data. For any bit in the mask, set it to 1 if it needs to match the one in service data, otherwise set it to 0.\nThe `mask` must have the same length as dataPrefix.\nandroid, ios: string\nweb: DataView",
2572
+ "docs": "Set filter on partial service data. For any bit in the mask, set it to 1 if it needs to match the one in service data, otherwise set it to 0.\r\nThe `mask` must have the same length as dataPrefix.\r\nandroid, ios: string\r\nweb: DataView",
2573
2573
  "complexTypes": [
2574
2574
  "DataView"
2575
2575
  ],
@@ -2587,7 +2587,7 @@
2587
2587
  {
2588
2588
  "name": "device",
2589
2589
  "tags": [],
2590
- "docs": "The peripheral device that was found in the scan.\n**Android** and **web**: `device.name` is always identical to `localName`.\n**iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.",
2590
+ "docs": "The peripheral device that was found in the scan.\r\n**Android** and **web**: `device.name` is always identical to `localName`.\r\n**iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.",
2591
2591
  "complexTypes": [
2592
2592
  "BleDevice"
2593
2593
  ],
@@ -2660,7 +2660,7 @@
2660
2660
  {
2661
2661
  "name": "timeout",
2662
2662
  "tags": [],
2663
- "docs": "Timeout in milliseconds for plugin call.\nDefault is 10000 for `connect` and 5000 for other plugin methods.",
2663
+ "docs": "Timeout in milliseconds for plugin call.\r\nDefault is 10000 for `connect` and 5000 for other plugin methods.",
2664
2664
  "complexTypes": [],
2665
2665
  "type": "number | undefined"
2666
2666
  }
@@ -2844,19 +2844,19 @@
2844
2844
  "name": "SCAN_MODE_LOW_POWER",
2845
2845
  "value": "0",
2846
2846
  "tags": [],
2847
- "docs": "Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER"
2847
+ "docs": "Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER"
2848
2848
  },
2849
2849
  {
2850
2850
  "name": "SCAN_MODE_BALANCED",
2851
2851
  "value": "1",
2852
2852
  "tags": [],
2853
- "docs": "Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED"
2853
+ "docs": "Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED"
2854
2854
  },
2855
2855
  {
2856
2856
  "name": "SCAN_MODE_LOW_LATENCY",
2857
2857
  "value": "2",
2858
2858
  "tags": [],
2859
- "docs": "Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY"
2859
+ "docs": "Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\r\nhttps://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY"
2860
2860
  }
2861
2861
  ]
2862
2862
  },
@@ -2868,19 +2868,19 @@
2868
2868
  "name": "CONNECTION_PRIORITY_BALANCED",
2869
2869
  "value": "0",
2870
2870
  "tags": [],
2871
- "docs": "Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED"
2871
+ "docs": "Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.\r\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED"
2872
2872
  },
2873
2873
  {
2874
2874
  "name": "CONNECTION_PRIORITY_HIGH",
2875
2875
  "value": "1",
2876
2876
  "tags": [],
2877
- "docs": "Request a high priority, low latency connection. An application should only request high priority connection parameters to transfer large amounts of data over LE quickly. Once the transfer is complete, the application should request CONNECTION_PRIORITY_BALANCED connection parameters to reduce energy use.\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH"
2877
+ "docs": "Request a high priority, low latency connection. An application should only request high priority connection parameters to transfer large amounts of data over LE quickly. Once the transfer is complete, the application should request CONNECTION_PRIORITY_BALANCED connection parameters to reduce energy use.\r\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH"
2878
2878
  },
2879
2879
  {
2880
2880
  "name": "CONNECTION_PRIORITY_LOW_POWER",
2881
2881
  "value": "2",
2882
2882
  "tags": [],
2883
- "docs": "Request low power, reduced data rate connection parameters.\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER"
2883
+ "docs": "Request low power, reduced data rate connection parameters.\r\nhttps://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER"
2884
2884
  }
2885
2885
  ]
2886
2886
  }
@@ -1 +1 @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AAC,GAA6B;QACjD,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\nimport { Capacitor } from '@capacitor/core';\n\nimport type { DisplayStrings } from './config';\nimport { dataViewToHexString, hexStringToDataView, toUint8Array, toHexString } from './conversion';\nimport type {\n BleDevice,\n BleService,\n ConnectionPriority,\n Data,\n InitializeOptions,\n ReadResult,\n RequestBleDeviceOptions,\n ScanResult,\n ScanResultInternal,\n TimeoutOptions,\n} from './definitions';\nimport { BluetoothLe } from './plugin';\nimport { getQueue } from './queue';\nimport { parseUUID } from './validators';\n\nexport interface BleClientInterface {\n /**\n * Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\n * On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\n * For an example, see [usage](#usage).\n */\n initialize(options?: InitializeOptions): Promise<void>;\n\n /**\n * Reports whether Bluetooth is enabled on this device.\n * Always returns `true` on **web**.\n */\n isEnabled(): Promise<boolean>;\n\n /**\n * Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE\n * Only available on **Android**.*/\n requestEnable(): Promise<void>;\n\n /**\n * Enable Bluetooth.\n * Only available on **Android**.\n * **Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()\n * @deprecated Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()\n */\n enable(): Promise<void>;\n\n /**\n * Disable Bluetooth.\n * Only available on **Android**.\n * **Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()\n * @deprecated Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()\n */\n disable(): Promise<void>;\n\n /**\n * Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\n * Not available on **web** (the callback will never be invoked).\n * @param callback Callback function to use when the Bluetooth state changes.\n */\n startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;\n\n /**\n * Stop the enabled notifications registered with `startEnabledNotifications`.\n */\n stopEnabledNotifications(): Promise<void>;\n\n /**\n * Reports whether Location Services are enabled on this device.\n * Only available on **Android**.\n */\n isLocationEnabled(): Promise<boolean>;\n\n /**\n * Open Location settings.\n * Only available on **Android**.\n */\n openLocationSettings(): Promise<void>;\n\n /**\n * Open Bluetooth settings.\n * Only available on **Android**.\n */\n openBluetoothSettings(): Promise<void>;\n\n /**\n * Open App settings.\n * Not available on **web**.\n * On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\n * to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\n * for the app to be able use it.\n */\n openAppSettings(): Promise<void>;\n\n /**\n * Set the strings that are displayed in the `requestDevice` dialog.\n * @param displayStrings\n */\n setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;\n\n /**\n * Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\n * For an example, see [usage](#usage).\n * @param options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)\n */\n requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;\n\n /**\n * Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\n * Scanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\n * **Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.\n * @param options\n * @param callback\n */\n requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;\n\n /**\n * Stop scanning for BLE devices. For an example, see [usage](#usage).\n */\n stopLEScan(): Promise<void>;\n\n /**\n * On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\n * Uses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and\n * [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\n * On Android, you can directly connect to the device with the deviceId.\n * @param deviceIds List of device IDs, e.g. saved from a previous app run.\n */\n getDevices(deviceIds: string[]): Promise<BleDevice[]>;\n\n /**\n * Get a list of currently bonded devices.\n * Only available on **Android**.\n * Uses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android\n */\n getBondedDevices(): Promise<BleDevice[]>;\n\n /**\n * Get a list of currently connected devices.\n * Uses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,\n * [getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android\n * and [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\n * @param services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS.\n */\n getConnectedDevices(services: string[]): Promise<BleDevice[]>;\n\n /**\n * Connect to a peripheral BLE device. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param onDisconnect Optional disconnect callback function that will be used when the device disconnects\n * @param options Options for plugin call\n */\n connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;\n\n /**\n * Create a bond with a peripheral BLE device.\n * Only available on **Android**. On iOS bonding is handled by the OS.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param options Options for plugin call\n */\n createBond(deviceId: string, options?: TimeoutOptions): Promise<void>;\n\n /**\n * Report whether a peripheral BLE device is bonded.\n * Only available on **Android**. On iOS bonding is handled by the OS.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n isBonded(deviceId: string): Promise<boolean>;\n\n /**\n * Disconnect from a peripheral BLE device. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n disconnect(deviceId: string): Promise<void>;\n\n /**\n * Get services, characteristics and descriptors of a device.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n getServices(deviceId: string): Promise<BleService[]>;\n\n /**\n * Discover services, characteristics and descriptors of a device.\n * You only need this method if your peripheral device changes its services and characteristics at runtime.\n * If the discovery was successful, the remote services can be retrieved using the getServices function.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n discoverServices(deviceId: string): Promise<void>;\n\n /**\n * Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n getMtu(deviceId: string): Promise<number>;\n\n /**\n * Request a connection parameter update.\n * Only available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)\n */\n requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;\n\n /**\n * Read the RSSI value of a connected device.\n * Not available on **web**.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n */\n readRssi(deviceId: string): Promise<number>;\n\n /**\n * Read the value of a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param options Options for plugin call\n */\n read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;\n\n /**\n * Write a value to a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n write(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions,\n ): Promise<void>;\n\n /**\n * Write a value to a characteristic without waiting for a response.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n writeWithoutResponse(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions,\n ): Promise<void>;\n\n /**\n * Read the value of a descriptor.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\n * @param options Options for plugin call\n */\n readDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n options?: TimeoutOptions,\n ): Promise<DataView>;\n\n /**\n * Write a value to a descriptor.\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\n * @param options Options for plugin call\n */\n writeDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n value: DataView,\n options?: TimeoutOptions,\n ): Promise<void>;\n\n /**\n * Start listening to changes of the value of a characteristic.\n * Note that you should only start the notifications once per characteristic in your app and share the data and\n * not call `startNotifications` in every component that needs the data.\n * For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n * @param callback Callback function to use when the value of the characteristic changes\n * @param options Options for plugin call. Timeout not supported on **web**.\n */\n startNotifications(\n deviceId: string,\n service: string,\n characteristic: string,\n callback: (value: DataView) => void,\n options?: TimeoutOptions,\n ): Promise<void>;\n\n /**\n * Stop listening to the changes of the value of a characteristic. For an example, see [usage](#usage).\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\n * @param service UUID of the service (see [UUID format](#uuid-format))\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\n */\n stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;\n}\n\nclass BleClientClass implements BleClientInterface {\n private scanListener: PluginListenerHandle | null = null;\n private eventListeners = new Map<string, PluginListenerHandle>();\n private queue = getQueue(true);\n\n enableQueue() {\n this.queue = getQueue(true);\n }\n\n disableQueue() {\n this.queue = getQueue(false);\n }\n\n async initialize(options?: InitializeOptions): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.initialize(options);\n });\n }\n\n async isEnabled(): Promise<boolean> {\n const enabled = await this.queue(async () => {\n const result = await BluetoothLe.isEnabled();\n return result.value;\n });\n return enabled;\n }\n\n async requestEnable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.requestEnable();\n });\n }\n\n async enable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.enable();\n });\n }\n\n async disable(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.disable();\n });\n }\n\n async startEnabledNotifications(callback: (value: boolean) => void): Promise<void> {\n await this.queue(async () => {\n const key = `onEnabledChanged`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, (result) => {\n callback(result.value);\n });\n this.eventListeners.set(key, listener);\n await BluetoothLe.startEnabledNotifications();\n });\n }\n\n async stopEnabledNotifications(): Promise<void> {\n await this.queue(async () => {\n const key = `onEnabledChanged`;\n await this.eventListeners.get(key)?.remove();\n this.eventListeners.delete(key);\n await BluetoothLe.stopEnabledNotifications();\n });\n }\n\n async isLocationEnabled(): Promise<boolean> {\n const enabled = await this.queue(async () => {\n const result = await BluetoothLe.isLocationEnabled();\n return result.value;\n });\n return enabled;\n }\n\n async openLocationSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openLocationSettings();\n });\n }\n\n async openBluetoothSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openBluetoothSettings();\n });\n }\n\n async openAppSettings(): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.openAppSettings();\n });\n }\n\n async setDisplayStrings(displayStrings: DisplayStrings): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.setDisplayStrings(displayStrings);\n });\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n options = options ? this.validateRequestBleDeviceOptions(options) : undefined;\n const result = await this.queue(async () => {\n const device = await BluetoothLe.requestDevice(options);\n return device;\n });\n return result;\n }\n\n async requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void> {\n options = this.validateRequestBleDeviceOptions(options);\n await this.queue(async () => {\n await this.scanListener?.remove();\n this.scanListener = await BluetoothLe.addListener('onScanResult', (resultInternal: ScanResultInternal) => {\n const result: ScanResult = {\n ...resultInternal,\n manufacturerData: this.convertObject(resultInternal.manufacturerData),\n serviceData: this.convertObject(resultInternal.serviceData),\n rawAdvertisement: resultInternal.rawAdvertisement\n ? this.convertValue(resultInternal.rawAdvertisement)\n : undefined,\n };\n callback(result);\n });\n await BluetoothLe.requestLEScan(options);\n });\n }\n\n async stopLEScan(): Promise<void> {\n await this.queue(async () => {\n await this.scanListener?.remove();\n this.scanListener = null;\n await BluetoothLe.stopLEScan();\n });\n }\n\n async getDevices(deviceIds: string[]): Promise<BleDevice[]> {\n if (!Array.isArray(deviceIds)) {\n throw new Error('deviceIds must be an array');\n }\n return this.queue(async () => {\n const result = await BluetoothLe.getDevices({ deviceIds });\n return result.devices;\n });\n }\n\n async getConnectedDevices(services: string[]): Promise<BleDevice[]> {\n if (!Array.isArray(services)) {\n throw new Error('services must be an array');\n }\n services = services.map(parseUUID);\n return this.queue(async () => {\n const result = await BluetoothLe.getConnectedDevices({ services });\n return result.devices;\n });\n }\n\n async getBondedDevices(): Promise<BleDevice[]> {\n return this.queue(async () => {\n const result = await BluetoothLe.getBondedDevices();\n return result.devices;\n });\n }\n\n async connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void> {\n await this.queue(async () => {\n if (onDisconnect) {\n const key = `disconnected|${deviceId}`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, () => {\n onDisconnect(deviceId);\n });\n this.eventListeners.set(key, listener);\n }\n await BluetoothLe.connect({ deviceId, ...options });\n });\n }\n\n async createBond(deviceId: string, options?: TimeoutOptions): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.createBond({ deviceId, ...options });\n });\n }\n\n async isBonded(deviceId: string): Promise<boolean> {\n const isBonded = await this.queue(async () => {\n const result = await BluetoothLe.isBonded({ deviceId });\n return result.value;\n });\n return isBonded;\n }\n\n async disconnect(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.disconnect({ deviceId });\n });\n }\n\n async getServices(deviceId: string): Promise<BleService[]> {\n const services = await this.queue(async () => {\n const result = await BluetoothLe.getServices({ deviceId });\n return result.services;\n });\n return services;\n }\n\n async discoverServices(deviceId: string): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.discoverServices({ deviceId });\n });\n }\n\n async getMtu(deviceId: string): Promise<number> {\n const value = await this.queue(async () => {\n const result = await BluetoothLe.getMtu({ deviceId });\n return result.value;\n });\n return value;\n }\n\n async requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void> {\n await this.queue(async () => {\n await BluetoothLe.requestConnectionPriority({ deviceId, connectionPriority });\n });\n }\n\n async readRssi(deviceId: string): Promise<number> {\n const value = await this.queue(async () => {\n const result = await BluetoothLe.readRssi({ deviceId });\n return parseFloat(result.value);\n });\n return value;\n }\n\n async read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n const value = await this.queue(async () => {\n const result = await BluetoothLe.read({\n deviceId,\n service,\n characteristic,\n ...options,\n });\n return this.convertValue(result.value);\n });\n return value;\n }\n\n async write(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions,\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n return this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.write({\n deviceId,\n service,\n characteristic,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async writeWithoutResponse(\n deviceId: string,\n service: string,\n characteristic: string,\n value: DataView,\n options?: TimeoutOptions,\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.writeWithoutResponse({\n deviceId,\n service,\n characteristic,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async readDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n options?: TimeoutOptions,\n ): Promise<DataView> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n descriptor = parseUUID(descriptor);\n const value = await this.queue(async () => {\n const result = await BluetoothLe.readDescriptor({\n deviceId,\n service,\n characteristic,\n descriptor,\n ...options,\n });\n return this.convertValue(result.value);\n });\n return value;\n }\n\n async writeDescriptor(\n deviceId: string,\n service: string,\n characteristic: string,\n descriptor: string,\n value: DataView,\n options?: TimeoutOptions,\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n descriptor = parseUUID(descriptor);\n return this.queue(async () => {\n if (!value?.buffer) {\n throw new Error('Invalid data.');\n }\n let writeValue: DataView | string = value;\n if (Capacitor.getPlatform() !== 'web') {\n // on native we can only write strings\n writeValue = dataViewToHexString(value);\n }\n await BluetoothLe.writeDescriptor({\n deviceId,\n service,\n characteristic,\n descriptor,\n value: writeValue,\n ...options,\n });\n });\n }\n\n async startNotifications(\n deviceId: string,\n service: string,\n characteristic: string,\n callback: (value: DataView) => void,\n options?: TimeoutOptions,\n ): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n const key = `notification|${deviceId}|${service}|${characteristic}`;\n await this.eventListeners.get(key)?.remove();\n const listener = await BluetoothLe.addListener(key, (event: ReadResult) => {\n callback(this.convertValue(event?.value));\n });\n this.eventListeners.set(key, listener);\n await BluetoothLe.startNotifications({\n deviceId,\n service,\n characteristic,\n ...options,\n });\n });\n }\n\n async stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void> {\n service = parseUUID(service);\n characteristic = parseUUID(characteristic);\n await this.queue(async () => {\n const key = `notification|${deviceId}|${service}|${characteristic}`;\n await this.eventListeners.get(key)?.remove();\n this.eventListeners.delete(key);\n await BluetoothLe.stopNotifications({\n deviceId,\n service,\n characteristic,\n });\n });\n }\n\n private validateRequestBleDeviceOptions(options: RequestBleDeviceOptions): RequestBleDeviceOptions {\n if (options.services) {\n options.services = options.services.map(parseUUID);\n }\n if (options.optionalServices) {\n options.optionalServices = options.optionalServices.map(parseUUID);\n }\n if (options.serviceData && Capacitor.getPlatform() !== 'web') {\n // Native platforms: convert to hex strings\n options.serviceData = options.serviceData.map((filter) => ({\n ...filter,\n serviceUuid: parseUUID(filter.serviceUuid),\n dataPrefix: toHexString(filter.dataPrefix),\n mask: toHexString(filter.mask),\n })) as any;\n }\n if (options.manufacturerData) {\n if (Capacitor.getPlatform() !== 'web') {\n // Native platforms: convert to hex strings\n options.manufacturerData = options.manufacturerData.map((filter) => ({\n ...filter,\n dataPrefix: toHexString(filter.dataPrefix),\n mask: toHexString(filter.mask),\n })) as any;\n } else {\n // Web platform: convert to Uint8Array for Web Bluetooth API\n options.manufacturerData = options.manufacturerData.map((filter) => ({\n ...filter,\n dataPrefix: toUint8Array(filter.dataPrefix),\n mask: toUint8Array(filter.mask),\n }));\n }\n }\n return options;\n }\n\n private convertValue(value?: Data): DataView {\n if (typeof value === 'string') {\n return hexStringToDataView(value);\n } else if (value === undefined) {\n return new DataView(new ArrayBuffer(0));\n }\n return value;\n }\n\n private convertObject(obj?: { [key: string]: Data }): { [key: string]: DataView } | undefined {\n if (obj === undefined) {\n return undefined;\n }\n const result: { [key: string]: DataView } = {};\n for (const key of Object.keys(obj)) {\n result[key] = this.convertValue(obj[key]);\n }\n return result;\n }\n}\n\nexport const BleClient = new BleClientClass();\n"]}
1
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,GAA6B;QACjD,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,MAAM,GAAgC,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\r\nimport { Capacitor } from '@capacitor/core';\r\n\r\nimport type { DisplayStrings } from './config';\r\nimport { dataViewToHexString, hexStringToDataView, toUint8Array, toHexString } from './conversion';\r\nimport type {\r\n BleDevice,\r\n BleService,\r\n ConnectionPriority,\r\n Data,\r\n InitializeOptions,\r\n ReadResult,\r\n RequestBleDeviceOptions,\r\n ScanResult,\r\n ScanResultInternal,\r\n TimeoutOptions,\r\n} from './definitions';\r\nimport { BluetoothLe } from './plugin';\r\nimport { getQueue } from './queue';\r\nimport { parseUUID } from './validators';\r\n\r\nexport interface BleClientInterface {\r\n /**\r\n * Initialize Bluetooth Low Energy (BLE). If it fails, BLE might be unavailable on this device.\r\n * On **Android** it will ask for the location permission. On **iOS** it will ask for the Bluetooth permission.\r\n * For an example, see [usage](#usage).\r\n */\r\n initialize(options?: InitializeOptions): Promise<void>;\r\n\r\n /**\r\n * Reports whether Bluetooth is enabled on this device.\r\n * Always returns `true` on **web**.\r\n */\r\n isEnabled(): Promise<boolean>;\r\n\r\n /**\r\n * Request enabling Bluetooth. Show a system activity that allows the user to turn on Bluetooth. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#ACTION_REQUEST_ENABLE\r\n * Only available on **Android**.*/\r\n requestEnable(): Promise<void>;\r\n\r\n /**\r\n * Enable Bluetooth.\r\n * Only available on **Android**.\r\n * **Deprecated** Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()\r\n * @deprecated Will fail on Android SDK >= 33. Use `requestEnable` instead. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()\r\n */\r\n enable(): Promise<void>;\r\n\r\n /**\r\n * Disable Bluetooth.\r\n * Only available on **Android**.\r\n * **Deprecated** Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()\r\n * @deprecated Will fail on Android SDK >= 33. See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()\r\n */\r\n disable(): Promise<void>;\r\n\r\n /**\r\n * Register a callback function that will be invoked when Bluetooth is enabled (true) or disabled (false) on this device.\r\n * Not available on **web** (the callback will never be invoked).\r\n * @param callback Callback function to use when the Bluetooth state changes.\r\n */\r\n startEnabledNotifications(callback: (value: boolean) => void): Promise<void>;\r\n\r\n /**\r\n * Stop the enabled notifications registered with `startEnabledNotifications`.\r\n */\r\n stopEnabledNotifications(): Promise<void>;\r\n\r\n /**\r\n * Reports whether Location Services are enabled on this device.\r\n * Only available on **Android**.\r\n */\r\n isLocationEnabled(): Promise<boolean>;\r\n\r\n /**\r\n * Open Location settings.\r\n * Only available on **Android**.\r\n */\r\n openLocationSettings(): Promise<void>;\r\n\r\n /**\r\n * Open Bluetooth settings.\r\n * Only available on **Android**.\r\n */\r\n openBluetoothSettings(): Promise<void>;\r\n\r\n /**\r\n * Open App settings.\r\n * Not available on **web**.\r\n * On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible\r\n * to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings\r\n * for the app to be able use it.\r\n */\r\n openAppSettings(): Promise<void>;\r\n\r\n /**\r\n * Set the strings that are displayed in the `requestDevice` dialog.\r\n * @param displayStrings\r\n */\r\n setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;\r\n\r\n /**\r\n * Request a peripheral BLE device to interact with. This will scan for available devices according to the filters in the options and show a dialog to pick a device.\r\n * For an example, see [usage](#usage).\r\n * @param options Device filters, see [RequestBleDeviceOptions](#RequestBleDeviceOptions)\r\n */\r\n requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;\r\n\r\n /**\r\n * Start scanning for BLE devices to interact with according to the filters in the options. The callback will be invoked on each device that is found.\r\n * Scanning will continue until `stopLEScan` is called. For an example, see [usage](#usage).\r\n * **Note**: Use with care on **web** platform, the required API is still behind a flag in most browsers.\r\n * @param options\r\n * @param callback\r\n */\r\n requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void>;\r\n\r\n /**\r\n * Stop scanning for BLE devices. For an example, see [usage](#usage).\r\n */\r\n stopLEScan(): Promise<void>;\r\n\r\n /**\r\n * On iOS and web, if you want to connect to a previously connected device without scanning first, you can use `getDevice`.\r\n * Uses [retrievePeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipherals) on iOS and\r\n * [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\r\n * On Android, you can directly connect to the device with the deviceId.\r\n * @param deviceIds List of device IDs, e.g. saved from a previous app run.\r\n */\r\n getDevices(deviceIds: string[]): Promise<BleDevice[]>;\r\n\r\n /**\r\n * Get a list of currently bonded devices.\r\n * Only available on **Android**.\r\n * Uses [getBondedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getBondedDevices()) on Android\r\n */\r\n getBondedDevices(): Promise<BleDevice[]>;\r\n\r\n /**\r\n * Get a list of currently connected devices.\r\n * Uses [retrieveConnectedPeripherals](https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals) on iOS,\r\n * [getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int)) on Android\r\n * and [getDevices](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices) on web.\r\n * @param services List of services to filter the devices by. If no service is specified, no devices will be returned. Only applies to iOS.\r\n */\r\n getConnectedDevices(services: string[]): Promise<BleDevice[]>;\r\n\r\n /**\r\n * Connect to a peripheral BLE device. For an example, see [usage](#usage).\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param onDisconnect Optional disconnect callback function that will be used when the device disconnects\r\n * @param options Options for plugin call\r\n */\r\n connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void>;\r\n\r\n /**\r\n * Create a bond with a peripheral BLE device.\r\n * Only available on **Android**. On iOS bonding is handled by the OS.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param options Options for plugin call\r\n */\r\n createBond(deviceId: string, options?: TimeoutOptions): Promise<void>;\r\n\r\n /**\r\n * Report whether a peripheral BLE device is bonded.\r\n * Only available on **Android**. On iOS bonding is handled by the OS.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n */\r\n isBonded(deviceId: string): Promise<boolean>;\r\n\r\n /**\r\n * Disconnect from a peripheral BLE device. For an example, see [usage](#usage).\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n */\r\n disconnect(deviceId: string): Promise<void>;\r\n\r\n /**\r\n * Get services, characteristics and descriptors of a device.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n */\r\n getServices(deviceId: string): Promise<BleService[]>;\r\n\r\n /**\r\n * Discover services, characteristics and descriptors of a device.\r\n * You only need this method if your peripheral device changes its services and characteristics at runtime.\r\n * If the discovery was successful, the remote services can be retrieved using the getServices function.\r\n * Not available on **web**.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n */\r\n discoverServices(deviceId: string): Promise<void>;\r\n\r\n /**\r\n * Get the MTU of a connected device. Note that the maximum write value length is 3 bytes less than the MTU.\r\n * Not available on **web**.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n */\r\n getMtu(deviceId: string): Promise<number>;\r\n\r\n /**\r\n * Request a connection parameter update.\r\n * Only available on **Android**. https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int)\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param connectionPriority Request a specific connection priority. See [ConnectionPriority](#connectionpriority)\r\n */\r\n requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void>;\r\n\r\n /**\r\n * Read the RSSI value of a connected device.\r\n * Not available on **web**.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n */\r\n readRssi(deviceId: string): Promise<number>;\r\n\r\n /**\r\n * Read the value of a characteristic. For an example, see [usage](#usage).\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n * @param options Options for plugin call\r\n */\r\n read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView>;\r\n\r\n /**\r\n * Write a value to a characteristic. For an example, see [usage](#usage).\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\r\n * @param options Options for plugin call\r\n */\r\n write(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n value: DataView,\r\n options?: TimeoutOptions,\r\n ): Promise<void>;\r\n\r\n /**\r\n * Write a value to a characteristic without waiting for a response.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\r\n * @param options Options for plugin call\r\n */\r\n writeWithoutResponse(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n value: DataView,\r\n options?: TimeoutOptions,\r\n ): Promise<void>;\r\n\r\n /**\r\n * Read the value of a descriptor.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\r\n * @param options Options for plugin call\r\n */\r\n readDescriptor(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n descriptor: string,\r\n options?: TimeoutOptions,\r\n ): Promise<DataView>;\r\n\r\n /**\r\n * Write a value to a descriptor.\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n * @param descriptor UUID of the descriptor (see [UUID format](#uuid-format))\r\n * @param value The value to write as a DataView. To create a DataView from an array of numbers, there is a helper function, e.g. numbersToDataView([1, 0])\r\n * @param options Options for plugin call\r\n */\r\n writeDescriptor(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n descriptor: string,\r\n value: DataView,\r\n options?: TimeoutOptions,\r\n ): Promise<void>;\r\n\r\n /**\r\n * Start listening to changes of the value of a characteristic.\r\n * Note that you should only start the notifications once per characteristic in your app and share the data and\r\n * not call `startNotifications` in every component that needs the data.\r\n * For an example, see [usage](#usage).\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n * @param callback Callback function to use when the value of the characteristic changes\r\n * @param options Options for plugin call. Timeout not supported on **web**.\r\n */\r\n startNotifications(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n callback: (value: DataView) => void,\r\n options?: TimeoutOptions,\r\n ): Promise<void>;\r\n\r\n /**\r\n * Stop listening to the changes of the value of a characteristic. For an example, see [usage](#usage).\r\n * @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))\r\n * @param service UUID of the service (see [UUID format](#uuid-format))\r\n * @param characteristic UUID of the characteristic (see [UUID format](#uuid-format))\r\n */\r\n stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void>;\r\n}\r\n\r\nclass BleClientClass implements BleClientInterface {\r\n private scanListener: PluginListenerHandle | null = null;\r\n private eventListeners = new Map<string, PluginListenerHandle>();\r\n private queue = getQueue(true);\r\n\r\n enableQueue() {\r\n this.queue = getQueue(true);\r\n }\r\n\r\n disableQueue() {\r\n this.queue = getQueue(false);\r\n }\r\n\r\n async initialize(options?: InitializeOptions): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.initialize(options);\r\n });\r\n }\r\n\r\n async isEnabled(): Promise<boolean> {\r\n const enabled = await this.queue(async () => {\r\n const result = await BluetoothLe.isEnabled();\r\n return result.value;\r\n });\r\n return enabled;\r\n }\r\n\r\n async requestEnable(): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.requestEnable();\r\n });\r\n }\r\n\r\n async enable(): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.enable();\r\n });\r\n }\r\n\r\n async disable(): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.disable();\r\n });\r\n }\r\n\r\n async startEnabledNotifications(callback: (value: boolean) => void): Promise<void> {\r\n await this.queue(async () => {\r\n const key = `onEnabledChanged`;\r\n await this.eventListeners.get(key)?.remove();\r\n const listener = await BluetoothLe.addListener(key, (result) => {\r\n callback(result.value);\r\n });\r\n this.eventListeners.set(key, listener);\r\n await BluetoothLe.startEnabledNotifications();\r\n });\r\n }\r\n\r\n async stopEnabledNotifications(): Promise<void> {\r\n await this.queue(async () => {\r\n const key = `onEnabledChanged`;\r\n await this.eventListeners.get(key)?.remove();\r\n this.eventListeners.delete(key);\r\n await BluetoothLe.stopEnabledNotifications();\r\n });\r\n }\r\n\r\n async isLocationEnabled(): Promise<boolean> {\r\n const enabled = await this.queue(async () => {\r\n const result = await BluetoothLe.isLocationEnabled();\r\n return result.value;\r\n });\r\n return enabled;\r\n }\r\n\r\n async openLocationSettings(): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.openLocationSettings();\r\n });\r\n }\r\n\r\n async openBluetoothSettings(): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.openBluetoothSettings();\r\n });\r\n }\r\n\r\n async openAppSettings(): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.openAppSettings();\r\n });\r\n }\r\n\r\n async setDisplayStrings(displayStrings: DisplayStrings): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.setDisplayStrings(displayStrings);\r\n });\r\n }\r\n\r\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\r\n options = options ? this.validateRequestBleDeviceOptions(options) : undefined;\r\n const result = await this.queue(async () => {\r\n const device = await BluetoothLe.requestDevice(options);\r\n return device;\r\n });\r\n return result;\r\n }\r\n\r\n async requestLEScan(options: RequestBleDeviceOptions, callback: (result: ScanResult) => void): Promise<void> {\r\n options = this.validateRequestBleDeviceOptions(options);\r\n await this.queue(async () => {\r\n await this.scanListener?.remove();\r\n this.scanListener = await BluetoothLe.addListener('onScanResult', (resultInternal: ScanResultInternal) => {\r\n const result: ScanResult = {\r\n ...resultInternal,\r\n manufacturerData: this.convertObject(resultInternal.manufacturerData),\r\n serviceData: this.convertObject(resultInternal.serviceData),\r\n rawAdvertisement: resultInternal.rawAdvertisement\r\n ? this.convertValue(resultInternal.rawAdvertisement)\r\n : undefined,\r\n };\r\n callback(result);\r\n });\r\n await BluetoothLe.requestLEScan(options);\r\n });\r\n }\r\n\r\n async stopLEScan(): Promise<void> {\r\n await this.queue(async () => {\r\n await this.scanListener?.remove();\r\n this.scanListener = null;\r\n await BluetoothLe.stopLEScan();\r\n });\r\n }\r\n\r\n async getDevices(deviceIds: string[]): Promise<BleDevice[]> {\r\n if (!Array.isArray(deviceIds)) {\r\n throw new Error('deviceIds must be an array');\r\n }\r\n return this.queue(async () => {\r\n const result = await BluetoothLe.getDevices({ deviceIds });\r\n return result.devices;\r\n });\r\n }\r\n\r\n async getConnectedDevices(services: string[]): Promise<BleDevice[]> {\r\n if (!Array.isArray(services)) {\r\n throw new Error('services must be an array');\r\n }\r\n services = services.map(parseUUID);\r\n return this.queue(async () => {\r\n const result = await BluetoothLe.getConnectedDevices({ services });\r\n return result.devices;\r\n });\r\n }\r\n\r\n async getBondedDevices(): Promise<BleDevice[]> {\r\n return this.queue(async () => {\r\n const result = await BluetoothLe.getBondedDevices();\r\n return result.devices;\r\n });\r\n }\r\n\r\n async connect(deviceId: string, onDisconnect?: (deviceId: string) => void, options?: TimeoutOptions): Promise<void> {\r\n await this.queue(async () => {\r\n if (onDisconnect) {\r\n const key = `disconnected|${deviceId}`;\r\n await this.eventListeners.get(key)?.remove();\r\n const listener = await BluetoothLe.addListener(key, () => {\r\n onDisconnect(deviceId);\r\n });\r\n this.eventListeners.set(key, listener);\r\n }\r\n await BluetoothLe.connect({ deviceId, ...options });\r\n });\r\n }\r\n\r\n async createBond(deviceId: string, options?: TimeoutOptions): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.createBond({ deviceId, ...options });\r\n });\r\n }\r\n\r\n async isBonded(deviceId: string): Promise<boolean> {\r\n const isBonded = await this.queue(async () => {\r\n const result = await BluetoothLe.isBonded({ deviceId });\r\n return result.value;\r\n });\r\n return isBonded;\r\n }\r\n\r\n async disconnect(deviceId: string): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.disconnect({ deviceId });\r\n });\r\n }\r\n\r\n async getServices(deviceId: string): Promise<BleService[]> {\r\n const services = await this.queue(async () => {\r\n const result = await BluetoothLe.getServices({ deviceId });\r\n return result.services;\r\n });\r\n return services;\r\n }\r\n\r\n async discoverServices(deviceId: string): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.discoverServices({ deviceId });\r\n });\r\n }\r\n\r\n async getMtu(deviceId: string): Promise<number> {\r\n const value = await this.queue(async () => {\r\n const result = await BluetoothLe.getMtu({ deviceId });\r\n return result.value;\r\n });\r\n return value;\r\n }\r\n\r\n async requestConnectionPriority(deviceId: string, connectionPriority: ConnectionPriority): Promise<void> {\r\n await this.queue(async () => {\r\n await BluetoothLe.requestConnectionPriority({ deviceId, connectionPriority });\r\n });\r\n }\r\n\r\n async readRssi(deviceId: string): Promise<number> {\r\n const value = await this.queue(async () => {\r\n const result = await BluetoothLe.readRssi({ deviceId });\r\n return parseFloat(result.value);\r\n });\r\n return value;\r\n }\r\n\r\n async read(deviceId: string, service: string, characteristic: string, options?: TimeoutOptions): Promise<DataView> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n const value = await this.queue(async () => {\r\n const result = await BluetoothLe.read({\r\n deviceId,\r\n service,\r\n characteristic,\r\n ...options,\r\n });\r\n return this.convertValue(result.value);\r\n });\r\n return value;\r\n }\r\n\r\n async write(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n value: DataView,\r\n options?: TimeoutOptions,\r\n ): Promise<void> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n return this.queue(async () => {\r\n if (!value?.buffer) {\r\n throw new Error('Invalid data.');\r\n }\r\n let writeValue: DataView | string = value;\r\n if (Capacitor.getPlatform() !== 'web') {\r\n // on native we can only write strings\r\n writeValue = dataViewToHexString(value);\r\n }\r\n await BluetoothLe.write({\r\n deviceId,\r\n service,\r\n characteristic,\r\n value: writeValue,\r\n ...options,\r\n });\r\n });\r\n }\r\n\r\n async writeWithoutResponse(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n value: DataView,\r\n options?: TimeoutOptions,\r\n ): Promise<void> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n await this.queue(async () => {\r\n if (!value?.buffer) {\r\n throw new Error('Invalid data.');\r\n }\r\n let writeValue: DataView | string = value;\r\n if (Capacitor.getPlatform() !== 'web') {\r\n // on native we can only write strings\r\n writeValue = dataViewToHexString(value);\r\n }\r\n await BluetoothLe.writeWithoutResponse({\r\n deviceId,\r\n service,\r\n characteristic,\r\n value: writeValue,\r\n ...options,\r\n });\r\n });\r\n }\r\n\r\n async readDescriptor(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n descriptor: string,\r\n options?: TimeoutOptions,\r\n ): Promise<DataView> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n descriptor = parseUUID(descriptor);\r\n const value = await this.queue(async () => {\r\n const result = await BluetoothLe.readDescriptor({\r\n deviceId,\r\n service,\r\n characteristic,\r\n descriptor,\r\n ...options,\r\n });\r\n return this.convertValue(result.value);\r\n });\r\n return value;\r\n }\r\n\r\n async writeDescriptor(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n descriptor: string,\r\n value: DataView,\r\n options?: TimeoutOptions,\r\n ): Promise<void> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n descriptor = parseUUID(descriptor);\r\n return this.queue(async () => {\r\n if (!value?.buffer) {\r\n throw new Error('Invalid data.');\r\n }\r\n let writeValue: DataView | string = value;\r\n if (Capacitor.getPlatform() !== 'web') {\r\n // on native we can only write strings\r\n writeValue = dataViewToHexString(value);\r\n }\r\n await BluetoothLe.writeDescriptor({\r\n deviceId,\r\n service,\r\n characteristic,\r\n descriptor,\r\n value: writeValue,\r\n ...options,\r\n });\r\n });\r\n }\r\n\r\n async startNotifications(\r\n deviceId: string,\r\n service: string,\r\n characteristic: string,\r\n callback: (value: DataView) => void,\r\n options?: TimeoutOptions,\r\n ): Promise<void> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n await this.queue(async () => {\r\n const key = `notification|${deviceId}|${service}|${characteristic}`;\r\n await this.eventListeners.get(key)?.remove();\r\n const listener = await BluetoothLe.addListener(key, (event: ReadResult) => {\r\n callback(this.convertValue(event?.value));\r\n });\r\n this.eventListeners.set(key, listener);\r\n await BluetoothLe.startNotifications({\r\n deviceId,\r\n service,\r\n characteristic,\r\n ...options,\r\n });\r\n });\r\n }\r\n\r\n async stopNotifications(deviceId: string, service: string, characteristic: string): Promise<void> {\r\n service = parseUUID(service);\r\n characteristic = parseUUID(characteristic);\r\n await this.queue(async () => {\r\n const key = `notification|${deviceId}|${service}|${characteristic}`;\r\n await this.eventListeners.get(key)?.remove();\r\n this.eventListeners.delete(key);\r\n await BluetoothLe.stopNotifications({\r\n deviceId,\r\n service,\r\n characteristic,\r\n });\r\n });\r\n }\r\n\r\n private validateRequestBleDeviceOptions(options: RequestBleDeviceOptions): RequestBleDeviceOptions {\r\n if (options.services) {\r\n options.services = options.services.map(parseUUID);\r\n }\r\n if (options.optionalServices) {\r\n options.optionalServices = options.optionalServices.map(parseUUID);\r\n }\r\n if (options.serviceData && Capacitor.getPlatform() !== 'web') {\r\n // Native platforms: convert to hex strings\r\n options.serviceData = options.serviceData.map((filter) => ({\r\n ...filter,\r\n serviceUuid: parseUUID(filter.serviceUuid),\r\n dataPrefix: toHexString(filter.dataPrefix),\r\n mask: toHexString(filter.mask),\r\n })) as any;\r\n }\r\n if (options.manufacturerData) {\r\n if (Capacitor.getPlatform() !== 'web') {\r\n // Native platforms: convert to hex strings\r\n options.manufacturerData = options.manufacturerData.map((filter) => ({\r\n ...filter,\r\n dataPrefix: toHexString(filter.dataPrefix),\r\n mask: toHexString(filter.mask),\r\n })) as any;\r\n } else {\r\n // Web platform: convert to Uint8Array for Web Bluetooth API\r\n options.manufacturerData = options.manufacturerData.map((filter) => ({\r\n ...filter,\r\n dataPrefix: toUint8Array(filter.dataPrefix),\r\n mask: toUint8Array(filter.mask),\r\n }));\r\n }\r\n }\r\n return options;\r\n }\r\n\r\n private convertValue(value?: Data): DataView {\r\n if (typeof value === 'string') {\r\n return hexStringToDataView(value);\r\n } else if (value === undefined) {\r\n return new DataView(new ArrayBuffer(0));\r\n }\r\n return value;\r\n }\r\n\r\n private convertObject(obj?: { [key: string]: Data }): { [key: string]: DataView } | undefined {\r\n if (obj === undefined) {\r\n return undefined;\r\n }\r\n const result: { [key: string]: DataView } = {};\r\n for (const key of Object.keys(obj)) {\r\n result[key] = this.convertValue(obj[key]);\r\n }\r\n return result;\r\n }\r\n}\r\n\r\nexport const BleClient = new BleClientClass();\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"conversion.js","sourceRoot":"","sources":["../../src/conversion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,C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AE,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;KAClF;IACD,IAAI,KAAK,YAAY,QAAQ,EAAE;QAC7B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;KACzE;IACD,OAAO,KAAK,CAAC,CAAC,qBAAqB;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAwC;IAClE,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,KAAK,YAAY,QAAQ,EAAE;QAC7B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;KACnC;IACD,aAAa;IACb,OAAO,mBAAmB,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["/**\n * Convert an array of numbers into a DataView.\n */\nexport function numbersToDataView(value: number[]): DataView {\n return new DataView(Uint8Array.from(value).buffer);\n}\n\n/**\n * Convert a DataView into an array of numbers.\n */\nexport function dataViewToNumbers(value: DataView): number[] {\n return Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n}\n\n/**\n * Convert a string into a DataView.\n */\nexport function textToDataView(value: string): DataView {\n return numbersToDataView(value.split('').map((s) => s.charCodeAt(0)));\n}\n\n/**\n * Convert a DataView into a string.\n */\nexport function dataViewToText(value: DataView): string {\n return String.fromCharCode(...dataViewToNumbers(value));\n}\n\n/**\n * Convert a 16 bit UUID into a 128 bit UUID string\n * @param value number, e.g. 0x180d\n * @return string, e.g. '0000180d-0000-1000-8000-00805f9b34fb'\n */\nexport function numberToUUID(value: number): string {\n return `0000${value.toString(16).padStart(4, '0')}-0000-1000-8000-00805f9b34fb`;\n}\n\n/**\n * Convert a string of hex into a DataView of raw bytes.\n * Note: characters other than [0-9a-fA-F] are ignored\n * @param hex string of values, e.g. \"00 01 02\" or \"000102\"\n * @return DataView of raw bytes\n */\nexport function hexStringToDataView(hex: string): DataView {\n const bin = [];\n let i,\n c,\n isEmpty = 1,\n buffer = 0;\n for (i = 0; i < hex.length; i++) {\n c = hex.charCodeAt(i);\n if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) {\n buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15);\n if ((isEmpty ^= 1)) {\n bin.push(buffer & 0xff);\n }\n }\n }\n return numbersToDataView(bin);\n}\n\nexport function dataViewToHexString(value: DataView): string {\n return dataViewToNumbers(value)\n .map((n) => {\n let s = n.toString(16);\n if (s.length == 1) {\n s = '0' + s;\n }\n return s;\n })\n .join('');\n}\n\nexport function webUUIDToString(uuid: string | number): string {\n if (typeof uuid === 'string') {\n return uuid;\n } else if (typeof uuid === 'number') {\n return numberToUUID(uuid);\n } else {\n throw new Error('Invalid UUID');\n }\n}\n\nexport function mapToObject<V>(map?: Map<string | number, V>): { [key: string]: V } | undefined {\n const obj: { [key: string]: V } = {};\n if (!map) {\n return undefined;\n }\n map.forEach((value, key) => {\n obj[key.toString()] = value;\n });\n return obj;\n}\n\n/**\n * Convert Data or Uint8Array to Uint8Array.\n * @param value DataView, Uint8Array, or undefined\n * @return Uint8Array or undefined\n */\nexport function toUint8Array(value: DataView | Uint8Array | undefined): Uint8Array | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'string') {\n const dataView = hexStringToDataView(value);\n return new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);\n }\n if (value instanceof DataView) {\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n }\n return value; // Already Uint8Array\n}\n\n/**\n * Convert Data, Uint8Array, or string to hex string.\n * @param value DataView, Uint8Array, or undefined\n * @return hex string or undefined\n */\nexport function toHexString(value: DataView | Uint8Array | undefined): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (value instanceof DataView) {\n return dataViewToHexString(value);\n }\n // Uint8Array\n return dataViewToHexString(new DataView(value.buffer, value.byteOffset, value.byteLength));\n}\n"]}
1
+ {"version":3,"file":"conversion.js","sourceRoot":"","sources":["../../src/conversion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,8BAA8B,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,IAAI,CAAC,EACH,CAAC,EACD,OAAO,GAAG,CAAC,EACX,MAAM,GAAG,CAAC,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KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["/**\r\n * Convert an array of numbers into a DataView.\r\n */\r\nexport function numbersToDataView(value: number[]): DataView {\r\n return new DataView(Uint8Array.from(value).buffer);\r\n}\r\n\r\n/**\r\n * Convert a DataView into an array of numbers.\r\n */\r\nexport function dataViewToNumbers(value: DataView): number[] {\r\n return Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\r\n}\r\n\r\n/**\r\n * Convert a string into a DataView.\r\n */\r\nexport function textToDataView(value: string): DataView {\r\n return numbersToDataView(value.split('').map((s) => s.charCodeAt(0)));\r\n}\r\n\r\n/**\r\n * Convert a DataView into a string.\r\n */\r\nexport function dataViewToText(value: DataView): string {\r\n return String.fromCharCode(...dataViewToNumbers(value));\r\n}\r\n\r\n/**\r\n * Convert a 16 bit UUID into a 128 bit UUID string\r\n * @param value number, e.g. 0x180d\r\n * @return string, e.g. '0000180d-0000-1000-8000-00805f9b34fb'\r\n */\r\nexport function numberToUUID(value: number): string {\r\n return `0000${value.toString(16).padStart(4, '0')}-0000-1000-8000-00805f9b34fb`;\r\n}\r\n\r\n/**\r\n * Convert a string of hex into a DataView of raw bytes.\r\n * Note: characters other than [0-9a-fA-F] are ignored\r\n * @param hex string of values, e.g. \"00 01 02\" or \"000102\"\r\n * @return DataView of raw bytes\r\n */\r\nexport function hexStringToDataView(hex: string): DataView {\r\n const bin = [];\r\n let i,\r\n c,\r\n isEmpty = 1,\r\n buffer = 0;\r\n for (i = 0; i < hex.length; i++) {\r\n c = hex.charCodeAt(i);\r\n if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) {\r\n buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15);\r\n if ((isEmpty ^= 1)) {\r\n bin.push(buffer & 0xff);\r\n }\r\n }\r\n }\r\n return numbersToDataView(bin);\r\n}\r\n\r\nexport function dataViewToHexString(value: DataView): string {\r\n return dataViewToNumbers(value)\r\n .map((n) => {\r\n let s = n.toString(16);\r\n if (s.length == 1) {\r\n s = '0' + s;\r\n }\r\n return s;\r\n })\r\n .join('');\r\n}\r\n\r\nexport function webUUIDToString(uuid: string | number): string {\r\n if (typeof uuid === 'string') {\r\n return uuid;\r\n } else if (typeof uuid === 'number') {\r\n return numberToUUID(uuid);\r\n } else {\r\n throw new Error('Invalid UUID');\r\n }\r\n}\r\n\r\nexport function mapToObject<V>(map?: Map<string | number, V>): { [key: string]: V } | undefined {\r\n const obj: { [key: string]: V } = {};\r\n if (!map) {\r\n return undefined;\r\n }\r\n map.forEach((value, key) => {\r\n obj[key.toString()] = value;\r\n });\r\n return obj;\r\n}\r\n\r\n/**\r\n * Convert Data or Uint8Array to Uint8Array.\r\n * @param value DataView, Uint8Array, or undefined\r\n * @return Uint8Array or undefined\r\n */\r\nexport function toUint8Array(value: DataView | Uint8Array | undefined): Uint8Array | undefined {\r\n if (value === undefined) {\r\n return undefined;\r\n }\r\n if (typeof value === 'string') {\r\n const dataView = hexStringToDataView(value);\r\n return new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);\r\n }\r\n if (value instanceof DataView) {\r\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\r\n }\r\n return value; // Already Uint8Array\r\n}\r\n\r\n/**\r\n * Convert Data, Uint8Array, or string to hex string.\r\n * @param value DataView, Uint8Array, or undefined\r\n * @return hex string or undefined\r\n */\r\nexport function toHexString(value: DataView | Uint8Array | undefined): string | undefined {\r\n if (value === undefined) {\r\n return undefined;\r\n }\r\n if (value instanceof DataView) {\r\n return dataViewToHexString(value);\r\n }\r\n // Uint8Array\r\n return dataViewToHexString(new DataView(value.buffer, value.byteOffset, value.byteLength));\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAoEA;;GAEG;AACH,MAAM,CAAN,IAAY,QAgBX;AAhBD,WAAY,QAAQ;IAClB;;;OAGG;IACH,qEAAuB,CAAA;IACvB;;;OAGG;IACH,mEAAsB,CAAA;IACtB;;;OAGG;IACH,yEAAyB,CAAA;AAC3B,CAAC,EAhBW,QAAQ,KAAR,QAAQ,QAgBnB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAgBX;AAhBD,WAAY,kBAAkB;IAC5B;;;OAGG;IACH,2GAAgC,CAAA;IAChC;;;OAGG;IACH,mGAA4B,CAAA;IAC5B;;;OAGG;IACH,6GAAiC,CAAA;AACnC,CAAC,EAhBW,kBAAkB,KAAlB,kBAAkB,QAgB7B","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nimport type { DisplayStrings } from './config';\n\nexport interface InitializeOptions {\n /**\n * If your app doesn't use Bluetooth scan results to derive physical\n * location information, you can strongly assert that your app\n * doesn't derive physical location. (Android only)\n * Requires adding 'neverForLocation' to AndroidManifest.xml\n * https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location\n * @default false\n */\n androidNeverForLocation?: boolean;\n}\n\nexport interface RequestBleDeviceOptions {\n /**\n * Filter devices by service UUIDs.\n * UUIDs have to be specified as 128 bit UUID strings,\n * e.g. ['0000180d-0000-1000-8000-00805f9b34fb']\n * There is a helper function to convert numbers to UUIDs.\n * e.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))\n */\n services?: string[];\n /**\n * Filter devices by name\n */\n name?: string;\n /**\n * Filter devices by name prefix\n */\n namePrefix?: string;\n /**\n * For **web**, all services that will be used have to be listed under services or optionalServices,\n * e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))\n */\n optionalServices?: string[];\n /**\n * Normally scans will discard the second and subsequent advertisements from a single device.\n * If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\n * (default: false)\n */\n allowDuplicates?: boolean;\n /**\n * Android scan mode (default: ScanMode.SCAN_MODE_BALANCED)\n */\n scanMode?: ScanMode;\n /**\n * Allow scanning for devices with a specific manufacturer data\n * https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata\n */\n manufacturerData?: ManufacturerDataFilter[];\n /**\n * Display mode for the device list in `requestDevice` (**iOS** only).\n * - `\"alert\"`: Classic alert dialog (default)\n * - `\"list\"`: Scrollable list view\n * @default \"alert\"\n */\n displayMode?: 'alert' | 'list';\n /**\n * Allow scanning for devices with specific service data.\n * Service data is data associated with a specific service UUID in the advertisement packet.\n * Useful for protocols like OpenDroneID, EddyStone, and Open Beacon.\n */\n serviceData?: ServiceDataFilter[];\n}\n\n/**\n * Android scan mode\n */\nexport enum ScanMode {\n /**\n * Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\n * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER\n */\n SCAN_MODE_LOW_POWER = 0,\n /**\n * Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\n * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED\n */\n SCAN_MODE_BALANCED = 1,\n /**\n * Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\n * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY\n */\n SCAN_MODE_LOW_LATENCY = 2,\n}\n\n/**\n * Android connection priority used in `requestConnectionPriority`\n */\nexport enum ConnectionPriority {\n /**\n * Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.\n * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED\n */\n CONNECTION_PRIORITY_BALANCED = 0,\n /**\n * Request a high priority, low latency connection. An application should only request high priority connection parameters to transfer large amounts of data over LE quickly. Once the transfer is complete, the application should request CONNECTION_PRIORITY_BALANCED connection parameters to reduce energy use.\n * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH\n */\n CONNECTION_PRIORITY_HIGH = 1,\n /**\n * Request low power, reduced data rate connection parameters.\n * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER\n */\n CONNECTION_PRIORITY_LOW_POWER = 2,\n}\n\nexport interface ManufacturerDataFilter {\n /**\n * Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field.\n */\n companyIdentifier: number;\n\n /**\n * Prefix to match in the manufacturer data field.\n * On **Android** this field is mandatory.\n * android, ios: DataView\n * web: Uint8Array\n */\n dataPrefix?: DataView | Uint8Array;\n\n /**\n * Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.\n * The `mask` must have the same length of dataPrefix.\n * android, ios: DataView\n * web: Uint8Array\n */\n mask?: DataView | Uint8Array;\n}\n\nexport interface ServiceDataFilter {\n /**\n * Service UUID to filter by. The service data must be associated with this UUID.\n * UUIDs have to be specified as 128 bit UUID strings,\n * e.g. '0000fffa-0000-1000-8000-00805f9b34fb'\n */\n serviceUuid: string;\n\n /**\n * Prefix to match in the service data field.\n * For example, OpenDroneID uses [0x0D] as the advertisement code.\n * android, ios: string\n * web: DataView\n */\n dataPrefix?: DataView;\n\n /**\n * Set filter on partial service data. For any bit in the mask, set it to 1 if it needs to match the one in service data, otherwise set it to 0.\n * The `mask` must have the same length as dataPrefix.\n * android, ios: string\n * web: DataView\n */\n mask?: DataView;\n}\n\nexport interface BleDevice {\n /**\n * ID of the device, which will be needed for further calls.\n * On **Android** this is the BLE MAC address.\n * On **iOS** and **web** it is an identifier.\n */\n deviceId: string;\n /**\n * Name of the peripheral device.\n */\n name?: string;\n uuids?: string[];\n}\n\nexport interface DeviceIdOptions {\n deviceId: string;\n}\nexport interface TimeoutOptions {\n /**\n * Timeout in milliseconds for plugin call.\n * Default is 10000 for `connect` and 5000 for other plugin methods.\n */\n timeout?: number;\n}\n\nexport interface RequestConnectionPriorityOptions extends DeviceIdOptions {\n connectionPriority: ConnectionPriority;\n}\n\nexport interface GetDevicesOptions {\n deviceIds: string[];\n}\n\nexport interface GetConnectedDevicesOptions {\n services: string[];\n}\n\nexport interface BleService {\n readonly uuid: string;\n readonly characteristics: BleCharacteristic[];\n}\n\nexport interface BleDescriptor {\n readonly uuid: string;\n}\n\nexport interface BleCharacteristic {\n readonly uuid: string;\n readonly properties: BleCharacteristicProperties;\n readonly descriptors: BleDescriptor[];\n}\n\nexport interface BleCharacteristicProperties {\n readonly broadcast: boolean;\n readonly read: boolean;\n readonly writeWithoutResponse: boolean;\n readonly write: boolean;\n readonly notify: boolean;\n readonly indicate: boolean;\n readonly authenticatedSignedWrites: boolean;\n readonly reliableWrite?: boolean;\n readonly writableAuxiliaries?: boolean;\n readonly extendedProperties?: boolean;\n readonly notifyEncryptionRequired?: boolean;\n readonly indicateEncryptionRequired?: boolean;\n}\n\nexport interface BleServices {\n services: BleService[];\n}\n\nexport interface ReadOptions {\n deviceId: string;\n service: string;\n characteristic: string;\n}\n\nexport interface ReadDescriptorOptions {\n deviceId: string;\n service: string;\n characteristic: string;\n descriptor: string;\n}\n\nexport type Data = DataView | string;\n\nexport interface WriteOptions {\n deviceId: string;\n service: string;\n characteristic: string;\n /**\n * android, ios: string\n * web: DataView\n */\n value: Data;\n}\n\nexport interface WriteDescriptorOptions {\n deviceId: string;\n service: string;\n characteristic: string;\n descriptor: string;\n /**\n * android, ios: string\n * web: DataView\n */\n value: Data;\n}\n\nexport interface BooleanResult {\n value: boolean;\n}\n\nexport interface GetDevicesResult {\n devices: BleDevice[];\n}\n\nexport interface GetMtuResult {\n value: number;\n}\n\nexport interface ReadRssiResult {\n value: string;\n}\n\nexport interface ReadResult {\n /**\n * android, ios: string\n * web: DataView\n */\n value?: Data;\n}\n\nexport interface ScanResultInternal<T = Data> {\n device: BleDevice;\n localName?: string;\n rssi?: number;\n txPower?: number;\n manufacturerData?: { [key: string]: T };\n serviceData?: { [key: string]: T };\n uuids?: string[];\n rawAdvertisement?: T;\n}\n\nexport interface ScanResult {\n /**\n * The peripheral device that was found in the scan.\n * **Android** and **web**: `device.name` is always identical to `localName`.\n * **iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.\n */\n device: BleDevice;\n /**\n * The name of the peripheral device from the advertisement data.\n */\n localName?: string;\n /**\n * Received Signal Strength Indication.\n */\n rssi?: number;\n /**\n * Transmit power in dBm. A value of 127 indicates that it is not available.\n */\n txPower?: number;\n /**\n * Manufacturer data, key is a company identifier and value is the data.\n */\n manufacturerData?: { [key: string]: DataView };\n /**\n * Service data, key is a service UUID and value is the data.\n */\n serviceData?: { [key: string]: DataView };\n /**\n * Advertised services.\n */\n uuids?: string[];\n /**\n * Raw advertisement data (**Android** only).\n */\n rawAdvertisement?: DataView;\n}\n\nexport interface BluetoothLePlugin {\n initialize(options?: InitializeOptions): Promise<void>;\n isEnabled(): Promise<BooleanResult>;\n requestEnable(): Promise<void>;\n enable(): Promise<void>;\n disable(): Promise<void>;\n startEnabledNotifications(): Promise<void>;\n stopEnabledNotifications(): Promise<void>;\n isLocationEnabled(): Promise<BooleanResult>;\n openLocationSettings(): Promise<void>;\n openBluetoothSettings(): Promise<void>;\n openAppSettings(): Promise<void>;\n setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;\n requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;\n requestLEScan(options?: RequestBleDeviceOptions): Promise<void>;\n stopLEScan(): Promise<void>;\n getDevices(options: GetDevicesOptions): Promise<GetDevicesResult>;\n getConnectedDevices(options: GetConnectedDevicesOptions): Promise<GetDevicesResult>;\n getBondedDevices(): Promise<GetDevicesResult>;\n addListener(\n eventName: 'onEnabledChanged',\n listenerFunc: (result: BooleanResult) => void,\n ): Promise<PluginListenerHandle>;\n addListener(eventName: string, listenerFunc: (event: ReadResult) => void): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'onScanResult',\n listenerFunc: (result: ScanResultInternal) => void,\n ): Promise<PluginListenerHandle>;\n connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;\n createBond(options: DeviceIdOptions & TimeoutOptions): Promise<void>;\n isBonded(options: DeviceIdOptions): Promise<BooleanResult>;\n disconnect(options: DeviceIdOptions): Promise<void>;\n getServices(options: DeviceIdOptions): Promise<BleServices>;\n discoverServices(options: DeviceIdOptions): Promise<void>;\n getMtu(options: DeviceIdOptions): Promise<GetMtuResult>;\n requestConnectionPriority(options: RequestConnectionPriorityOptions): Promise<void>;\n readRssi(options: DeviceIdOptions): Promise<ReadRssiResult>;\n read(options: ReadOptions & TimeoutOptions): Promise<ReadResult>;\n write(options: WriteOptions & TimeoutOptions): Promise<void>;\n writeWithoutResponse(options: WriteOptions & TimeoutOptions): Promise<void>;\n readDescriptor(options: ReadDescriptorOptions & TimeoutOptions): Promise<ReadResult>;\n writeDescriptor(options: WriteDescriptorOptions & TimeoutOptions): Promise<void>;\n startNotifications(options: ReadOptions & TimeoutOptions): Promise<void>;\n stopNotifications(options: ReadOptions): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAoEA;;GAEG;AACH,MAAM,CAAN,IAAY,QAgBX;AAhBD,WAAY,QAAQ;IAClB;;;OAGG;IACH,qEAAuB,CAAA;IACvB;;;OAGG;IACH,mEAAsB,CAAA;IACtB;;;OAGG;IACH,yEAAyB,CAAA;AAC3B,CAAC,EAhBW,QAAQ,KAAR,QAAQ,QAgBnB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAgBX;AAhBD,WAAY,kBAAkB;IAC5B;;;OAGG;IACH,2GAAgC,CAAA;IAChC;;;OAGG;IACH,mGAA4B,CAAA;IAC5B;;;OAGG;IACH,6GAAiC,CAAA;AACnC,CAAC,EAhBW,kBAAkB,KAAlB,kBAAkB,QAgB7B","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\r\n\r\nimport type { DisplayStrings } from './config';\r\n\r\nexport interface InitializeOptions {\r\n /**\r\n * If your app doesn't use Bluetooth scan results to derive physical\r\n * location information, you can strongly assert that your app\r\n * doesn't derive physical location. (Android only)\r\n * Requires adding 'neverForLocation' to AndroidManifest.xml\r\n * https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location\r\n * @default false\r\n */\r\n androidNeverForLocation?: boolean;\r\n}\r\n\r\nexport interface RequestBleDeviceOptions {\r\n /**\r\n * Filter devices by service UUIDs.\r\n * UUIDs have to be specified as 128 bit UUID strings,\r\n * e.g. ['0000180d-0000-1000-8000-00805f9b34fb']\r\n * There is a helper function to convert numbers to UUIDs.\r\n * e.g. [numberToUUID(0x180f)]. (see [UUID format](#uuid-format))\r\n */\r\n services?: string[];\r\n /**\r\n * Filter devices by name\r\n */\r\n name?: string;\r\n /**\r\n * Filter devices by name prefix\r\n */\r\n namePrefix?: string;\r\n /**\r\n * For **web**, all services that will be used have to be listed under services or optionalServices,\r\n * e.g. [numberToUUID(0x180f)] (see [UUID format](#uuid-format))\r\n */\r\n optionalServices?: string[];\r\n /**\r\n * Normally scans will discard the second and subsequent advertisements from a single device.\r\n * If you need to receive them, set allowDuplicates to true (only applicable in `requestLEScan`).\r\n * (default: false)\r\n */\r\n allowDuplicates?: boolean;\r\n /**\r\n * Android scan mode (default: ScanMode.SCAN_MODE_BALANCED)\r\n */\r\n scanMode?: ScanMode;\r\n /**\r\n * Allow scanning for devices with a specific manufacturer data\r\n * https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#manufacturerdata\r\n */\r\n manufacturerData?: ManufacturerDataFilter[];\r\n /**\r\n * Display mode for the device list in `requestDevice` (**iOS** only).\r\n * - `\"alert\"`: Classic alert dialog (default)\r\n * - `\"list\"`: Scrollable list view\r\n * @default \"alert\"\r\n */\r\n displayMode?: 'alert' | 'list';\r\n /**\r\n * Allow scanning for devices with specific service data.\r\n * Service data is data associated with a specific service UUID in the advertisement packet.\r\n * Useful for protocols like OpenDroneID, EddyStone, and Open Beacon.\r\n */\r\n serviceData?: ServiceDataFilter[];\r\n}\r\n\r\n/**\r\n * Android scan mode\r\n */\r\nexport enum ScanMode {\r\n /**\r\n * Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.\r\n * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER\r\n */\r\n SCAN_MODE_LOW_POWER = 0,\r\n /**\r\n * Perform Bluetooth LE scan in balanced power mode. (default) Scan results are returned at a rate that provides a good trade-off between scan frequency and power consumption.\r\n * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED\r\n */\r\n SCAN_MODE_BALANCED = 1,\r\n /**\r\n * Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.\r\n * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY\r\n */\r\n SCAN_MODE_LOW_LATENCY = 2,\r\n}\r\n\r\n/**\r\n * Android connection priority used in `requestConnectionPriority`\r\n */\r\nexport enum ConnectionPriority {\r\n /**\r\n * Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.\r\n * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED\r\n */\r\n CONNECTION_PRIORITY_BALANCED = 0,\r\n /**\r\n * Request a high priority, low latency connection. An application should only request high priority connection parameters to transfer large amounts of data over LE quickly. Once the transfer is complete, the application should request CONNECTION_PRIORITY_BALANCED connection parameters to reduce energy use.\r\n * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH\r\n */\r\n CONNECTION_PRIORITY_HIGH = 1,\r\n /**\r\n * Request low power, reduced data rate connection parameters.\r\n * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER\r\n */\r\n CONNECTION_PRIORITY_LOW_POWER = 2,\r\n}\r\n\r\nexport interface ManufacturerDataFilter {\r\n /**\r\n * Company ID (sometimes called the manufacturer ID) to search for in the manufacturer data field.\r\n */\r\n companyIdentifier: number;\r\n\r\n /**\r\n * Prefix to match in the manufacturer data field.\r\n * On **Android** this field is mandatory.\r\n * android, ios: DataView\r\n * web: Uint8Array\r\n */\r\n dataPrefix?: DataView | Uint8Array;\r\n\r\n /**\r\n * Set filter on partial manufacture data. For any bit in the mask, set it the 1 if it needs to match the one in manufacturer data, otherwise set it to 0.\r\n * The `mask` must have the same length of dataPrefix.\r\n * android, ios: DataView\r\n * web: Uint8Array\r\n */\r\n mask?: DataView | Uint8Array;\r\n}\r\n\r\nexport interface ServiceDataFilter {\r\n /**\r\n * Service UUID to filter by. The service data must be associated with this UUID.\r\n * UUIDs have to be specified as 128 bit UUID strings,\r\n * e.g. '0000fffa-0000-1000-8000-00805f9b34fb'\r\n */\r\n serviceUuid: string;\r\n\r\n /**\r\n * Prefix to match in the service data field.\r\n * For example, OpenDroneID uses [0x0D] as the advertisement code.\r\n * android, ios: string\r\n * web: DataView\r\n */\r\n dataPrefix?: DataView;\r\n\r\n /**\r\n * Set filter on partial service data. For any bit in the mask, set it to 1 if it needs to match the one in service data, otherwise set it to 0.\r\n * The `mask` must have the same length as dataPrefix.\r\n * android, ios: string\r\n * web: DataView\r\n */\r\n mask?: DataView;\r\n}\r\n\r\nexport interface BleDevice {\r\n /**\r\n * ID of the device, which will be needed for further calls.\r\n * On **Android** this is the BLE MAC address.\r\n * On **iOS** and **web** it is an identifier.\r\n */\r\n deviceId: string;\r\n /**\r\n * Name of the peripheral device.\r\n */\r\n name?: string;\r\n uuids?: string[];\r\n}\r\n\r\nexport interface DeviceIdOptions {\r\n deviceId: string;\r\n}\r\nexport interface TimeoutOptions {\r\n /**\r\n * Timeout in milliseconds for plugin call.\r\n * Default is 10000 for `connect` and 5000 for other plugin methods.\r\n */\r\n timeout?: number;\r\n}\r\n\r\nexport interface RequestConnectionPriorityOptions extends DeviceIdOptions {\r\n connectionPriority: ConnectionPriority;\r\n}\r\n\r\nexport interface GetDevicesOptions {\r\n deviceIds: string[];\r\n}\r\n\r\nexport interface GetConnectedDevicesOptions {\r\n services: string[];\r\n}\r\n\r\nexport interface BleService {\r\n readonly uuid: string;\r\n readonly characteristics: BleCharacteristic[];\r\n}\r\n\r\nexport interface BleDescriptor {\r\n readonly uuid: string;\r\n}\r\n\r\nexport interface BleCharacteristic {\r\n readonly uuid: string;\r\n readonly properties: BleCharacteristicProperties;\r\n readonly descriptors: BleDescriptor[];\r\n}\r\n\r\nexport interface BleCharacteristicProperties {\r\n readonly broadcast: boolean;\r\n readonly read: boolean;\r\n readonly writeWithoutResponse: boolean;\r\n readonly write: boolean;\r\n readonly notify: boolean;\r\n readonly indicate: boolean;\r\n readonly authenticatedSignedWrites: boolean;\r\n readonly reliableWrite?: boolean;\r\n readonly writableAuxiliaries?: boolean;\r\n readonly extendedProperties?: boolean;\r\n readonly notifyEncryptionRequired?: boolean;\r\n readonly indicateEncryptionRequired?: boolean;\r\n}\r\n\r\nexport interface BleServices {\r\n services: BleService[];\r\n}\r\n\r\nexport interface ReadOptions {\r\n deviceId: string;\r\n service: string;\r\n characteristic: string;\r\n}\r\n\r\nexport interface ReadDescriptorOptions {\r\n deviceId: string;\r\n service: string;\r\n characteristic: string;\r\n descriptor: string;\r\n}\r\n\r\nexport type Data = DataView | string;\r\n\r\nexport interface WriteOptions {\r\n deviceId: string;\r\n service: string;\r\n characteristic: string;\r\n /**\r\n * android, ios: string\r\n * web: DataView\r\n */\r\n value: Data;\r\n}\r\n\r\nexport interface WriteDescriptorOptions {\r\n deviceId: string;\r\n service: string;\r\n characteristic: string;\r\n descriptor: string;\r\n /**\r\n * android, ios: string\r\n * web: DataView\r\n */\r\n value: Data;\r\n}\r\n\r\nexport interface BooleanResult {\r\n value: boolean;\r\n}\r\n\r\nexport interface GetDevicesResult {\r\n devices: BleDevice[];\r\n}\r\n\r\nexport interface GetMtuResult {\r\n value: number;\r\n}\r\n\r\nexport interface ReadRssiResult {\r\n value: string;\r\n}\r\n\r\nexport interface ReadResult {\r\n /**\r\n * android, ios: string\r\n * web: DataView\r\n */\r\n value?: Data;\r\n}\r\n\r\nexport interface ScanResultInternal<T = Data> {\r\n device: BleDevice;\r\n localName?: string;\r\n rssi?: number;\r\n txPower?: number;\r\n manufacturerData?: { [key: string]: T };\r\n serviceData?: { [key: string]: T };\r\n uuids?: string[];\r\n rawAdvertisement?: T;\r\n}\r\n\r\nexport interface ScanResult {\r\n /**\r\n * The peripheral device that was found in the scan.\r\n * **Android** and **web**: `device.name` is always identical to `localName`.\r\n * **iOS**: `device.name` is identical to `localName` the first time a device is discovered, but after connecting `device.name` is the cached GAP name in subsequent scans.\r\n */\r\n device: BleDevice;\r\n /**\r\n * The name of the peripheral device from the advertisement data.\r\n */\r\n localName?: string;\r\n /**\r\n * Received Signal Strength Indication.\r\n */\r\n rssi?: number;\r\n /**\r\n * Transmit power in dBm. A value of 127 indicates that it is not available.\r\n */\r\n txPower?: number;\r\n /**\r\n * Manufacturer data, key is a company identifier and value is the data.\r\n */\r\n manufacturerData?: { [key: string]: DataView };\r\n /**\r\n * Service data, key is a service UUID and value is the data.\r\n */\r\n serviceData?: { [key: string]: DataView };\r\n /**\r\n * Advertised services.\r\n */\r\n uuids?: string[];\r\n /**\r\n * Raw advertisement data (**Android** only).\r\n */\r\n rawAdvertisement?: DataView;\r\n}\r\n\r\nexport interface BluetoothLePlugin {\r\n initialize(options?: InitializeOptions): Promise<void>;\r\n isEnabled(): Promise<BooleanResult>;\r\n requestEnable(): Promise<void>;\r\n enable(): Promise<void>;\r\n disable(): Promise<void>;\r\n startEnabledNotifications(): Promise<void>;\r\n stopEnabledNotifications(): Promise<void>;\r\n isLocationEnabled(): Promise<BooleanResult>;\r\n openLocationSettings(): Promise<void>;\r\n openBluetoothSettings(): Promise<void>;\r\n openAppSettings(): Promise<void>;\r\n setDisplayStrings(displayStrings: DisplayStrings): Promise<void>;\r\n requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;\r\n requestLEScan(options?: RequestBleDeviceOptions): Promise<void>;\r\n stopLEScan(): Promise<void>;\r\n getDevices(options: GetDevicesOptions): Promise<GetDevicesResult>;\r\n getConnectedDevices(options: GetConnectedDevicesOptions): Promise<GetDevicesResult>;\r\n getBondedDevices(): Promise<GetDevicesResult>;\r\n addListener(\r\n eventName: 'onEnabledChanged',\r\n listenerFunc: (result: BooleanResult) => void,\r\n ): Promise<PluginListenerHandle>;\r\n addListener(eventName: string, listenerFunc: (event: ReadResult) => void): Promise<PluginListenerHandle>;\r\n addListener(\r\n eventName: 'onScanResult',\r\n listenerFunc: (result: ScanResultInternal) => void,\r\n ): Promise<PluginListenerHandle>;\r\n connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;\r\n createBond(options: DeviceIdOptions & TimeoutOptions): Promise<void>;\r\n isBonded(options: DeviceIdOptions): Promise<BooleanResult>;\r\n disconnect(options: DeviceIdOptions): Promise<void>;\r\n getServices(options: DeviceIdOptions): Promise<BleServices>;\r\n discoverServices(options: DeviceIdOptions): Promise<void>;\r\n getMtu(options: DeviceIdOptions): Promise<GetMtuResult>;\r\n requestConnectionPriority(options: RequestConnectionPriorityOptions): Promise<void>;\r\n readRssi(options: DeviceIdOptions): Promise<ReadRssiResult>;\r\n read(options: ReadOptions & TimeoutOptions): Promise<ReadResult>;\r\n write(options: WriteOptions & TimeoutOptions): Promise<void>;\r\n writeWithoutResponse(options: WriteOptions & TimeoutOptions): Promise<void>;\r\n readDescriptor(options: ReadDescriptorOptions & TimeoutOptions): Promise<ReadResult>;\r\n writeDescriptor(options: WriteDescriptorOptions & TimeoutOptions): Promise<void>;\r\n startNotifications(options: ReadOptions & TimeoutOptions): Promise<void>;\r\n stopNotifications(options: ReadOptions): Promise<void>;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,eA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C;iBACb;aACF;iBAAM;gBACL,mCAAmC;gBACnC,IAAI,OAAO,GAAG,IAAI,CAAC;gBACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;oBAC9C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;wBACtC,OAAO,GAAG,KAAK,CAAC;wBAChB,MAAM;qBACP;iBACF;gBACD,IAAI,OAAO,EAAE;oBACX,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC,CAAC,oBAAoB;IACpC,CAAC;IAEO,gBAAgB,CAAC,QAAgB;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;SACnG;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAuB;;QAC1C,MAAM,SAAS,GAAc;YAC3B,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,yDAAyD;YACzD,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS;SAC/B,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { hexStringToDataView, mapToObject, webUUIDToString } from './conversion';\nimport type {\n BleCharacteristic,\n BleCharacteristicProperties,\n BleDescriptor,\n BleService,\n TimeoutOptions,\n BleDevice,\n BleServices,\n BluetoothLePlugin,\n BooleanResult,\n DeviceIdOptions,\n GetConnectedDevicesOptions,\n GetDevicesOptions,\n GetDevicesResult,\n ReadDescriptorOptions,\n ReadOptions,\n ReadResult,\n ReadRssiResult,\n RequestBleDeviceOptions,\n ScanResultInternal,\n WriteOptions,\n WriteDescriptorOptions,\n GetMtuResult,\n RequestConnectionPriorityOptions,\n} from './definitions';\nimport { runWithTimeout } from './timeout';\n\nexport class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {\n private deviceMap = new Map<string, BluetoothDevice>();\n private discoveredDevices = new Map<string, boolean>();\n private scan: BluetoothLEScan | null = null;\n private requestBleDeviceOptions: RequestBleDeviceOptions | undefined;\n private DEFAULT_CONNECTION_TIMEOUT = 10000;\n\n async initialize(): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.bluetooth) {\n throw this.unavailable('Web Bluetooth API not available in this browser.');\n }\n const isAvailable = await navigator.bluetooth.getAvailability();\n if (!isAvailable) {\n throw this.unavailable('No Bluetooth radio available.');\n }\n }\n\n async isEnabled(): Promise<BooleanResult> {\n // not available on web\n return { value: true };\n }\n\n async requestEnable(): Promise<void> {\n throw this.unavailable('requestEnable is not available on web.');\n }\n\n async enable(): Promise<void> {\n throw this.unavailable('enable is not available on web.');\n }\n\n async disable(): Promise<void> {\n throw this.unavailable('disable is not available on web.');\n }\n\n async startEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async stopEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async isLocationEnabled(): Promise<BooleanResult> {\n throw this.unavailable('isLocationEnabled is not available on web.');\n }\n\n async openLocationSettings(): Promise<void> {\n throw this.unavailable('openLocationSettings is not available on web.');\n }\n\n async openBluetoothSettings(): Promise<void> {\n throw this.unavailable('openBluetoothSettings is not available on web.');\n }\n\n async openAppSettings(): Promise<void> {\n throw this.unavailable('openAppSettings is not available on web.');\n }\n\n async setDisplayStrings(): Promise<void> {\n // not available on web\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n const filters = this.getFilters(options);\n const device = await navigator.bluetooth.requestDevice({\n filters: filters.length ? filters : undefined,\n optionalServices: options?.optionalServices,\n acceptAllDevices: filters.length === 0,\n });\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n }\n\n async requestLEScan(options?: RequestBleDeviceOptions): Promise<void> {\n this.requestBleDeviceOptions = options;\n const filters = this.getFilters(options);\n await this.stopLEScan();\n this.discoveredDevices = new Map<string, boolean>();\n navigator.bluetooth.removeEventListener(\n 'advertisementreceived',\n this.onAdvertisementReceivedCallback as EventListener,\n );\n navigator.bluetooth.addEventListener('advertisementreceived', this.onAdvertisementReceivedCallback);\n this.scan = await navigator.bluetooth.requestLEScan({\n filters: filters.length ? filters : undefined,\n acceptAllAdvertisements: filters.length === 0,\n keepRepeatedDevices: options?.allowDuplicates,\n });\n }\n\n private onAdvertisementReceivedCallback = this.onAdvertisementReceived.bind(this);\n\n private onAdvertisementReceived(event: BluetoothAdvertisingEvent): void {\n const deviceId = event.device.id;\n this.deviceMap.set(deviceId, event.device);\n const isNew = !this.discoveredDevices.has(deviceId);\n\n // Apply service data filtering client-side (Web Bluetooth API doesn't support it in scan filters)\n if (this.requestBleDeviceOptions?.serviceData && !this.matchesServiceDataFilter(event)) {\n return;\n }\n\n if (isNew || this.requestBleDeviceOptions?.allowDuplicates) {\n this.discoveredDevices.set(deviceId, true);\n const device = this.getBleDevice(event.device);\n const result: ScanResultInternal = {\n device,\n localName: device.name,\n rssi: event.rssi,\n txPower: event.txPower,\n manufacturerData: mapToObject(event.manufacturerData),\n serviceData: mapToObject(event.serviceData),\n uuids: event.uuids?.map(webUUIDToString),\n };\n this.notifyListeners('onScanResult', result);\n }\n }\n\n async stopLEScan(): Promise<void> {\n if (this.scan?.active) {\n this.scan.stop();\n }\n this.scan = null;\n }\n\n async getDevices(options: GetDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => options.deviceIds.includes(device.id))\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => {\n return device.gatt?.connected;\n })\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getBondedDevices(): Promise<GetDevicesResult> {\n return {} as Promise<GetDevicesResult>;\n }\n\n async connect(options: DeviceIdOptions & TimeoutOptions): Promise<void> {\n const device = this.getDeviceFromMap(options.deviceId);\n device.removeEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n device.addEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n const timeoutError = Symbol();\n if (device.gatt === undefined) {\n throw new Error('No gatt server available.');\n }\n try {\n const timeout = options.timeout ?? this.DEFAULT_CONNECTION_TIMEOUT;\n await runWithTimeout(device.gatt.connect(), timeout, timeoutError);\n } catch (error) {\n // cancel pending connect call, does not work yet in chromium because of a bug:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=684073\n await device.gatt?.disconnect();\n if (error === timeoutError) {\n throw new Error('Connection timeout');\n } else {\n throw error;\n }\n }\n }\n\n private onDisconnectedCallback = this.onDisconnected.bind(this);\n\n private onDisconnected(event: Event): void {\n const deviceId = (event.target as BluetoothDevice).id;\n const key = `disconnected|${deviceId}`;\n this.notifyListeners(key, null);\n }\n\n async createBond(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('createBond is not available on web.');\n }\n\n async isBonded(_options: DeviceIdOptions): Promise<BooleanResult> {\n throw this.unavailable('isBonded is not available on web.');\n }\n\n async disconnect(options: DeviceIdOptions): Promise<void> {\n this.getDeviceFromMap(options.deviceId).gatt?.disconnect();\n }\n\n async getServices(options: DeviceIdOptions): Promise<BleServices> {\n const services = (await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryServices()) ?? [];\n const bleServices: BleService[] = [];\n for (const service of services) {\n const characteristics = await service.getCharacteristics();\n const bleCharacteristics: BleCharacteristic[] = [];\n for (const characteristic of characteristics) {\n bleCharacteristics.push({\n uuid: characteristic.uuid,\n properties: this.getProperties(characteristic),\n descriptors: await this.getDescriptors(characteristic),\n });\n }\n bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics });\n }\n return { services: bleServices };\n }\n\n private async getDescriptors(characteristic: BluetoothRemoteGATTCharacteristic): Promise<BleDescriptor[]> {\n try {\n const descriptors = await characteristic.getDescriptors();\n return descriptors.map((descriptor) => ({\n uuid: descriptor.uuid,\n }));\n } catch {\n return [];\n }\n }\n\n private getProperties(characteristic: BluetoothRemoteGATTCharacteristic): BleCharacteristicProperties {\n return {\n broadcast: characteristic.properties.broadcast,\n read: characteristic.properties.read,\n writeWithoutResponse: characteristic.properties.writeWithoutResponse,\n write: characteristic.properties.write,\n notify: characteristic.properties.notify,\n indicate: characteristic.properties.indicate,\n authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites,\n reliableWrite: characteristic.properties.reliableWrite,\n writableAuxiliaries: characteristic.properties.writableAuxiliaries,\n };\n }\n\n private async getCharacteristic(\n options: ReadOptions | WriteOptions,\n ): Promise<BluetoothRemoteGATTCharacteristic | undefined> {\n const service = await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryService(options?.service);\n return service?.getCharacteristic(options?.characteristic);\n }\n\n private async getDescriptor(\n options: ReadDescriptorOptions | WriteDescriptorOptions,\n ): Promise<BluetoothRemoteGATTDescriptor | undefined> {\n const characteristic = await this.getCharacteristic(options);\n return characteristic?.getDescriptor(options?.descriptor);\n }\n\n async discoverServices(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('discoverServices is not available on web.');\n }\n\n async getMtu(_options: DeviceIdOptions): Promise<GetMtuResult> {\n throw this.unavailable('getMtu is not available on web.');\n }\n\n async requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void> {\n throw this.unavailable('requestConnectionPriority is not available on web.');\n }\n\n async readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult> {\n throw this.unavailable('readRssi is not available on web.');\n }\n\n async read(options: ReadOptions): Promise<ReadResult> {\n const characteristic = await this.getCharacteristic(options);\n const value = await characteristic?.readValue();\n return { value };\n }\n\n async write(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithResponse(dataView);\n }\n\n async writeWithoutResponse(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithoutResponse(dataView);\n }\n\n async readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult> {\n const descriptor = await this.getDescriptor(options);\n const value = await descriptor?.readValue();\n return { value };\n }\n\n async writeDescriptor(options: WriteDescriptorOptions): Promise<void> {\n const descriptor = await this.getDescriptor(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await descriptor?.writeValue(dataView);\n }\n\n async startNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n characteristic?.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n characteristic?.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n await characteristic?.startNotifications();\n }\n\n private onCharacteristicValueChangedCallback = this.onCharacteristicValueChanged.bind(this);\n\n private onCharacteristicValueChanged(event: Event): void {\n const characteristic = event.target as BluetoothRemoteGATTCharacteristic;\n const key = `notification|${characteristic.service?.device.id}|${characteristic.service?.uuid}|${characteristic.uuid}`;\n this.notifyListeners(key, {\n value: characteristic.value,\n });\n }\n\n async stopNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n await characteristic?.stopNotifications();\n }\n\n private getFilters(options?: RequestBleDeviceOptions): BluetoothLEScanFilter[] {\n const filters: BluetoothLEScanFilter[] = [];\n for (const service of options?.services ?? []) {\n filters.push({\n services: [service],\n name: options?.name,\n namePrefix: options?.namePrefix,\n });\n }\n if ((options?.name || options?.namePrefix) && filters.length === 0) {\n filters.push({\n name: options.name,\n namePrefix: options.namePrefix,\n });\n }\n for (const manufacturerData of options?.manufacturerData ?? []) {\n // Cast to any to avoid type incompatibility - conversion is handled in bleClient.ts\n filters.push({\n manufacturerData: [manufacturerData as any],\n });\n }\n // Note: Web Bluetooth API does not support service data in scan filters.\n // Service data filtering will be done client-side in onAdvertisementReceived.\n // We still accept serviceData in options for API consistency across platforms.\n return filters;\n }\n\n private matchesServiceDataFilter(event: BluetoothAdvertisingEvent): boolean {\n const filters = this.requestBleDeviceOptions?.serviceData;\n if (!filters || filters.length === 0) {\n return true; // No filters, accept all\n }\n\n if (!event.serviceData) {\n return false; // No service data in advertisement\n }\n\n // Check if any filter matches (OR logic)\n for (const filter of filters) {\n const serviceData = event.serviceData.get(filter.serviceUuid);\n if (!serviceData) {\n continue; // This filter doesn't match, try next\n }\n\n // If we have service data for this UUID\n if (!filter.dataPrefix) {\n return true; // Filter matched by service UUID alone\n }\n\n // Check data prefix (DataView on web)\n const data = new Uint8Array(serviceData.buffer);\n const prefixView = filter.dataPrefix as DataView;\n\n if (data.length < prefixView.byteLength) {\n continue; // Data too short\n }\n\n // Apply mask if provided\n if (filter.mask) {\n const maskView = filter.mask as DataView;\n let matches = true;\n for (let i = 0; i < prefixView.byteLength; i++) {\n if ((data[i] & maskView.getUint8(i)) !== (prefixView.getUint8(i) & maskView.getUint8(i))) {\n matches = false;\n break;\n }\n }\n if (matches) {\n return true;\n }\n } else {\n // Check if data starts with prefix\n let matches = true;\n for (let i = 0; i < prefixView.byteLength; i++) {\n if (data[i] !== prefixView.getUint8(i)) {\n matches = false;\n break;\n }\n }\n if (matches) {\n return true;\n }\n }\n }\n\n return false; // No filter matched\n }\n\n private getDeviceFromMap(deviceId: string): BluetoothDevice {\n const device = this.deviceMap.get(deviceId);\n if (device === undefined) {\n throw new Error('Device not found. Call \"requestDevice\", \"requestLEScan\" or \"getDevices\" first.');\n }\n return device;\n }\n\n private getBleDevice(device: BluetoothDevice): BleDevice {\n const bleDevice: BleDevice = {\n deviceId: device.id,\n // use undefined instead of null if name is not available\n name: device.name ?? undefined,\n };\n return bleDevice;\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA0BjF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAA7C;;QACU,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,sBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,SAAI,GAA2B,IAAI,CAAC;QAEpC,+BAA0B,GAAG,KAAK,CAAC;QAsFnC,oCAA+B,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAwF1E,2BAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAiJxD,yCAAoC,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAuH9F,CAAC;IApbC,KAAK,CAAC,UAAU;QACd,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;YAC5D,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;QAChE,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;SACzD;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,uBAAuB;QAC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or/core';\r\n\r\nimport { hexStringToDataView, mapToObject, webUUIDToString } from './conversion';\r\nimport type {\r\n BleCharacteristic,\r\n BleCharacteristicProperties,\r\n BleDescriptor,\r\n BleService,\r\n TimeoutOptions,\r\n BleDevice,\r\n BleServices,\r\n BluetoothLePlugin,\r\n BooleanResult,\r\n DeviceIdOptions,\r\n GetConnectedDevicesOptions,\r\n GetDevicesOptions,\r\n GetDevicesResult,\r\n ReadDescriptorOptions,\r\n ReadOptions,\r\n ReadResult,\r\n ReadRssiResult,\r\n RequestBleDeviceOptions,\r\n ScanResultInternal,\r\n WriteOptions,\r\n WriteDescriptorOptions,\r\n GetMtuResult,\r\n RequestConnectionPriorityOptions,\r\n} from './definitions';\r\nimport { runWithTimeout } from './timeout';\r\n\r\nexport class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {\r\n private deviceMap = new Map<string, BluetoothDevice>();\r\n private discoveredDevices = new Map<string, boolean>();\r\n private scan: BluetoothLEScan | null = null;\r\n private requestBleDeviceOptions: RequestBleDeviceOptions | undefined;\r\n private DEFAULT_CONNECTION_TIMEOUT = 10000;\r\n\r\n async initialize(): Promise<void> {\r\n if (typeof navigator === 'undefined' || !navigator.bluetooth) {\r\n throw this.unavailable('Web Bluetooth API not available in this browser.');\r\n }\r\n const isAvailable = await navigator.bluetooth.getAvailability();\r\n if (!isAvailable) {\r\n throw this.unavailable('No Bluetooth radio available.');\r\n }\r\n }\r\n\r\n async isEnabled(): Promise<BooleanResult> {\r\n // not available on web\r\n return { value: true };\r\n }\r\n\r\n async requestEnable(): Promise<void> {\r\n throw this.unavailable('requestEnable is not available on web.');\r\n }\r\n\r\n async enable(): Promise<void> {\r\n throw this.unavailable('enable is not available on web.');\r\n }\r\n\r\n async disable(): Promise<void> {\r\n throw this.unavailable('disable is not available on web.');\r\n }\r\n\r\n async startEnabledNotifications(): Promise<void> {\r\n // not available on web\r\n }\r\n\r\n async stopEnabledNotifications(): Promise<void> {\r\n // not available on web\r\n }\r\n\r\n async isLocationEnabled(): Promise<BooleanResult> {\r\n throw this.unavailable('isLocationEnabled is not available on web.');\r\n }\r\n\r\n async openLocationSettings(): Promise<void> {\r\n throw this.unavailable('openLocationSettings is not available on web.');\r\n }\r\n\r\n async openBluetoothSettings(): Promise<void> {\r\n throw this.unavailable('openBluetoothSettings is not available on web.');\r\n }\r\n\r\n async openAppSettings(): Promise<void> {\r\n throw this.unavailable('openAppSettings is not available on web.');\r\n }\r\n\r\n async setDisplayStrings(): Promise<void> {\r\n // not available on web\r\n }\r\n\r\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\r\n const filters = this.getFilters(options);\r\n const device = await navigator.bluetooth.requestDevice({\r\n filters: filters.length ? filters : undefined,\r\n optionalServices: options?.optionalServices,\r\n acceptAllDevices: filters.length === 0,\r\n });\r\n this.deviceMap.set(device.id, device);\r\n const bleDevice = this.getBleDevice(device);\r\n return bleDevice;\r\n }\r\n\r\n async requestLEScan(options?: RequestBleDeviceOptions): Promise<void> {\r\n this.requestBleDeviceOptions = options;\r\n const filters = this.getFilters(options);\r\n await this.stopLEScan();\r\n this.discoveredDevices = new Map<string, boolean>();\r\n navigator.bluetooth.removeEventListener(\r\n 'advertisementreceived',\r\n this.onAdvertisementReceivedCallback as EventListener,\r\n );\r\n navigator.bluetooth.addEventListener('advertisementreceived', this.onAdvertisementReceivedCallback);\r\n this.scan = await navigator.bluetooth.requestLEScan({\r\n filters: filters.length ? filters : undefined,\r\n acceptAllAdvertisements: filters.length === 0,\r\n keepRepeatedDevices: options?.allowDuplicates,\r\n });\r\n }\r\n\r\n private onAdvertisementReceivedCallback = this.onAdvertisementReceived.bind(this);\r\n\r\n private onAdvertisementReceived(event: BluetoothAdvertisingEvent): void {\r\n const deviceId = event.device.id;\r\n this.deviceMap.set(deviceId, event.device);\r\n const isNew = !this.discoveredDevices.has(deviceId);\r\n\r\n // Apply service data filtering client-side (Web Bluetooth API doesn't support it in scan filters)\r\n if (this.requestBleDeviceOptions?.serviceData && !this.matchesServiceDataFilter(event)) {\r\n return;\r\n }\r\n\r\n if (isNew || this.requestBleDeviceOptions?.allowDuplicates) {\r\n this.discoveredDevices.set(deviceId, true);\r\n const device = this.getBleDevice(event.device);\r\n const result: ScanResultInternal = {\r\n device,\r\n localName: device.name,\r\n rssi: event.rssi,\r\n txPower: event.txPower,\r\n manufacturerData: mapToObject(event.manufacturerData),\r\n serviceData: mapToObject(event.serviceData),\r\n uuids: event.uuids?.map(webUUIDToString),\r\n };\r\n this.notifyListeners('onScanResult', result);\r\n }\r\n }\r\n\r\n async stopLEScan(): Promise<void> {\r\n if (this.scan?.active) {\r\n this.scan.stop();\r\n }\r\n this.scan = null;\r\n }\r\n\r\n async getDevices(options: GetDevicesOptions): Promise<GetDevicesResult> {\r\n const devices = await navigator.bluetooth.getDevices();\r\n const bleDevices = devices\r\n .filter((device) => options.deviceIds.includes(device.id))\r\n .map((device) => {\r\n this.deviceMap.set(device.id, device);\r\n const bleDevice = this.getBleDevice(device);\r\n return bleDevice;\r\n });\r\n return { devices: bleDevices };\r\n }\r\n\r\n async getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult> {\r\n const devices = await navigator.bluetooth.getDevices();\r\n const bleDevices = devices\r\n .filter((device) => {\r\n return device.gatt?.connected;\r\n })\r\n .map((device) => {\r\n this.deviceMap.set(device.id, device);\r\n const bleDevice = this.getBleDevice(device);\r\n return bleDevice;\r\n });\r\n return { devices: bleDevices };\r\n }\r\n\r\n async getBondedDevices(): Promise<GetDevicesResult> {\r\n return {} as Promise<GetDevicesResult>;\r\n }\r\n\r\n async connect(options: DeviceIdOptions & TimeoutOptions): Promise<void> {\r\n const device = this.getDeviceFromMap(options.deviceId);\r\n device.removeEventListener('gattserverdisconnected', this.onDisconnectedCallback);\r\n device.addEventListener('gattserverdisconnected', this.onDisconnectedCallback);\r\n const timeoutError = Symbol();\r\n if (device.gatt === undefined) {\r\n throw new Error('No gatt server available.');\r\n }\r\n try {\r\n const timeout = options.timeout ?? this.DEFAULT_CONNECTION_TIMEOUT;\r\n await runWithTimeout(device.gatt.connect(), timeout, timeoutError);\r\n } catch (error) {\r\n // cancel pending connect call, does not work yet in chromium because of a bug:\r\n // https://bugs.chromium.org/p/chromium/issues/detail?id=684073\r\n await device.gatt?.disconnect();\r\n if (error === timeoutError) {\r\n throw new Error('Connection timeout');\r\n } else {\r\n throw error;\r\n }\r\n }\r\n }\r\n\r\n private onDisconnectedCallback = this.onDisconnected.bind(this);\r\n\r\n private onDisconnected(event: Event): void {\r\n const deviceId = (event.target as BluetoothDevice).id;\r\n const key = `disconnected|${deviceId}`;\r\n this.notifyListeners(key, null);\r\n }\r\n\r\n async createBond(_options: DeviceIdOptions): Promise<void> {\r\n throw this.unavailable('createBond is not available on web.');\r\n }\r\n\r\n async isBonded(_options: DeviceIdOptions): Promise<BooleanResult> {\r\n throw this.unavailable('isBonded is not available on web.');\r\n }\r\n\r\n async disconnect(options: DeviceIdOptions): Promise<void> {\r\n this.getDeviceFromMap(options.deviceId).gatt?.disconnect();\r\n }\r\n\r\n async getServices(options: DeviceIdOptions): Promise<BleServices> {\r\n const services = (await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryServices()) ?? [];\r\n const bleServices: BleService[] = [];\r\n for (const service of services) {\r\n const characteristics = await service.getCharacteristics();\r\n const bleCharacteristics: BleCharacteristic[] = [];\r\n for (const characteristic of characteristics) {\r\n bleCharacteristics.push({\r\n uuid: characteristic.uuid,\r\n properties: this.getProperties(characteristic),\r\n descriptors: await this.getDescriptors(characteristic),\r\n });\r\n }\r\n bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics });\r\n }\r\n return { services: bleServices };\r\n }\r\n\r\n private async getDescriptors(characteristic: BluetoothRemoteGATTCharacteristic): Promise<BleDescriptor[]> {\r\n try {\r\n const descriptors = await characteristic.getDescriptors();\r\n return descriptors.map((descriptor) => ({\r\n uuid: descriptor.uuid,\r\n }));\r\n } catch {\r\n return [];\r\n }\r\n }\r\n\r\n private getProperties(characteristic: BluetoothRemoteGATTCharacteristic): BleCharacteristicProperties {\r\n return {\r\n broadcast: characteristic.properties.broadcast,\r\n read: characteristic.properties.read,\r\n writeWithoutResponse: characteristic.properties.writeWithoutResponse,\r\n write: characteristic.properties.write,\r\n notify: characteristic.properties.notify,\r\n indicate: characteristic.properties.indicate,\r\n authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites,\r\n reliableWrite: characteristic.properties.reliableWrite,\r\n writableAuxiliaries: characteristic.properties.writableAuxiliaries,\r\n };\r\n }\r\n\r\n private async getCharacteristic(\r\n options: ReadOptions | WriteOptions,\r\n ): Promise<BluetoothRemoteGATTCharacteristic | undefined> {\r\n const service = await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryService(options?.service);\r\n return service?.getCharacteristic(options?.characteristic);\r\n }\r\n\r\n private async getDescriptor(\r\n options: ReadDescriptorOptions | WriteDescriptorOptions,\r\n ): Promise<BluetoothRemoteGATTDescriptor | undefined> {\r\n const characteristic = await this.getCharacteristic(options);\r\n return characteristic?.getDescriptor(options?.descriptor);\r\n }\r\n\r\n async discoverServices(_options: DeviceIdOptions): Promise<void> {\r\n throw this.unavailable('discoverServices is not available on web.');\r\n }\r\n\r\n async getMtu(_options: DeviceIdOptions): Promise<GetMtuResult> {\r\n throw this.unavailable('getMtu is not available on web.');\r\n }\r\n\r\n async requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void> {\r\n throw this.unavailable('requestConnectionPriority is not available on web.');\r\n }\r\n\r\n async readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult> {\r\n throw this.unavailable('readRssi is not available on web.');\r\n }\r\n\r\n async read(options: ReadOptions): Promise<ReadResult> {\r\n const characteristic = await this.getCharacteristic(options);\r\n const value = await characteristic?.readValue();\r\n return { value };\r\n }\r\n\r\n async write(options: WriteOptions): Promise<void> {\r\n const characteristic = await this.getCharacteristic(options);\r\n let dataView: DataView;\r\n if (typeof options.value === 'string') {\r\n dataView = hexStringToDataView(options.value);\r\n } else {\r\n dataView = options.value;\r\n }\r\n await characteristic?.writeValueWithResponse(dataView);\r\n }\r\n\r\n async writeWithoutResponse(options: WriteOptions): Promise<void> {\r\n const characteristic = await this.getCharacteristic(options);\r\n let dataView: DataView;\r\n if (typeof options.value === 'string') {\r\n dataView = hexStringToDataView(options.value);\r\n } else {\r\n dataView = options.value;\r\n }\r\n await characteristic?.writeValueWithoutResponse(dataView);\r\n }\r\n\r\n async readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult> {\r\n const descriptor = await this.getDescriptor(options);\r\n const value = await descriptor?.readValue();\r\n return { value };\r\n }\r\n\r\n async writeDescriptor(options: WriteDescriptorOptions): Promise<void> {\r\n const descriptor = await this.getDescriptor(options);\r\n let dataView: DataView;\r\n if (typeof options.value === 'string') {\r\n dataView = hexStringToDataView(options.value);\r\n } else {\r\n dataView = options.value;\r\n }\r\n await descriptor?.writeValue(dataView);\r\n }\r\n\r\n async startNotifications(options: ReadOptions): Promise<void> {\r\n const characteristic = await this.getCharacteristic(options);\r\n characteristic?.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\r\n characteristic?.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\r\n await characteristic?.startNotifications();\r\n }\r\n\r\n private onCharacteristicValueChangedCallback = this.onCharacteristicValueChanged.bind(this);\r\n\r\n private onCharacteristicValueChanged(event: Event): void {\r\n const characteristic = event.target as BluetoothRemoteGATTCharacteristic;\r\n const key = `notification|${characteristic.service?.device.id}|${characteristic.service?.uuid}|${characteristic.uuid}`;\r\n this.notifyListeners(key, {\r\n value: characteristic.value,\r\n });\r\n }\r\n\r\n async stopNotifications(options: ReadOptions): Promise<void> {\r\n const characteristic = await this.getCharacteristic(options);\r\n await characteristic?.stopNotifications();\r\n }\r\n\r\n private getFilters(options?: RequestBleDeviceOptions): BluetoothLEScanFilter[] {\r\n const filters: BluetoothLEScanFilter[] = [];\r\n for (const service of options?.services ?? []) {\r\n filters.push({\r\n services: [service],\r\n name: options?.name,\r\n namePrefix: options?.namePrefix,\r\n });\r\n }\r\n if ((options?.name || options?.namePrefix) && filters.length === 0) {\r\n filters.push({\r\n name: options.name,\r\n namePrefix: options.namePrefix,\r\n });\r\n }\r\n for (const manufacturerData of options?.manufacturerData ?? []) {\r\n // Cast to any to avoid type incompatibility - conversion is handled in bleClient.ts\r\n filters.push({\r\n manufacturerData: [manufacturerData as any],\r\n });\r\n }\r\n // Note: Web Bluetooth API does not support service data in scan filters.\r\n // Service data filtering will be done client-side in onAdvertisementReceived.\r\n // We still accept serviceData in options for API consistency across platforms.\r\n return filters;\r\n }\r\n\r\n private matchesServiceDataFilter(event: BluetoothAdvertisingEvent): boolean {\r\n const filters = this.requestBleDeviceOptions?.serviceData;\r\n if (!filters || filters.length === 0) {\r\n return true; // No filters, accept all\r\n }\r\n\r\n if (!event.serviceData) {\r\n return false; // No service data in advertisement\r\n }\r\n\r\n // Check if any filter matches (OR logic)\r\n for (const filter of filters) {\r\n const serviceData = event.serviceData.get(filter.serviceUuid);\r\n if (!serviceData) {\r\n continue; // This filter doesn't match, try next\r\n }\r\n\r\n // If we have service data for this UUID\r\n if (!filter.dataPrefix) {\r\n return true; // Filter matched by service UUID alone\r\n }\r\n\r\n // Check data prefix (DataView on web)\r\n const data = new Uint8Array(serviceData.buffer);\r\n const prefixView = filter.dataPrefix as DataView;\r\n\r\n if (data.length < prefixView.byteLength) {\r\n continue; // Data too short\r\n }\r\n\r\n // Apply mask if provided\r\n if (filter.mask) {\r\n const maskView = filter.mask as DataView;\r\n let matches = true;\r\n for (let i = 0; i < prefixView.byteLength; i++) {\r\n if ((data[i] & maskView.getUint8(i)) !== (prefixView.getUint8(i) & maskView.getUint8(i))) {\r\n matches = false;\r\n break;\r\n }\r\n }\r\n if (matches) {\r\n return true;\r\n }\r\n } else {\r\n // Check if data starts with prefix\r\n let matches = true;\r\n for (let i = 0; i < prefixView.byteLength; i++) {\r\n if (data[i] !== prefixView.getUint8(i)) {\r\n matches = false;\r\n break;\r\n }\r\n }\r\n if (matches) {\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n return false; // No filter matched\r\n }\r\n\r\n private getDeviceFromMap(deviceId: string): BluetoothDevice {\r\n const device = this.deviceMap.get(deviceId);\r\n if (device === undefined) {\r\n throw new Error('Device not found. Call \"requestDevice\", \"requestLEScan\" or \"getDevices\" first.');\r\n }\r\n return device;\r\n }\r\n\r\n private getBleDevice(device: BluetoothDevice): BleDevice {\r\n const bleDevice: BleDevice = {\r\n deviceId: device.id,\r\n // use undefined instead of null if name is not available\r\n name: device.name ?? undefined,\r\n };\r\n return bleDevice;\r\n }\r\n}\r\n"]}
@@ -178,8 +178,8 @@ class DeviceManager: NSObject, CBCentralManagerDelegate {
178
178
 
179
179
  guard self.passesNameFilter(peripheralName: peripheral.name) else { return }
180
180
  guard self.passesNamePrefixFilter(peripheralName: peripheral.name) else { return }
181
- guard self.passesManufacturerDataFilter(advertisementData) else { return }
182
- guard self.passesServiceDataFilter(advertisementData) else { return }
181
+ guard ScanFilterUtils.passesManufacturerDataFilter(advertisementData, filters: self.manufacturerDataFilters) else { return }
182
+ guard ScanFilterUtils.passesServiceDataFilter(advertisementData, filters: self.serviceDataFilters) else { return }
183
183
 
184
184
  let device: Device
185
185
  if self.allowDuplicates, let knownDevice = discoveredDevices.first(where: { $0.key == peripheral.identifier.uuidString })?.value {
@@ -360,94 +360,6 @@ class DeviceManager: NSObject, CBCentralManagerDelegate {
360
360
  return name.hasPrefix(prefix)
361
361
  }
362
362
 
363
- private func passesManufacturerDataFilter(_ advertisementData: [String: Any]) -> Bool {
364
- guard let filters = self.manufacturerDataFilters, !filters.isEmpty else {
365
- return true // No filters means everything passes
366
- }
367
-
368
- guard let manufacturerData = advertisementData[CBAdvertisementDataManufacturerDataKey] as? Data,
369
- manufacturerData.count >= 2 else {
370
- return false // If there's no valid manufacturer data, fail
371
- }
372
-
373
- let companyIdentifier = manufacturerData.prefix(2).withUnsafeBytes {
374
- $0.load(as: UInt16.self).littleEndian // Manufacturer ID is little-endian
375
- }
376
-
377
- let payload = manufacturerData.dropFirst(2)
378
-
379
- for filter in filters {
380
- if filter.companyIdentifier != companyIdentifier {
381
- continue // Skip if company ID does not match
382
- }
383
-
384
- if let dataPrefix = filter.dataPrefix {
385
- if payload.count < dataPrefix.count {
386
- continue // Payload too short, does not match
387
- }
388
-
389
- if let mask = filter.mask {
390
- var matches = true
391
- for i in 0..<dataPrefix.count {
392
- if (payload[i] & mask[i]) != (dataPrefix[i] & mask[i]) {
393
- matches = false
394
- break
395
- }
396
- }
397
- if matches {
398
- return true
399
- }
400
- } else if payload.starts(with: dataPrefix) {
401
- return true
402
- }
403
- } else {
404
- return true // Company ID matched, and no dataPrefix required
405
- }
406
- }
407
-
408
- return false // If none matched, return false
409
- }
410
-
411
- private func passesServiceDataFilter(_ advertisementData: [String: Any]) -> Bool {
412
- guard let filters = self.serviceDataFilters, !filters.isEmpty else {
413
- return true // No filters means everything passes
414
- }
415
-
416
- guard let serviceDataDict = advertisementData[CBAdvertisementDataServiceDataKey] as? [CBUUID: Data] else {
417
- return false // If there's no service data, fail
418
- }
419
-
420
- for filter in filters {
421
- guard let serviceData = serviceDataDict[filter.serviceUuid] else {
422
- continue // Skip if service UUID does not match
423
- }
424
-
425
- if let dataPrefix = filter.dataPrefix {
426
- if serviceData.count < dataPrefix.count {
427
- continue // Service data too short, does not match
428
- }
429
-
430
- if let mask = filter.mask {
431
- var matches = true
432
- for i in 0..<dataPrefix.count {
433
- if (serviceData[i] & mask[i]) != (dataPrefix[i] & mask[i]) {
434
- matches = false
435
- break
436
- }
437
- }
438
- if matches {
439
- return true
440
- }
441
- } else if serviceData.starts(with: dataPrefix) {
442
- return true
443
- }
444
- } else {
445
- return true // Service UUID matched, and no dataPrefix required
446
- }
447
- }
448
-
449
- return false // If none matched, return false
450
- }
451
363
 
452
364
  private func resolve(_ key: String, _ value: String) {
453
365
  let callback = self.callbackMap[key]
@@ -7,18 +7,6 @@ import CoreBluetooth
7
7
  let CONNECTION_TIMEOUT: Double = 10
8
8
  let DEFAULT_TIMEOUT: Double = 5
9
9
 
10
- struct ManufacturerDataFilter {
11
- let companyIdentifier: UInt16
12
- let dataPrefix: Data?
13
- let mask: Data?
14
- }
15
-
16
- struct ServiceDataFilter {
17
- let serviceUuid: CBUUID
18
- let dataPrefix: Data?
19
- let mask: Data?
20
- }
21
-
22
10
  @objc(BluetoothLe)
23
11
  public class BluetoothLe: CAPPlugin {
24
12
  typealias BleDevice = [String: Any]
@@ -0,0 +1,114 @@
1
+ import Foundation
2
+ import CoreBluetooth
3
+
4
+ struct ManufacturerDataFilter {
5
+ let companyIdentifier: UInt16
6
+ let dataPrefix: Data?
7
+ let mask: Data?
8
+ }
9
+
10
+ struct ServiceDataFilter {
11
+ let serviceUuid: CBUUID
12
+ let dataPrefix: Data?
13
+ let mask: Data?
14
+ }
15
+
16
+ class ScanFilterUtils {
17
+
18
+ static func passesManufacturerDataFilter(_ advertisementData: [String: Any], filters: [ManufacturerDataFilter]?) -> Bool {
19
+ guard let filters = filters, !filters.isEmpty else {
20
+ return true // No filters means everything passes
21
+ }
22
+
23
+ guard let manufacturerData = advertisementData[CBAdvertisementDataManufacturerDataKey] as? Data,
24
+ manufacturerData.count >= 2 else {
25
+ return false // If there's no valid manufacturer data, fail
26
+ }
27
+
28
+ let companyIdentifier = manufacturerData.prefix(2).withUnsafeBytes {
29
+ $0.load(as: UInt16.self).littleEndian // Manufacturer ID is little-endian
30
+ }
31
+
32
+ let payload = Data(manufacturerData.dropFirst(2))
33
+
34
+ for filter in filters {
35
+ if filter.companyIdentifier != companyIdentifier {
36
+ continue // Skip if company ID does not match
37
+ }
38
+
39
+ if let dataPrefix = filter.dataPrefix {
40
+ if payload.count < dataPrefix.count {
41
+ continue // Payload too short, does not match
42
+ }
43
+
44
+ if let mask = filter.mask {
45
+ // Validate that mask length matches dataPrefix length
46
+ if mask.count != dataPrefix.count {
47
+ continue // Skip this filter if mask length is invalid
48
+ }
49
+ var matches = true
50
+ for i in 0..<dataPrefix.count {
51
+ if (payload[i] & mask[i]) != (dataPrefix[i] & mask[i]) {
52
+ matches = false
53
+ break
54
+ }
55
+ }
56
+ if matches {
57
+ return true
58
+ }
59
+ } else if payload.starts(with: dataPrefix) {
60
+ return true
61
+ }
62
+ } else {
63
+ return true // Company ID matched, and no dataPrefix required
64
+ }
65
+ }
66
+
67
+ return false // If none matched, return false
68
+ }
69
+
70
+ static func passesServiceDataFilter(_ advertisementData: [String: Any], filters: [ServiceDataFilter]?) -> Bool {
71
+ guard let filters = filters, !filters.isEmpty else {
72
+ return true // No filters means everything passes
73
+ }
74
+
75
+ guard let serviceDataDict = advertisementData[CBAdvertisementDataServiceDataKey] as? [CBUUID: Data] else {
76
+ return false // If there's no service data, fail
77
+ }
78
+
79
+ for filter in filters {
80
+ guard let serviceData = serviceDataDict[filter.serviceUuid] else {
81
+ continue // Skip if service UUID does not match
82
+ }
83
+
84
+ if let dataPrefix = filter.dataPrefix {
85
+ if serviceData.count < dataPrefix.count {
86
+ continue // Service data too short, does not match
87
+ }
88
+
89
+ if let mask = filter.mask {
90
+ // Validate that mask length matches dataPrefix length
91
+ if mask.count != dataPrefix.count {
92
+ continue // Skip this filter if mask length is invalid
93
+ }
94
+ var matches = true
95
+ for i in 0..<dataPrefix.count {
96
+ if (serviceData[i] & mask[i]) != (dataPrefix[i] & mask[i]) {
97
+ matches = false
98
+ break
99
+ }
100
+ }
101
+ if matches {
102
+ return true
103
+ }
104
+ } else if serviceData.starts(with: dataPrefix) {
105
+ return true
106
+ }
107
+ } else {
108
+ return true // Service UUID matched, and no dataPrefix required
109
+ }
110
+ }
111
+
112
+ return false // If none matched, return false
113
+ }
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/bluetooth-le",
3
- "version": "7.3.0",
3
+ "version": "7.3.1",
4
4
  "description": "Capacitor plugin for Bluetooth Low Energy ",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",