I am developing a B4A app on a Nexus 7 (5.0.2). The app communicates over Bluetooth with a paired HC-06 module and the admin and serial connection code is essentially what is in the Bluetooth tutorial.
The app is run manually when required. The problem I am having is that following power cycling the Tablet it appears to be a matter of luck/chance whether the app, when first run, will connect to the module. If it first connects following a power cycle then it will always connect (when the app is run) until power is cycled again. After that it may or may not connect.
If it fails to connect then it may connect following a power cycle or it may not. So far a work around is to "forget" the module then re pair it after which the connection succeeds.
Fail to connect means serial_connected is called with success=false and the last exception is java.io.IOException: read failed, socket might be closed.....
Although the connection fails the module can be found during admin discovery and of course it is in the Bluetooth settings list of paired devices.
I suspect this is not a B4A issue but would appreciate it if anyone can share any thoughts about a solution.
The app is run manually when required. The problem I am having is that following power cycling the Tablet it appears to be a matter of luck/chance whether the app, when first run, will connect to the module. If it first connects following a power cycle then it will always connect (when the app is run) until power is cycled again. After that it may or may not connect.
If it fails to connect then it may connect following a power cycle or it may not. So far a work around is to "forget" the module then re pair it after which the connection succeeds.
Fail to connect means serial_connected is called with success=false and the last exception is java.io.IOException: read failed, socket might be closed.....
Although the connection fails the module can be found during admin discovery and of course it is in the Bluetooth settings list of paired devices.
I suspect this is not a B4A issue but would appreciate it if anyone can share any thoughts about a solution.