Android Question WIFI as serial to microcontroler

sanduro

Member
Licensed User
Longtime User
Hi ,

I have found Bluetooth to serial example, i have found Asyncstreams example over TCPsocket.

What I need is WIFI to clasic serial working with async stream ?

Is it even possible or I should stop searching?

All I need is to send texts to and from via serial line after WIFI connection is established.

I am lost.

TY, San
 

raphaelcno

Active Member
Licensed User
Longtime User
Yes, you can use serial communication with AsyncStreams over Wi-Fi.
Here is an example of code to open Wi-Fi connection and initialize AsyncStreams :
B4X:
Sub Globals
    Dim Sock_WiFi As Socket
    Dim Btn_WiFi As Button  ' Button on layout
    Dim AStream As AsyncStreams
End Sub
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        Sock_WiFi.Initialize("Sock_WiFi")
    End If
End Sub
Sub Btn_WiFi_Click  ' When clicking on button on layout
    Sock_WiFi.Connect(IpAddress, Int_PortNr, 10000)
    AStream.Initialize(Sock_WiFi.InputStream, Sock_WiFi.OutputStream, "AStream")
End Sub
Sub Sock_WiFi_Connected(Successful As Boolean)
    ' Send data with AStream.Write(...)
End Sub
Sub AStream_NewData(Buffer() As Byte)
    ' Receive data
End Sub

See also similar question : http://www.b4x.com/android/forum/threads/serial-over-wifi.24356/
 
Upvote 0
Top