I am using the Bluetooth Example and I am able to search for BT devices and establish a connection with the InputList.
I would like to be able to connect with the code so that if the connectedDevice.Name is = "Remote_BTName" the device must connect and these is no required user intervention.
How would I have to edit this code:
I would like to be able to connect with the code so that if the connectedDevice.Name is = "Remote_BTName" the device must connect and these is no required user intervention.
How would I have to edit this code:
B4X:
Sub Admin_DiscoveryFinished
ProgressDialogHide
If foundDevices.Size = 0 Then
ToastMessageShow("No device found.", True)
Else
Dim l As List
l.Initialize
For i = 0 To foundDevices.Size - 1
Dim nm As NameAndMac
nm = foundDevices.Get(i)
l.Add(nm.Name)
Next
Dim res As Int
res = InputList(l, "Choose device to connect", -1)
If res <> DialogResponse.CANCEL Then
connectedDevice = foundDevices.Get(res)
ProgressDialogShow("Trying to connect to: " & connectedDevice.Name & " (" & connectedDevice.Mac & ")")
serial1.Connect(connectedDevice.Mac)
End If
End If
End Sub