Android Question Bluetooth connection

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi there...

I am needing to connect to a Bluetooth to serial converter.

I have made nothing about bluetooth to date.

This module successfully connects on my notebook. It works and transmits the data.

I could pairing it with my tablet (Samsung Tab 3 light)

Tried Serial.Connect and Serial.ConnectInsecure in both cases never happened the serial_connected event.

I see that the bluetooth leds changed to the same behavior when connected on my notebook. Seems to be connecting on both cases.

But never gets the connection event.

I have no idea what to do. (according to the supplier of this gadget it is supposed to work with androids)

Thanks

EDIT: using an apk called Bluetooth terminal, it has 2 options: connect secure and connect insecure, using the insecure option it connected. So it works with this apk and tablet.

EDIT2: just used another terminal from play.google and it only has the connect option and worked. I have jumped pin 3 and 4 of my bluetooth-serial device to make a tx-rx loop, and everything that I sends I get back.
 
Last edited:

EduardoElias

Well-Known Member
Licensed User
Longtime User
Nope, I Just added that with other 2 play.google apps I could connect. So it is not hardware.

I am still not understanding why neither connect nor connectinsecure is not generating the serial_connected.

B4X:
Sub ConnectBluetooth
    Dim PairedDevices As Map
    If Not(Serial1.IsInitialized) Then
        Serial1.Initialize("")
    End If
   
    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) 'show list with paired devices
    If res <> DialogResponse.CANCEL Then
        Serial1.ConnectInsecure(Admin, PairedDevices.Get(l.Get(res)), 1) 'convert the name to mac address and connect
    End If
   
End Sub

Sub Serial1_Connected (Success As Boolean)
    Serial1.Listen
    If Success Then
        TextReader1.Initialize(Serial1.InputStream)
        TextWriter1.Initialize(Serial1.OutputStream)
    End If
   
    TextWriter1.Write(Chr(5))
End Sub
 
Upvote 0
Top