Sporadic 'Writing characteristic failed' on BleClient.write()
See original GitHub issueHello, thank you for the creation and support of this plugin.
I have a ionic cordova application I ported to capacitor. The app does continuous BleClient.write()s with the expected result to come from an indication.
What I am seeing with this plugin is sporadic ‘Writing characteristic failed’ from the BleClient.write(). The app might be able to do writes and get the associated indication back for say 5 minutes before this error occurs. The next time it might run for 10 seconds before the error occurs.
Below is what I have captured in Android Studio.
GOOD CASE
File: http://localhost/main.js - Line 2114 - Msg: WRITE
V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 63189254, pluginId: BluetoothLe, methodName: write
V/Capacitor: callback: 63189254, pluginId: BluetoothLe, methodName: write, methodData: {"deviceId":"CC:3B:3E:81:45:6B","service":"832ae7fe-d3c5-11e4-b9d6-1681e6b88ec1","characteristic":"737bea54-d3c5-11e4-b9d6-1681e6b88ec1","value":"2b 01 01 0b 00 04 00 00 00 00"}
D/Device: resolve: write|832ae7fe-d3c5-11e4-b9d6-1681e6b88ec1|737bea54-d3c5-11e4-b9d6-1681e6b88ec1 Characteristic successfully written.
I/Capacitor/Console: File: http://localhost/ - Line 204 - Msg: undefined
V/Capacitor/BluetoothLe: Notifying listeners for event notification|CC:3B:3E:81:45:6B|832ae7fe-d3c5-11e4-b9d6-1681e6b88ec1|93c7a770-ddff-11e4-b9d6-1681e6b88ec1
I/Capacitor/Console: File: http://localhost/main.js - Line 2191 - Msg: rx [0x2b,0x00,0x01,0x01,0x0b,0x00,0x04,0x00,0x00,0x00,0x00]
I/Capacitor/Console: File: http://localhost/main.js - Line 2191 - Msg: tx [0x2b,0x01,0x01,0x0b,0x00,0x04,0x00,0x00,0x00,0x00]
BAD CASE
File: http://localhost/main.js - Line 2114 - Msg:-WRITE
V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 63189255, pluginId: BluetoothLe, methodName: write
V/Capacitor: callback: 63189255, pluginId: BluetoothLe, methodName: write, methodData: {"deviceId":"CC:3B:3E:81:45:6B","service":"832ae7fe-d3c5-11e4-b9d6-1681e6b88ec1","characteristic":"737bea54-d3c5-11e4-b9d6-1681e6b88ec1","value":"2b 01 01 0b 00 04 00 00 00 00"}
D/Device: reject: write|832ae7fe-d3c5-11e4-b9d6-1681e6b88ec1|737bea54-d3c5-11e4-b9d6-1681e6b88ec1 Writing characteristic failed.
D/Capacitor: Sending plugin error: {"save":false,"callbackId":"63189255","pluginId":"BluetoothLe","methodName":"write","success":false,"error":{"message":"Writing characteristic failed."}}
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=CC:3B:3E:81:45:6B
V/Capacitor/BluetoothLe: Notifying listeners for event disconnected|CC:3B:3E:81:45:6B
D/Capacitor/BluetoothLe: No listeners found for event disconnected|CC:3B:3E:81:45:6B
D/BluetoothGatt: close()
unregisterApp() - mClientIf=9
D/Device: Disconnected from GATT server.
W/Device: Resolve callback not registered for key: disconnect
For whatever reason I do not see this issue with the cordova plugin.
What are some potential causes behind ‘Writing characteristic failed.’? Is there anything I can check or look into?
Thanks for any insight.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Thank for looking at this.
I was actually in the process of responding. I am thinking there was something up with my development environment. The plugin seems to be working well.
You can close this issue.
Thanks for your time supporting this plugin.
Let me know if you find anything. I am unfortunately still not able to reproduce this.