@capgo/capacitor-bluetooth-low-energy 8.2.8 → 8.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -18,12 +18,12 @@ Talk to Bluetooth Low Energy devices from your Capacitor app: scan, connect, rea
|
|
|
18
18
|
|
|
19
19
|
## Built and maintained with AI
|
|
20
20
|
|
|
21
|
-
We build, improve and fix our plugins with heavy use of AI, so issues usually get fixed in under a day and pull requests get feedback the same day. A human still reviews and merges 50+ pull requests daily.
|
|
21
|
+
We build, improve and fix our plugins with heavy use of AI, so issues usually get fixed in under a day and pull requests get feedback the same day. A human still reviews, tests and merges 50+ pull requests daily.
|
|
22
22
|
|
|
23
23
|
- Most plugin issues get a fix pull request the same day, often within a couple of hours, and are usually resolved in one to two days.
|
|
24
24
|
- Every pull request goes through our AI review system, usually within minutes.
|
|
25
|
-
- Our AI pre-checks tests, code review, conventions and security, then a human
|
|
26
|
-
- A human, Martin, reviews and merges 50+ pull requests every day.
|
|
25
|
+
- Our AI pre-checks tests, code review, conventions and security, then a human reviews, tests and merges.
|
|
26
|
+
- A human, Martin, reviews, tests and merges 50+ pull requests every day.
|
|
27
27
|
- In the last 90 days, 95% of plugin issues were resolved.
|
|
28
28
|
|
|
29
29
|
[Learn more about how we build with AI](https://capgo.app/docs/plugins/ai-engineering/)
|
package/android/build.gradle
CHANGED
|
@@ -40,6 +40,11 @@ android {
|
|
|
40
40
|
sourceCompatibility JavaVersion.VERSION_21
|
|
41
41
|
targetCompatibility JavaVersion.VERSION_21
|
|
42
42
|
}
|
|
43
|
+
testOptions {
|
|
44
|
+
unitTests {
|
|
45
|
+
includeAndroidResources = true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
repositories {
|
|
@@ -54,6 +59,9 @@ dependencies {
|
|
|
54
59
|
implementation project(':capacitor-android')
|
|
55
60
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
61
|
testImplementation "junit:junit:$junitVersion"
|
|
62
|
+
testImplementation "androidx.test:core:1.6.1"
|
|
63
|
+
testImplementation "org.mockito:mockito-core:5.14.2"
|
|
64
|
+
testImplementation "org.robolectric:robolectric:4.14.1"
|
|
57
65
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
66
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
59
67
|
}
|
package/android/src/main/java/ee/forgr/plugin/bluetooth_low_energy/BluetoothLowEnergyPlugin.java
CHANGED
|
@@ -77,7 +77,7 @@ import java.util.UUID;
|
|
|
77
77
|
)
|
|
78
78
|
public class BluetoothLowEnergyPlugin extends Plugin {
|
|
79
79
|
|
|
80
|
-
private final String pluginVersion = "8.2.
|
|
80
|
+
private final String pluginVersion = "8.2.10";
|
|
81
81
|
private BluetoothManager bluetoothManager;
|
|
82
82
|
private BluetoothAdapter bluetoothAdapter;
|
|
83
83
|
private BluetoothLeScanner bluetoothLeScanner;
|
|
@@ -94,6 +94,7 @@ public class BluetoothLowEnergyPlugin extends Plugin {
|
|
|
94
94
|
private ScanCallback scanCallback;
|
|
95
95
|
private AdvertiseCallback advertiseCallback;
|
|
96
96
|
private Handler scanHandler;
|
|
97
|
+
private Runnable scanTimeoutRunnable;
|
|
97
98
|
private boolean isScanning = false;
|
|
98
99
|
private String mode = "central";
|
|
99
100
|
|
|
@@ -299,15 +300,19 @@ public class BluetoothLowEnergyPlugin extends Plugin {
|
|
|
299
300
|
}
|
|
300
301
|
isScanning = true;
|
|
301
302
|
|
|
303
|
+
cancelScanTimeout();
|
|
302
304
|
if (timeout > 0) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}, (long) timeout);
|
|
305
|
+
scanTimeoutRunnable = this::stopScanInternal;
|
|
306
|
+
scanHandler.postDelayed(scanTimeoutRunnable, (long) timeout);
|
|
306
307
|
}
|
|
307
308
|
|
|
308
309
|
call.resolve();
|
|
309
310
|
} catch (SecurityException e) {
|
|
311
|
+
cleanupScanStartFailure();
|
|
310
312
|
call.reject("Permission denied: " + e.getMessage());
|
|
313
|
+
} catch (IllegalStateException e) {
|
|
314
|
+
cleanupScanStartFailure();
|
|
315
|
+
call.reject("Bluetooth is off: " + e.getMessage());
|
|
311
316
|
}
|
|
312
317
|
}
|
|
313
318
|
|
|
@@ -379,8 +384,25 @@ public class BluetoothLowEnergyPlugin extends Plugin {
|
|
|
379
384
|
bluetoothLeScanner.stopScan(scanCallback);
|
|
380
385
|
} catch (SecurityException e) {
|
|
381
386
|
// Ignore
|
|
387
|
+
} catch (IllegalStateException e) {
|
|
388
|
+
// Ignore when adapter is off; nothing left to stop
|
|
382
389
|
}
|
|
383
|
-
|
|
390
|
+
}
|
|
391
|
+
cancelScanTimeout();
|
|
392
|
+
isScanning = false;
|
|
393
|
+
scanCallback = null;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private void cleanupScanStartFailure() {
|
|
397
|
+
cancelScanTimeout();
|
|
398
|
+
scanCallback = null;
|
|
399
|
+
isScanning = false;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
private void cancelScanTimeout() {
|
|
403
|
+
if (scanTimeoutRunnable != null) {
|
|
404
|
+
scanHandler.removeCallbacks(scanTimeoutRunnable);
|
|
405
|
+
scanTimeoutRunnable = null;
|
|
384
406
|
}
|
|
385
407
|
}
|
|
386
408
|
|
|
@@ -961,7 +983,12 @@ public class BluetoothLowEnergyPlugin extends Plugin {
|
|
|
961
983
|
call.resolve();
|
|
962
984
|
} catch (SecurityException e) {
|
|
963
985
|
restoreBluetoothAdapterNameIfNeeded();
|
|
986
|
+
advertiseCallback = null;
|
|
964
987
|
call.reject("Permission denied: " + e.getMessage());
|
|
988
|
+
} catch (IllegalStateException e) {
|
|
989
|
+
restoreBluetoothAdapterNameIfNeeded();
|
|
990
|
+
advertiseCallback = null;
|
|
991
|
+
call.reject("Bluetooth is off: " + e.getMessage());
|
|
965
992
|
}
|
|
966
993
|
}
|
|
967
994
|
|
|
@@ -972,7 +999,10 @@ public class BluetoothLowEnergyPlugin extends Plugin {
|
|
|
972
999
|
bluetoothLeAdvertiser.stopAdvertising(advertiseCallback);
|
|
973
1000
|
} catch (SecurityException e) {
|
|
974
1001
|
// Ignore
|
|
1002
|
+
} catch (IllegalStateException e) {
|
|
1003
|
+
// Ignore when adapter is off
|
|
975
1004
|
}
|
|
1005
|
+
advertiseCallback = null;
|
|
976
1006
|
}
|
|
977
1007
|
restoreBluetoothAdapterNameIfNeeded();
|
|
978
1008
|
call.resolve();
|
|
@@ -1454,6 +1484,8 @@ public class BluetoothLowEnergyPlugin extends Plugin {
|
|
|
1454
1484
|
gattServer = bluetoothManager.openGattServer(getContext(), gattServerCallback);
|
|
1455
1485
|
} catch (SecurityException e) {
|
|
1456
1486
|
// Ignore
|
|
1487
|
+
} catch (IllegalStateException e) {
|
|
1488
|
+
// Ignore when adapter is off
|
|
1457
1489
|
}
|
|
1458
1490
|
}
|
|
1459
1491
|
}
|
|
@@ -5,7 +5,7 @@ import CoreBluetooth
|
|
|
5
5
|
// swiftlint:disable type_body_length file_length
|
|
6
6
|
@objc(BluetoothLowEnergyPlugin)
|
|
7
7
|
public class BluetoothLowEnergyPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
8
|
-
private let pluginVersion: String = "8.2.
|
|
8
|
+
private let pluginVersion: String = "8.2.10"
|
|
9
9
|
public let identifier = "BluetoothLowEnergyPlugin"
|
|
10
10
|
public let jsName = "BluetoothLowEnergy"
|
|
11
11
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-bluetooth-low-energy",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.10",
|
|
4
4
|
"description": "Bluetooth Low Energy (BLE) plugin for Capacitor with support for scanning, connecting, reading, writing, and notifications.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|