After bluetooth is enabled using "admin.enable" I have a timer which is trying to connect to the device using a given mac address.
B4X:
Sub TimerBT1_Tick
TimerBT1.Enabled = False
If MachineMac<>"null" Then
Serial1.Connect (MachineMac)
End If
TimerBT1.Enabled = True
End Sub
To know if it successed I have the usual Sub :
B4X:
Sub Serial1_Connected (Success As Boolean)
If Success Then
TimerBT1.Enabled = False
ProgressDialogHide
Allarm.Text = "Connected successfully"
CONNECTED1 = True
StartService(BT1)
Timer1.Enabled = True
IME1.HideKeyboard
CallSub("TE","SAV")
Else
CONNECTED1 = False
End If
End Sub
I'm not already connected. At the very first connection I have the MAC address saved into a string and then into a file.
When I re-start the application a second time, I get my file loaded and through the address saved into the string I get recconnect automatically without choosing any paired device.