@capacitor-community/bluetooth-le 7.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CapacitorCommunityBluetoothLe.podspec +17 -17
  2. package/LICENSE +21 -21
  3. package/README.md +95 -26
  4. package/android/build.gradle +68 -68
  5. package/android/src/main/AndroidManifest.xml +22 -22
  6. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1061 -1009
  7. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
  8. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +720 -718
  9. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
  10. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
  11. package/dist/docs.json +892 -78
  12. package/dist/esm/bleClient.d.ts +277 -277
  13. package/dist/esm/bleClient.js +349 -349
  14. package/dist/esm/bleClient.js.map +1 -1
  15. package/dist/esm/config.d.ts +53 -53
  16. package/dist/esm/config.js +2 -2
  17. package/dist/esm/config.js.map +1 -1
  18. package/dist/esm/conversion.d.ts +34 -34
  19. package/dist/esm/conversion.js +84 -84
  20. package/dist/esm/conversion.js.map +1 -1
  21. package/dist/esm/definitions.d.ts +301 -292
  22. package/dist/esm/definitions.js +42 -42
  23. package/dist/esm/definitions.js.map +1 -1
  24. package/dist/esm/index.d.ts +5 -5
  25. package/dist/esm/index.js +5 -5
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/plugin.d.ts +2 -2
  28. package/dist/esm/plugin.js +4 -4
  29. package/dist/esm/plugin.js.map +1 -1
  30. package/dist/esm/queue.d.ts +3 -3
  31. package/dist/esm/queue.js +17 -17
  32. package/dist/esm/queue.js.map +1 -1
  33. package/dist/esm/timeout.d.ts +1 -1
  34. package/dist/esm/timeout.js +9 -9
  35. package/dist/esm/timeout.js.map +1 -1
  36. package/dist/esm/validators.d.ts +1 -1
  37. package/dist/esm/validators.js +11 -11
  38. package/dist/esm/validators.js.map +1 -1
  39. package/dist/esm/web.d.ts +56 -56
  40. package/dist/esm/web.js +340 -335
  41. package/dist/esm/web.js.map +1 -1
  42. package/dist/plugin.cjs.js +841 -834
  43. package/dist/plugin.cjs.js.map +1 -1
  44. package/dist/plugin.js +841 -834
  45. package/dist/plugin.js.map +1 -1
  46. package/ios/Plugin/Conversion.swift +83 -83
  47. package/ios/Plugin/Device.swift +423 -423
  48. package/ios/Plugin/DeviceManager.swift +401 -349
  49. package/ios/Plugin/Info.plist +24 -24
  50. package/ios/Plugin/Logging.swift +8 -8
  51. package/ios/Plugin/Plugin.h +10 -10
  52. package/ios/Plugin/Plugin.m +41 -41
  53. package/ios/Plugin/Plugin.swift +682 -636
  54. package/ios/Plugin/ThreadSafeDictionary.swift +13 -13
  55. package/package.json +101 -101
