Android Question Bluetooth conection

fernando.oliboni

Member
Licensed User
Longtime User
B4X:
Sub Timer1_Tick
    If connected Then
        If TextReader1.Ready Then 'check if there is any data waiting to be read
            txt_chat.Text = txt_chat.Text & TextReader1.ReadLine & CRLF
            txt_chat.SelectionStart = txt_chat.Text.Length
        End If
    End If
End Sub

I'm using the code below and it's working fine with ESP32, I'm talking to ESP32 and GRBL, sending command and getting OKs.
1) I just wanted to understand the reason for using a timer associated with sending messages.
2) Why the value of 200 milliseconds? Would it be a sufficient amount of waiting? If the response occurs before then, is the clock reset?
Could someone explain this dynamic to me?
 

fernando.oliboni

Member
Licensed User
Longtime User
Network communication based on TextReader is a guaranteed failure.

You should use AsyncStreams. If you are using B4R to program the ESP32 then you can use prefix mode + B4RSerializator. This makes things very simple.
If not then you should still use AsyncStreams.

Hi Erel, I don't use B4R, I use B4A. Could you give me an example of using AsyncStreams with connecting, sending and receiving messages? Thanks Fernando
 
Upvote 0

fernando.oliboni

Member
Licensed User
Longtime User
Network communication based on TextReader is a guaranteed failure.

You should use AsyncStreams. If you are using B4R to program the ESP32 then you can use prefix mode + B4RSerializator. This makes things very simple.
If not then you should still use AsyncStreams.
I only use classic bluetooth connection
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0
Top