'Static code module
Sub Process_Globals
Private mqtt As BANanoMQTTClient
End Sub
Sub Initialize
mqtt.Initialize("mqtt", "xxx.xx.xxx.xx",9001, "/mqtt", False, "clientid")
Dim ops As BANanoMQTTConnectOptions
ops.Initialize("username", "password")
ops.CleanSession = False
mqtt.Connect2(ops)
End Sub
Sub mqtt_Connected (Success As Boolean)
If Success Then
Log("connected " & Success)
mqtt.Subscribe("incoming", 0)
Else
Log(LastException)
Log("Could not connect to MQTT broker!")
End If
End Sub
Private Sub mqtt_Disconnected
Log("Disconnected")
End Sub
Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte)
Log("mqtt_MessageArrived")
Log(Topic)
Dim msg As String = BytesToString(Payload, 0, Payload.Length, "utf8")
Log(msg)
End Sub