@@ -1,43 +1,43 @@
1
- /**
2
- * Android scan mode
3
- */
4
- export var ScanMode;
5
- (function (ScanMode) {
6
- /**
7
- * Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.
8
- * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER
9
- */
10
- ScanMode[ScanMode["SCAN_MODE_LOW_POWER"] = 0] = "SCAN_MODE_LOW_POWER";
11
- /**
12
- * 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.
13
- * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED
14
- */
15
- ScanMode[ScanMode["SCAN_MODE_BALANCED"] = 1] = "SCAN_MODE_BALANCED";
16
- /**
17
- * Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.
18
- * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY
19
- */
20
- ScanMode[ScanMode["SCAN_MODE_LOW_LATENCY"] = 2] = "SCAN_MODE_LOW_LATENCY";
21
- })(ScanMode || (ScanMode = {}));
22
- /**
23
- * Android connection priority used in `requestConnectionPriority`
24
- */
25
- export var ConnectionPriority;
26
- (function (ConnectionPriority) {
27
- /**
28
- * Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.
29
- * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED
30
- */
31
- ConnectionPriority[ConnectionPriority["CONNECTION_PRIORITY_BALANCED"] = 0] = "CONNECTION_PRIORITY_BALANCED";
32
- /**
33
- * 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.
34
- * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH
35
- */
36
- ConnectionPriority[ConnectionPriority["CONNECTION_PRIORITY_HIGH"] = 1] = "CONNECTION_PRIORITY_HIGH";
37
- /**
38
- * Request low power, reduced data rate connection parameters.
39
- * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER
40
- */
41
- ConnectionPriority[ConnectionPriority["CONNECTION_PRIORITY_LOW_POWER"] = 2] = "CONNECTION_PRIORITY_LOW_POWER";
42
- })(ConnectionPriority || (ConnectionPriority = {}));
1
+ /**
2
+ * Android scan mode
3
+ */
4
+ export var ScanMode;
5
+ (function (ScanMode) {
6
+ /**
7
+ * Perform Bluetooth LE scan in low power mode. This mode is enforced if the scanning application is not in foreground.
8
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_POWER
9
+ */
10
+ ScanMode[ScanMode["SCAN_MODE_LOW_POWER"] = 0] = "SCAN_MODE_LOW_POWER";
11
+ /**
12
+ * 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.
13
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_BALANCED
14
+ */
15
+ ScanMode[ScanMode["SCAN_MODE_BALANCED"] = 1] = "SCAN_MODE_BALANCED";
16
+ /**
17
+ * Scan using highest duty cycle. It's recommended to only use this mode when the application is running in the foreground.
18
+ * https://developer.android.com/reference/android/bluetooth/le/ScanSettings#SCAN_MODE_LOW_LATENCY
19
+ */
20
+ ScanMode[ScanMode["SCAN_MODE_LOW_LATENCY"] = 2] = "SCAN_MODE_LOW_LATENCY";
21
+ })(ScanMode || (ScanMode = {}));
22
+ /**
23
+ * Android connection priority used in `requestConnectionPriority`
24
+ */
25
+ export var ConnectionPriority;
26
+ (function (ConnectionPriority) {
27
+ /**
28
+ * Use the connection parameters recommended by the Bluetooth SIG. This is the default value if no connection parameter update is requested.
29
+ * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_BALANCED
30
+ */
31
+ ConnectionPriority[ConnectionPriority["CONNECTION_PRIORITY_BALANCED"] = 0] = "CONNECTION_PRIORITY_BALANCED";
32
+ /**
33
+ * 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.
34
+ * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_HIGH
35
+ */
36
+ ConnectionPriority[ConnectionPriority["CONNECTION_PRIORITY_HIGH"] = 1] = "CONNECTION_PRIORITY_HIGH";
37
+ /**
38
+ * Request low power, reduced data rate connection parameters.
39
+ * https://developer.android.com/reference/android/bluetooth/BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER
40
+ */
41
+ ConnectionPriority[ConnectionPriority["CONNECTION_PRIORITY_LOW_POWER"] = 2] = "CONNECTION_PRIORITY_LOW_POWER";
42
+ })(ConnectionPriority || (ConnectionPriority = {}));
43
43
  //# sourceMappingURL=definitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAkDA;;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\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 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): Promise<void>;\n stopNotifications(options: ReadOptions): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuDA;;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?: { companyIdentifier: number; dataPrefix?: Uint8Array; mask?: Uint8Array }[];\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 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): Promise<void>;\r\n stopNotifications(options: ReadOptions): Promise<void>;\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
