#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
'Activity module
Sub Process_Globals
Dim AStream As AsyncStreams
End Sub
Sub Globals
Dim txtInput As EditText
Dim txtLog As EditText
Dim btnSend As Button
Public charset As String = "UTF8"
Private sb As StringBuilder
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("2")
If AStream.IsInitialized = False Then
AStream.Initialize (Main.serial1.InputStream ,Main.serial1 .OutputStream ,"AStream")
End If
sb.Initialize
txtLog.Width = 100%x
End Sub
Private Sub astream_NewData (Buffer() As Byte)
sb.Append(BytesToString(Buffer, 0, Buffer.Length, charset))
Dim s As String = sb.ToString
Log("S = " & s)
Log("SB = " & sb)
If s.Contains ("*") Then
LogMessage("PIC ", s)
sb.Initialize
s = ""
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
AStream.Close
End If
End Sub
Sub txtInput_EnterPressed
If btnSend.Enabled = True Then btnSend_Click
End Sub
Sub btnSend_Click
Dim out_mess As String
out_mess = txtInput.Text & "*"'& CRLF
Log("Out Mess = " & out_mess)
AStream.Write2 (out_mess.GetBytes ("UTF8"),0,out_mess.Length)
txtInput.SelectAll
txtInput.RequestFocus
LogMessage("Me", txtInput.Text)
End Sub
Sub LogMessage(From As String, Msg As String)
txtLog.Text = txtLog.Text & From & ": " & Msg & CRLF
txtLog.SelectionStart = txtLog.Text.Length
End Sub