bluetooth pc to phone communication and Javaio.io.IOException

gypsea

Member
Licensed User
Longtime User
Hi I am new to b4a and not the most experienced programmer. Over the years though I have written a few programs in VB and VBA out of desperation in my work as an offshore surveyor.
Right now I am trying to make my win7 pc and Samsung galaxy communicate serial data via blue tooth. I am also testing with transfer between the Samsung SII and an HTC Sensation. Both android devices are running 4.0.3.
I am using the new version of the tutorial and have serial lib version 1.21
When I was using Connect I could connect to the Samsung from the HTC and have text transfer in both directions but could not connect to the HTC or PC from the Samsung with the following error.
Javaio.io.IOException connection refused.
I modified the code on the Samsung for Connect3 and had to add a new integer variable for port. I don’t really know what this number is. I tried 1 and 8.
Now I can make a connection from the Samsung to the PC and from the HTC to the Samsung but still cant connect the Samsung to the HTC . The app on the HTC is still using connect.
My real question here is how can I easily test the transfer of serial data between the PC and Samsung galaxy sii. The app on the sii says it is connected to pc and the text box comes up.
I have added an incoming com port in the bt driver on the pc and it comes up as com8. I tried with a terminal program to send and receive data but I don’t think the bt connection with the phone ‘knows’ about the com port.
If I can solve this problem I have the skills to write the rest of my application but this is a bit beyond me. Can anyone help. Thx
 

gypsea

Member
Licensed User
Longtime User
update to my previous bt pc and phone post

Hi I am new to b4a and not the most experienced programmer. Over the years though I have written a few programs in VB and VBA out of desperation in my work as an offshore surveyor.
Right now I am trying to make my win7 pc and Samsung galaxy communicate serial data via blue tooth. I am also testing with transfer between the Samsung SII and an HTC Sensation. Both android devices are running 4.0.3.
I am using the new version of the tutorial and have serial lib version 1.21
When I was using Connect I could connect to the Samsung from the HTC and have text transfer in both directions but could not connect to the HTC or PC from the Samsung with the following error.
Javaio.io.IOException connection refused.
I modified the code on the Samsung for Connect3 and had to add a new integer variable for port. I don’t really know what this number is. I tried 1 and 8.
Now I can make a connection from the Samsung to the PC and from the HTC to the Samsung but still cant connect the Samsung to the HTC . The app on the HTC is still using connect.
My real question here is how can I easily test the transfer of serial data between the PC and Samsung galaxy sii. The app on the sii says it is connected to pc and the text box comes up.
I have added an incoming com port in the bt driver on the pc and it comes up as com8. I tried with a terminal program to send and receive data but I don’t think the bt connection with the phone ‘knows’ about the com port.
If I can solve this problem I have the skills to write the rest of my application but this is a bit beyond me. Can anyone help. Thx
Update: I have just tried the htc with the app using connect and I can receive serial data on com 8 in a terminal program but when I type in the terminal program the app on the htc stops.
I feel I am confused but so close!
:sign0104:
 
Upvote 0

gypsea

Member
Licensed User
Longtime User
bt error

I went back to using just connect and the Samsung sii seems to send to the terra term program just fine. When I type in terra term though the app locks up and I think this is what you need. the phone says unfortunately bluetooth example has stopped.
Thanks for your help.

ANDYB-PC:E0:B9:A5:D3:5C:1C
connected: true
** Activity (main) Pause, UserClosed = false **
** Activity (chatactivity) Create, isFirst = true **
** Activity (chatactivity) Resume **
java.lang.OutOfMemoryError
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:168)
at java.lang.Thread.run(Thread.java:856)
** Activity (chatactivity) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 
Upvote 0

gypsea

Member
Licensed User
Longtime User
working now

success! thanks i now can communicate with teraterm or a vb.net program reliably in both directions once connected. the connection process however is still a bit flaky and you seem to have to turn bt on and off and / or restart everything to get connected and to not get the ioexception error. is there anything i can do to try and make this more reliable. i will try connect2 and 3 and connectinsecure today....
Q: could you give me more information on what the RComm (i am assuming) rfcomm channel is and what UUID I should use for these methods.
Thx in advance
 
Upvote 0

gypsea

Member
Licensed User
Longtime User
bt error

yes b4a in bluetooth works great every time.
what are the rfcomm ports? what do they relate to?
thx
 
Upvote 0

gypsea

Member
Licensed User
Longtime User
next step

ok thanks
just to be clear, you are suggesting I look at the source code for the b4a bridge which seems to be reliable and use to make a more secure connection?
i will investigate
i guess my question is that the connect3 uses a variable where you set the rfcom and I dont really know what that does and I cant find any documentation on it.
Thanks
ANdy
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
unfortunately bluetooth example has stopped

Oops!

wrong post

moved
 
Last edited:
Upvote 0
Top