- export * from './definitions';
2
- export * from './bleClient';
3
- export * from './conversion';
4
- export * from './plugin';
5
- export * from './config';
1
+ export * from './definitions';
2
+ export * from './bleClient';
3
+ export * from './conversion';
4
+ export * from './plugin';
5
+ export * from './config';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from './definitions';
2
- export * from './bleClient';
3
- export * from './conversion';
4
- export * from './plugin';
5
- export * from './config';
1
+ export * from './definitions';
2
+ export * from './bleClient';
3
+ export * from './conversion';
4
+ export * from './plugin';
5
+ export * from './config';
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC","sourcesContent":["export * from './definitions';\nexport * from './bleClient';\nexport * from './conversion';\nexport * from './plugin';\nexport * from './config';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC","sourcesContent":["export * from './definitions';\r\nexport * from './bleClient';\r\nexport * from './conversion';\r\nexport * from './plugin';\r\nexport * from './config';\r\n"]}
@@ -1,2 +1,2 @@
1
- import type { BluetoothLePlugin } from './definitions';
2
- export declare const BluetoothLe: BluetoothLePlugin;
1
+ import type { BluetoothLePlugin } from './definitions';
2
+ export declare const BluetoothLe: BluetoothLePlugin;
@@ -1,5 +1,5 @@
1
- import { registerPlugin } from '@capacitor/core';
2
- export const BluetoothLe = registerPlugin('BluetoothLe', {
3
- web: () => import('./web').then((m) => new m.BluetoothLeWeb()),
4
- });
1
+ import { registerPlugin } from '@capacitor/core';
2
+ export const BluetoothLe = registerPlugin('BluetoothLe', {
3
+ web: () => import('./web').then((m) => new m.BluetoothLeWeb()),
4
+ });
5
5
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IAC1E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC/D,CAAC,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { BluetoothLePlugin } from './definitions';\n\nexport const BluetoothLe = registerPlugin<BluetoothLePlugin>('BluetoothLe', {\n web: () => import('./web').then((m) => new m.BluetoothLeWeb()),\n});\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAoB,aAAa,EAAE;IAC1E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC/D,CAAC,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\n\r\nimport type { BluetoothLePlugin } from './definitions';\r\n\r\nexport const BluetoothLe = registerPlugin<BluetoothLePlugin>('BluetoothLe', {\r\n web: () => import('./web').then((m) => new m.BluetoothLeWeb()),\r\n});\r\n"]}
@@ -1,3 +1,3 @@
1
- type Queue = <T>(fn: () => Promise<T>) => Promise<T>;
2
- export declare function getQueue(enabled: boolean): Queue;
3
- export {};
1
+ type Queue = <T>(fn: () => Promise<T>) => Promise<T>;
2
+ export declare function getQueue(enabled: boolean): Queue;
3
+ export {};
package/dist/esm/queue.js CHANGED
@@ -1,18 +1,18 @@
1
- const makeQueue = () => {
2
- let currentTask = Promise.resolve();
3
- // create a new promise so that errors can be bubbled
4
- // up to the caller without being caught by the queue
5
- return (fn) => new Promise((resolve, reject) => {
6
- currentTask = currentTask
7
- .then(() => fn())
8
- .then(resolve)
9
- .catch(reject);
10
- });
11
- };
12
- export function getQueue(enabled) {
13
- if (enabled) {
14
- return makeQueue();
15
- }
16
- return (fn) => fn();
17
- }
1
+ const makeQueue = () => {
2
+ let currentTask = Promise.resolve();
3
+ // create a new promise so that errors can be bubbled
4
+ // up to the caller without being caught by the queue
5
+ return (fn) => new Promise((resolve, reject) => {
6
+ currentTask = currentTask
7
+ .then(() => fn())
8
+ .then(resolve)
9
+ .catch(reject);
10
+ });
11
+ };
12
+ export function getQueue(enabled) {
13
+ if (enabled) {
14
+ return makeQueue();
15
+ }
16
+ return (fn) => fn();
17
+ }
18
18
  //# sourceMappingURL=queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,GAAU,EAAE;IAC5B,IAAI,WAAW,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IACtD,qDAAqD;IACrD,qDAAqD;IACrD,OAAO,CAAC,EAAE,EAAE,EAAE,CACZ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9B,WAAW,GAAG,WAAW;aACtB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;aAChB,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,IAAI,OAAO,EAAE;QACX,OAAO,SAAS,EAAE,CAAC;KACpB;IACD,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AACtB,CAAC","sourcesContent":["type Queue = <T>(fn: () => Promise<T>) => Promise<T>;\n\nconst makeQueue = (): Queue => {\n let currentTask: Promise<unknown> = Promise.resolve();\n // create a new promise so that errors can be bubbled\n // up to the caller without being caught by the queue\n return (fn) =>\n new Promise((resolve, reject) => {\n currentTask = currentTask\n .then(() => fn())\n .then(resolve)\n .catch(reject);\n });\n};\n\nexport function getQueue(enabled: boolean): Queue {\n if (enabled) {\n return makeQueue();\n }\n return (fn) => fn();\n}\n"]}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,GAAU,EAAE;IAC5B,IAAI,WAAW,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IACtD,qDAAqD;IACrD,qDAAqD;IACrD,OAAO,CAAC,EAAE,EAAE,EAAE,CACZ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9B,WAAW,GAAG,WAAW;aACtB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;aAChB,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,IAAI,OAAO,EAAE;QACX,OAAO,SAAS,EAAE,CAAC;KACpB;IACD,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AACtB,CAAC","sourcesContent":["type Queue = <T>(fn: () => Promise<T>) => Promise<T>;\r\n\r\nconst makeQueue = (): Queue => {\r\n let currentTask: Promise<unknown> = Promise.resolve();\r\n // create a new promise so that errors can be bubbled\r\n // up to the caller without being caught by the queue\r\n return (fn) =>\r\n new Promise((resolve, reject) => {\r\n currentTask = currentTask\r\n .then(() => fn())\r\n .then(resolve)\r\n .catch(reject);\r\n });\r\n};\r\n\r\nexport function getQueue(enabled: boolean): Queue {\r\n if (enabled) {\r\n return makeQueue();\r\n }\r\n return (fn) => fn();\r\n}\r\n"]}
