#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim usocket As UDPSocket
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private btn0 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
If (FirstTime) Then
usocket.Initialize("UDP", 6000, 255)
End If
Activity.LoadLayout("layoutScan")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'---------------------------------------------------------
'Clique dos botoes numéricos
'---------------------------------------------------------
Sub btn0_Click
UDPEnviaString("33333;1;1")
End Sub
Sub UDPEnviaString(msg As String)
Dim Data() As Byte
Dim chave As String
Dim udpip As String
chave = U.PadZero(Rnd(0, 10000000) & "", 10)
msg = chave & ";" & msg
Data = msg.GetBytes("UTF8")
Dim Packet As UDPPacket
udpip = G.Config.UDPIp
If (udpip = "") Then
udpip = G.GetBroadcastAddress
End If
Packet.Initialize(Data, 192.168.1.1, 6000)
usocket.Send(Packet)
End Sub
Sub UDP_PacketArrived (Packet As UDPPacket)
Dim msg As String
msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8")
ToastMessageShow(msg, True)
End Sub