Android Question Device unavailable in Android Bluetooth / BluetoothAdmin Tutorial

howard bassen

Member
Licensed User
I am running the example for Bluetooth connectivity between two android devices:
https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768

First I compiled program on my primary phone (ZTE Z981) and communicated with my PC (via its Bluetooth) . I can communicate both ways with a PC terminal emulator.

When I try to connect my primary phone to a second (PAIRED) android device rather than the PC I get I see the GUI on the device but get the following errors when I try to send or receive:

Logger connected to: ZTE Z981
--------- beginning of main
Nexus 7:08:60:6E:9D:87:70
:17:8D:84:76:1D:02
:08:66:98:B7:7B:D9
:08:66:98:B7:7B:D9
:08:66:98:B7:7B:D9
connected: false
java.io.IOException: read failed, socket might closed or timeout, read ret: -1
** Activity (main) Pause, UserClosed = false **

Can anyone suggest a fix
 

howard bassen

Member
Licensed User
Is the other device listening for connections?
When I use a commercial BT terminal app on my phone it works well with my PC (running a terminal emulator).

For the B4A app I can connect to my PC with the B4A example with difficulty. However the B4A app looses a connection when I try to send characters to the PC.
 

Erel

Administrator
Staff member
Licensed User
Make sure that AsyncStreams is not initialized in prefix mode.
 

howard bassen

Member
Licensed User
Unfortunately I do not see how I can incorporate the various pieces of code into the B4A Bluetooth example to fix my problem. Which pieces of code from the Asysnc Streams need to be added to the Bluetooth example, and where?
 

Erel

Administrator
Staff member
Licensed User
Search the code for InitializePrefix and change that line.
 

howard bassen

Member
Licensed User
sorry but the example program has neither AsyncStreams, Astreams, or InitializePrefix. Should I add these subs from another example? if so, which and how?
 
Top