Sub AfterSuccessfulConnection
If AStream.IsInitialized Then AStream.Close
'prefix mode! Change to non-prefix mode if communicating with non-B4X device.
'AStream.InitializePrefix(serial.InputStream, False, serial.OutputStream, "astream")
AStream.Initialize(serial.InputStream, serial.OutputStream, "astream")
ConnectionState = True
B4XPages.ShowPage("Chat Page")
End Sub