#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Public client As MqttClient
Public connected As Boolean
Public client As MqttClient
Dim host As String="0ed834272c314afea7aae83a2d027e0d.s1.eu.hivemq.cloud"
Dim myName As String="prova"
Dim port As Int = 8883
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'example of connecting to a local network
If wifi.Connect2("wifi-net", "pwd") Then
Log("Connected to network")
Else
Log("Failed to connect to network")
End If
End Sub
Sub ConnectMQTT
client.Initialize("client", host, port, myName)
Dim options As MqttConnectOptions
options.Initialize("user", "password")
client.Connect2(options)
End Sub
Sub client_Connected (Success As Boolean)
connected = Success
If Success Then
Log("CONNESSO")
Else
Log("NON CONNESSO")
End If
End Sub
Sub client_Disconnected
connected = False
Log("Disconnesso mqtt")
'CallSub(Main, "SetState")
End Sub
Sub client_MessageArrived (Topic As String, Payload() As Byte)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Service_Destroy
End Sub