Open chriscastro94 opened 4 months ago
A disconnect can also be triggered by the peripheral. When connecting you can pass an optional onDisconnect callback, see https://github.com/capacitor-community/bluetooth-le?tab=readme-ov-file#connect. Is this callback called between the successful connection and your read or write attempt?
I noticed that the disconnection event only triggers after a write or read attempt. However, by changing the autoconnect parameter to true, the connection works consistently.
Could this have any potential side effects?
Detailed Description of the Issue Issue Summary: After successfully connecting to a BLE device using the @capacitor-community/bluetooth-le plugin in an Ionic 7 Angular application, attempting to read or write characteristics returns an error stating "device is not connected." This issue occurs even though the initial connection appears to be successful.
Steps to Reproduce:
Observed Behavior:
The device connects successfully, as confirmed by the connection logs. Upon attempting to read or write a characteristic, an error is thrown indicating that the device is not connected. Expected Behavior:
After a successful connection, reading from or writing to a characteristic should succeed without errors. Additional Context:
The issue seems to be intermittent, as the connection is initially established but subsequent read/write operations fail. Adding delays and retry logic does not resolve the issue. This issue occurs on multiple Android devices and versions. Environment:
Ionic Version: 7 Capacitor Version: 6.0.0 BLE Plugin Version: "@capacitor-community/bluetooth-le": "^6.0.0" Pls Help