capacitor-community / capacitor-community/bluetooth-le

(Possible) Android 11 issue - Error: Connection timeout 9 out of 10 times

Open
#360 13 comments 0 reactions 0 assignees View on GitHub
bug cannot reproduce
Dominant language
TypeScript
Stars
361
Forks
121
Avg merge
10d 45m
Merged PRs (30d)
2

Description

**Describe the bug**
Experiencing failed connection attempts 9 out of 10 times on certain Ble devices when I build on Android 11 but not on Android 10 or any iOS devices.

Connecting to the same BLE device, very short range, data light flashes on the front of the device but connection times out with Android 11. Fine on all other devices.
Difficult to reproduce as it only happens on Android 11 devices on a particular Ble device. Publishing here just in case other people experience it.

**To Reproduce**
Steps to reproduce the behavior:

try {
await BleClient.initialize();

//needed for iOS, not for Android.
await BleClient.getDevices([deviceId]);

// connect to device, the onDisconnect callback is optional
await BleClient.connect(deviceId, (deviceIdDisco) => this.onDisconnect(deviceIdDisco));

const servicesAvail = await BleClient.getServices(deviceId);
console.log('services Avail:', JSON.stringify(servicesAvail));

await BleClient.write(deviceId, UUID_SERVICE, UUID_CHARACTERISTIC, data)
}catch (error) {
console.error(error);
}

Fails on BleClient.connect with error 'Error: Connection timeout.' 9 out of ten times on Android 11 but works perfect on iOS and Android 10/9. Takes around 4 seconds to timeout with lights flashing on the device im connecting to.

**Expected behavior**
Connects and allows me to write data to the device

**Plugin version:**
- @capacitor-community/bluetooth-le: 1.8.0

- iOS working
- Android 11 Fail
- Android 10 & 9 working

Hardware is Techlast 8 inch tablets with Android 9/10/11
Connecting device is a Mobile Printer with no real branding

**Additional context**
Could totally be a hardware / OS clash just making people aware just in case others have Android 11 issues.

Thanks

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported BleClient.connect timeout on Android 11 with the described BLE printer, comparing it with Android 9/10 and iOS. Trace the initialize, getDevices, connect, getServices, and write sequence shown in the report. Done means reliably connecting and writing data on the affected Android 11 tablet and confirming whether the failure is plugin, OS, or hardware-specific.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.