@@ -1 +1 @@
1
- export declare function runWithTimeout(promise: Promise<unknown>, time: number, exception: symbol): Promise<unknown>;
1
+ export declare function runWithTimeout(promise: Promise<unknown>, time: number, exception: symbol): Promise<unknown>;
@@ -1,10 +1,10 @@
1
- export async function runWithTimeout(promise, time, exception) {
2
- let timer;
3
- return Promise.race([
4
- promise,
5
- new Promise((_, reject) => {
6
- timer = setTimeout(() => reject(exception), time);
7
- }),
8
- ]).finally(() => clearTimeout(timer));
9
- }
1
+ export async function runWithTimeout(promise, time, exception) {
2
+ let timer;
3
+ return Promise.race([
4
+ promise,
5
+ new Promise((_, reject) => {
6
+ timer = setTimeout(() => reject(exception), time);
7
+ }),
8
+ ]).finally(() => clearTimeout(timer));
9
+ }
10
10
  //# sourceMappingURL=timeout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/timeout.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAyB,EAAE,IAAY,EAAE,SAAiB;IAC7F,IAAI,KAAoC,CAAC;IACzC,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,OAAO;QACP,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YACxB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC;KACH,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["export async function runWithTimeout(promise: Promise<unknown>, time: number, exception: symbol): Promise<unknown> {\n let timer: ReturnType<typeof setTimeout>;\n return Promise.race([\n promise,\n new Promise((_, reject) => {\n timer = setTimeout(() => reject(exception), time);\n }),\n ]).finally(() => clearTimeout(timer));\n}\n"]}
