IO Exception error Connection refused

alvinmb

Member
Licensed User
Longtime User
I'm connecting to a bluetooth barcode scanner and on a Galaxy S the code works fine. On a Galaxy Player and Galaxy Tab 7" when I try and make the connection in my app I get am "java.io.IOException: Connection refused" In the detail log I get:

...connect(77, RFCOMM) = 111 (errno 111)
java.io.IOException: Connection refused
at android.bluetooth.BluetoothSocket.connectNative(Native Method)
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:236)
at anywheresoftware.b4a.objects.Serial$1.run(Serial.java:152)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

Again the same code works on a Galaxy S phone.
 
Last edited:

alvinmb

Member
Licensed User
Longtime User
Yes the device was paired prior to connecting to the app
I have found a solution if I use :
serial1.ConnectInsecure(admin,connectedDevice.MAC,1) it works on the GalaxyS, Galaxy Player and Galaxy Tab. If I use serial1.Connect(connectedDevice.Mac) it only works on the Galaxy S.

I don't understand why - however I would like to find out.
 
Upvote 0

areripe

Member
Licensed User
Longtime User
I also got this problem when usin Tab 2.
But in using tutorial to connect to bluetooth
My code look liked this
Sub Button1_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i))
Next
Dim res As Int
res = InputList(l, "Choose device", -1)
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(l.Get(res)))
End If

What i need to change?
 
Upvote 0
Top