Hi all,
I use the following code to discover paired devices in a given list of candidates (device must be in it otherwise terminate the sw), then connect to them.
This works nice in B4A but jSerial for B4J misses a few functions relative to lib Serial for B4A.
So the question is: which is the alternative path to follow when compiling for B4J? TIA
Should I look for Bluetooth/BLE libs? Or should I go the USB way when dealing with B4j/Windows?
If the latter, would it work with Windows XP (to reuse a very old small-factor PC)?
I use the following code to discover paired devices in a given list of candidates (device must be in it otherwise terminate the sw), then connect to them.
This works nice in B4A but jSerial for B4J misses a few functions relative to lib Serial for B4A.
So the question is: which is the alternative path to follow when compiling for B4J? TIA
B4X:
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
Should I look for Bluetooth/BLE libs? Or should I go the USB way when dealing with B4j/Windows?
If the latter, would it work with Windows XP (to reuse a very old small-factor PC)?