1
+ {"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/timeout.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAyB,EAAE,IAAY,EAAE,SAAiB;IAC7F,IAAI,KAAoC,CAAC;IACzC,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,OAAO;QACP,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YACxB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC;KACH,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACxC,CAAC","sourcesContent":["export async function runWithTimeout(promise: Promise<unknown>, time: number, exception: symbol): Promise<unknown> {\r\n let timer: ReturnType<typeof setTimeout>;\r\n return Promise.race([\r\n promise,\r\n new Promise((_, reject) => {\r\n timer = setTimeout(() => reject(exception), time);\r\n }),\r\n ]).finally(() => clearTimeout(timer));\r\n}\r\n"]}
@@ -1 +1 @@
1
- export declare function parseUUID(uuid: any): string;
1
+ export declare function parseUUID(uuid: any): string;
@@ -1,12 +1,12 @@
1
- export function parseUUID(uuid) {
2
- if (typeof uuid !== 'string') {
3
- throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);
4
- }
5
- uuid = uuid.toLowerCase();
6
- const is128BitUuid = uuid.search(/^[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}$/) >= 0;
7
- if (!is128BitUuid) {
8
- throw new Error(`Invalid UUID format ${uuid}. Expected 128 bit string (e.g. "0000180d-0000-1000-8000-00805f9b34fb").`);
9
- }
10
- return uuid;
11
- }
1
+ export function parseUUID(uuid) {
2
+ if (typeof uuid !== 'string') {
3
+ throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);
4
+ }
5
+ uuid = uuid.toLowerCase();
6
+ const is128BitUuid = uuid.search(/^[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}$/) >= 0;
7
+ if (!is128BitUuid) {
8
+ throw new Error(`Invalid UUID format ${uuid}. Expected 128 bit string (e.g. "0000180d-0000-1000-8000-00805f9b34fb").`);
9
+ }
10
+ return uuid;
11
+ }
12
12
  //# sourceMappingURL=validators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/validators.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAS;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,IAAI,oBAAoB,CAAC,CAAC;KACvE;IACD,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,wEAAwE,CAAC,IAAI,CAAC,CAAC;IAChH,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,0EAA0E,CACtG,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function parseUUID(uuid: any): string {\n if (typeof uuid !== 'string') {\n throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);\n }\n uuid = uuid.toLowerCase();\n const is128BitUuid = uuid.search(/^[0-9a-f]{8}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{12}$/) >= 0;\n if (!is128BitUuid) {\n throw new Error(\n `Invalid UUID format ${uuid}. Expected 128 bit string (e.g. \"0000180d-0000-1000-8000-00805f9b34fb\").`,\n );\n }\n return uuid;\n}\n"]}
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/validators.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAS;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,IAAI,oBAAoB,CAAC,CAAC;KACvE;IACD,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,wEAAwE,CAAC,IAAI,CAAC,CAAC;IAChH,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,0EAA0E,CACtG,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function parseUUID(uuid: any): string {\r\n if (typeof uuid !== 'string') {\r\n throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);\r\n }\r\n uuid = uuid.toLowerCase();\r\n const is128BitUuid = uuid.search(/^[0-9a-f]{8}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{12}$/) >= 0;\r\n if (!is128BitUuid) {\r\n throw new Error(\r\n `Invalid UUID format ${uuid}. Expected 128 bit string (e.g. \"0000180d-0000-1000-8000-00805f9b34fb\").`,\r\n );\r\n }\r\n return uuid;\r\n}\r\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,56 +1,56 @@
1
- import { WebPlugin } from '@capacitor/core';
2
- import type { TimeoutOptions, BleDevice, BleServices, BluetoothLePlugin, BooleanResult, DeviceIdOptions, GetConnectedDevicesOptions, GetDevicesOptions, GetDevicesResult, ReadDescriptorOptions, ReadOptions, ReadResult, ReadRssiResult, RequestBleDeviceOptions, WriteOptions, WriteDescriptorOptions, GetMtuResult, RequestConnectionPriorityOptions } from './definitions';
3
- export declare class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {
4
- private deviceMap;
5
- private discoveredDevices;
6
- private scan;
7
- private requestBleDeviceOptions;
8
- private DEFAULT_CONNECTION_TIMEOUT;
9
- initialize(): Promise<void>;
10
- isEnabled(): Promise<BooleanResult>;
11
- requestEnable(): Promise<void>;
12
- enable(): Promise<void>;
13
- disable(): Promise<void>;
14
- startEnabledNotifications(): Promise<void>;
15
- stopEnabledNotifications(): Promise<void>;
16
- isLocationEnabled(): Promise<BooleanResult>;
17
- openLocationSettings(): Promise<void>;
18
- openBluetoothSettings(): Promise<void>;
19
- openAppSettings(): Promise<void>;
20
- setDisplayStrings(): Promise<void>;
21
- requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;
22
- requestLEScan(options?: RequestBleDeviceOptions): Promise<void>;
23
- private onAdvertisementReceivedCallback;
24
- private onAdvertisementReceived;
25
- stopLEScan(): Promise<void>;
26
- getDevices(options: GetDevicesOptions): Promise<GetDevicesResult>;
27
- getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult>;
28
- getBondedDevices(): Promise<GetDevicesResult>;
29
- connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
30
- private onDisconnectedCallback;
31
- private onDisconnected;
32
- createBond(_options: DeviceIdOptions): Promise<void>;
33
- isBonded(_options: DeviceIdOptions): Promise<BooleanResult>;
34
- disconnect(options: DeviceIdOptions): Promise<void>;
35
- getServices(options: DeviceIdOptions): Promise<BleServices>;
36
- private getDescriptors;
37
- private getProperties;
38
- private getCharacteristic;
39
- private getDescriptor;
40
- discoverServices(_options: DeviceIdOptions): Promise<void>;
41
- getMtu(_options: DeviceIdOptions): Promise<GetMtuResult>;
42
- requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void>;
43
- readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult>;
44
- read(options: ReadOptions): Promise<ReadResult>;
45
- write(options: WriteOptions): Promise<void>;
46
- writeWithoutResponse(options: WriteOptions): Promise<void>;
47
- readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult>;
48
- writeDescriptor(options: WriteDescriptorOptions): Promise<void>;
49
- startNotifications(options: ReadOptions): Promise<void>;
50
- private onCharacteristicValueChangedCallback;
51
- private onCharacteristicValueChanged;
52
- stopNotifications(options: ReadOptions): Promise<void>;
53
- private getFilters;
54
- private getDeviceFromMap;
55
- private getBleDevice;
56
- }
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { TimeoutOptions, BleDevice, BleServices, BluetoothLePlugin, BooleanResult, DeviceIdOptions, GetConnectedDevicesOptions, GetDevicesOptions, GetDevicesResult, ReadDescriptorOptions, ReadOptions, ReadResult, ReadRssiResult, RequestBleDeviceOptions, WriteOptions, WriteDescriptorOptions, GetMtuResult, RequestConnectionPriorityOptions } from './definitions';
3
+ export declare class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {
4
+ private deviceMap;
5
+ private discoveredDevices;
6
+ private scan;
7
+ private requestBleDeviceOptions;
8
+ private DEFAULT_CONNECTION_TIMEOUT;
9
+ initialize(): Promise<void>;
10
+ isEnabled(): Promise<BooleanResult>;
11
+ requestEnable(): Promise<void>;
12
+ enable(): Promise<void>;
13
+ disable(): Promise<void>;
14
+ startEnabledNotifications(): Promise<void>;
15
+ stopEnabledNotifications(): Promise<void>;
16
+ isLocationEnabled(): Promise<BooleanResult>;
17
+ openLocationSettings(): Promise<void>;
18
+ openBluetoothSettings(): Promise<void>;
19
+ openAppSettings(): Promise<void>;
20
+ setDisplayStrings(): Promise<void>;
21
+ requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice>;
22
+ requestLEScan(options?: RequestBleDeviceOptions): Promise<void>;
23
+ private onAdvertisementReceivedCallback;
24
+ private onAdvertisementReceived;
25
+ stopLEScan(): Promise<void>;
26
+ getDevices(options: GetDevicesOptions): Promise<GetDevicesResult>;
27
+ getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult>;
28
+ getBondedDevices(): Promise<GetDevicesResult>;
29
+ connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
30
+ private onDisconnectedCallback;
31
+ private onDisconnected;
32
+ createBond(_options: DeviceIdOptions): Promise<void>;
33
+ isBonded(_options: DeviceIdOptions): Promise<BooleanResult>;
34
+ disconnect(options: DeviceIdOptions): Promise<void>;
35
+ getServices(options: DeviceIdOptions): Promise<BleServices>;
36
+ private getDescriptors;
37
+ private getProperties;
38
+ private getCharacteristic;
39
+ private getDescriptor;
40
+ discoverServices(_options: DeviceIdOptions): Promise<void>;
41
+ getMtu(_options: DeviceIdOptions): Promise<GetMtuResult>;
42
+ requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void>;
43
+ readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult>;
44
+ read(options: ReadOptions): Promise<ReadResult>;
45
+ write(options: WriteOptions): Promise<void>;
46
+ writeWithoutResponse(options: WriteOptions): Promise<void>;
47
+ readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult>;
48
+ writeDescriptor(options: WriteDescriptorOptions): Promise<void>;
49
+ startNotifications(options: ReadOptions): Promise<void>;
50
+ private onCharacteristicValueChangedCallback;
51
+ private onCharacteristicValueChanged;
52
+ stopNotifications(options: ReadOptions): Promise<void>;
53
+ private getFilters;
54
+ private getDeviceFromMap;
55
+ private getBleDevice;
56
+ }