Public Sub Connect As ResumableSub
Dim PairedDevices As Map = Serial1.GetPairedDevices
Dim trovato As Boolean = False
For Each k As String In KPrinters <-- list of authorized printers
If PairedDevices.ContainsKey(k) Then
Log("Test Paired: "& k)
Serial1.Connect(PairedDevices.Get(k)) <- Connect doesn't exist in jSerial
wait for Serial1_Connected(res As Boolean)
If res Then
trovato = True
PrnName = k
Exit
End If
End If
Next
If trovato Then
Log("Found printer: "& PrnName)
Astream.Initialize(Serial1.InputStream, Serial1.OutputStream, "astream")
Connected = True
ConnectedError = ""
Serial1.Listen
Else
Log("No authorized printer found or connection to printer failed")
Connected = False
ConnectedError = LastException.Message
End If
If SubExists(CallBack, EventName & "_Connected") Then
CallSub2(CallBack, EventName & "_Connected", trovato)
End If
Return True
end Sub