B4R Question Problem with HC05.Write (or .print or .println)

Yayou49

Active Member
Licensed User
Hi,

I have a problem to read a string sent via HC05 to my B4A project.

On HC05 side, I'm trying this:
B4X:
HC05.println("toto");

On B4A side, BlueToothManager raised the event
B4X:
Private Sub AStream_NewData (Buffer() As Byte)
      CallSub2(Clefs, "Receive", BytesToString(Buffer, 0, Buffer.Length, "UTF8")) 
End Sub

For my tests, I've updated this sub as follow:

B4X:
Private Sub AStream_NewData (Buffer() As Byte)
    j = j+1
    Log(j)
    
    Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
    
End Sub

Where j (simple counter) starts from 0.

In my example, logs are:
1
t
2
oto

Even with a HC05.write or HC05.print, same result.
AStream_NewData is raised 2 times.

Astream is initialized as following:
B4X:
AStream.Initialize(serial.InputStream, serial.OutputStream, "astream")

Is there a particular setting or command to avoid this "cutting" ?

Thanks in advance.
 
Top