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