Android Question Bluetooth

androidvh

Member
Licensed User
Longtime User
open port (Bluetooth) with:

ser_port.connect(PairedDevices.GetValueAt(myDev)) -> Data is coming in, works perfect

Now I want to write a string (dim as string = "Test,Now,ON,1Hz") to the device:

doesn't work with:

Sub ser_port_Connected (Success As Boolean)
'
If Success Then

Dim txt_wr As TextWriter
txt_wr.Initialize(ser_port.OutputStream)
txt_wr.Write(s) -> doesn't work

txt_rd.Initialize(ser_port.InputStream) -> works perfect​

what is to do???


kind regards

Volker
 

DonManfred

Expert
Licensed User
Longtime User
Hey Volker,

did you tried something like
B4X:
    Dim os As OutputStream = ser_port.OutputStream
    Dim s As String = "Test,Now,ON,1Hz"
    os.WriteBytes(s.GetBytes("UTF8"),0,s.Length)

PD: No need to create two identical threads ;)
 
Upvote 0

androidvh

Member
Licensed User
Longtime User
  1. Dim s As String = "LOG,GEPOSE,ONTIME,1Hz" & CRLF
Dim AStream As AsyncStreams
AStream.InitializePrefix(Null, True, ser_port.OutputStream, "")
AStream.Write(s.GetBytes("UTF8"))
 
Upvote 0
Top