#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
'Activity module
Sub Process_Globals
Dim blnSendLoopOn As Boolean = False
Dim iSendCounter As Int
'Don't include a "_" in this message
Dim BaseMessageToSend As String = "0123456789:0123456789:01234567890:0123456789:0123456789:0123456789:01234567890:0123456789"
Dim MsgSent As String = ""
Dim pw As PhoneWakeState
Dim blnCounterMode As Boolean = True
End Sub
Sub Globals
Private txtInput As EditText
Private txtLog As EditText
Private btnSend As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("2")
pw.KeepAlive(False)
End Sub
Public Sub NewMessage (Msg As String)
'LogMessage("You", msg)
Dim MsgToDisplay As String = ""
If blnSendLoopOn = True Then
If blnCounterMode = True Then
Dim Components() As String = Regex.Split("_", Msg )
If Components.Length = 2 Then
If Components(1) = iSendCounter And Components(0) = BaseMessageToSend Then
iSendCounter = iSendCounter + 1
SendLoop
If (iSendCounter Mod 50) = 0 Then
MsgToDisplay = "The time is: " & DateTime.Time( DateTime.Now ) & ", Messages Sent: " & iSendCounter
Log(MsgToDisplay)
LogMessage("",MsgToDisplay)
End If
Else
blnSendLoopOn = False
MsgToDisplay = "Error at:" & iSendCounter
LogMessage("", MsgToDisplay)
Log(MsgToDisplay)
Log("Sent: " & MsgSent )
Log("Recv: " & Msg )
End If
End If
Else
If Msg = MsgSent Then
MsgToDisplay = "Received Ok: " & Msg.Length & " Chars"
SendLoop
Else
MsgToDisplay = "Failed, Received: " & Msg.Length & "Chars" & " Sent: " & MsgSent.Length & "Chars"
blnSendLoopOn = False
End If
LogMessage("", MsgToDisplay)
Log(MsgToDisplay)
End If
End If
If blnSendLoopOn = False Then
UpdateButtonText
End If
End Sub
Sub Activity_Resume
UpdateState
End Sub
Public Sub UpdateState
btnSend.Enabled = Starter.Manager.ConnectionState
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
Starter.Manager.Disconnect
End If
End Sub
Sub txtInput_EnterPressed
If btnSend.Enabled = True Then btnSend_Click
End Sub
Sub btnSend_Click
If txtInput.Text.ToUpperCase = "INC" Then
blnCounterMode = False
Else
blnCounterMode = True
End If
iSendCounter = 0
If blnSendLoopOn = False Then
MsgSent = ""
SendLoop
End If
blnSendLoopOn = Not(blnSendLoopOn)
UpdateButtonText
' Starter.Manager.SendMessage(txtInput.Text)
' txtInput.SelectAll
' txtInput.RequestFocus
' LogMessage("Me", txtInput.Text)
End Sub
Sub UpdateButtonText()
If blnSendLoopOn = True Then
btnSend.Text = "Stop"
Else
btnSend.Text = "Send"
End If
End Sub
Sub SendLoop()
If blnCounterMode = True Then
MsgSent = BaseMessageToSend & "_" & iSendCounter
Else
MsgSent = MsgSent & "A"
End If
Starter.Manager.SendMessage( MsgSent )
End Sub
Sub LogMessage(From As String, Msg As String)
txtLog.Text = txtLog.Text & From & ": " & Msg & CRLF
txtLog.SelectionStart = txtLog.Text.Length
End Sub