Hi All
I have added the Bluetooth example from Erel to my program to communicate with Digital Levels, Total Stations and external GPS. In the Routine where it looks for Bluetooth Devices, how can I exit from that Routine after some time? I can see from the log, that it picks up the Devices, but it does not exit from that Routine and just carries on scanning.
I have added the Bluetooth example from Erel to my program to communicate with Digital Levels, Total Stations and external GPS. In the Routine where it looks for Bluetooth Devices, how can I exit from that Routine after some time? I can see from the log, that it picks up the Devices, but it does not exit from that Routine and just carries on scanning.
B4X:
[/
Sub FindDevices_Click
HideParaPanels
Panel6.Visible=True
FindDevice
End Sub
Sub ExitBT_Click
HideParaPanels
Para4.Visible=True
End Sub
Sub FindAgain_Click
FindDevice
End Sub
Sub FindDevice
rp.CheckAndRequest(rp.PERMISSION_ACCESS_COARSE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("No permission...", False)
Return
End If
Dim success As Boolean = Starter.Manager.SearchForDevices
If success = False Then
ToastMessageShow("Error starting discovery process.", True)
Starter.Service_Create
Else
ProgressDialogShow2("Searching for devices...", True)
End If
End Sub
Public Sub DiscoverFinished
ProgressDialogHide
If Starter.Manager.foundDevices.Size = 0 Then
ToastMessageShow("No device found.", True)
Else
Dim l As List
l.Initialize
For Each nm As NameAndMac In Starter.Manager.foundDevices
l.Add(nm.Name)
Next
InputListAsync(l, "Choose device to connect", -1, True)
Wait For InputList_Result (Index As Int)
If Index <> DialogResponse.CANCEL Then
Dim Condevice As NameAndMac = Starter.Manager.foundDevices.Get(Index)
Starter.Manager.ConnectTo(Condevice)
ProgressDialogShow2($"Trying to connect to: ${Condevice.Name} (${Condevice.Mac})"$, False)
End If
End If
End Sub
]