Sub btnBTConnect_Click
BTFoundDevices.Initialize
If BTAdmin.StartDiscovery = False Then
ToastMessageShow("Error starting discovery process.", True)
Else
ProgressDialogShow("Searching for devices...")
End If
End Sub
Sub BTAdmin_DiscoveryFinished
ProgressDialogHide
If BTFoundDevices.Size = 0 Then
ToastMessageShow("No device found.", True)
Else
Dim l As List
l.Initialize
For i = 0 To BTFoundDevices.Size - 1
Dim nm As BTNameAndMac
nm = BTFoundDevices.Get(i)
l.Add(nm.Name)
Next
Dim res As Int
res = InputList(l, "Choose device to connect.", -1)
If res <> DialogResponse.CANCEL Then
BTConnectedDevice = BTFoundDevices.Get(res)
ProgressDialogShow("Trying to connect to: " & BTConnectedDevice.Name & " (" & BTConnectedDevice.Mac & ")")
BTSerial1.Connect(BTConnectedDevice.Mac)
End If
End If
End Sub
Sub BTAdmin_DeviceFound (Name As String, MacAddress As String)
Log(Name & ":" & MacAddress)
Dim nm As BTNameAndMac
nm.Name = Name
nm.Mac = MacAddress
BTFoundDevices.Add(nm)
ProgressDialogShow("Searching for devices (~ device found)...".Replace("~", BTFoundDevices.Size))
End Sub