Hello, I used ESP32 to publish a topic to an MQTT broker. I would like to use B4A to subscribe to the publication. Could anyone give an example? Thank you
Implementation of MQTT client based on the Paho open source project: http://www.eclipse.org/paho/ See this tutorial for more information: https://www.b4x.com/android/forum/threads/iot-mqtt-protocol.59471/ jMQTT v1.26 is compatible with B4J and B4A (older versions weren't compatible with B4A)...
[QUOTE = "kisoft, postagem: 775883, membro: 97798"]
Qual corretor MQTT? Você tem seu próprio servidor ?, Quer usar soluções prontas ... Use um mecanismo de busca, digite ESP8266 ...
[/CITAR]
I searched the forum and found iMQTT, but I couldn't use it completely because I don't know how to use the MQTT_MessageArrived function.
Implementation of MQTT client based on the Paho open source project: http://www.eclipse.org/paho/ See this tutorial for more information: https://www.b4x.com/android/forum/threads/iot-mqtt-protocol.59471/ jMQTT v1.26 is compatible with B4J and B4A (older versions weren't compatible with B4A)...
Sub Process_Globals
Public client As MqttClient
End Sub
Sub ConnectMQTT
Log("Connecting")
client.Initialize("client", "tcp://your_server:your_port", "your_topic")
' client.Connect ***If you don't need user and password, then uncomment this line and comment the 3 next ones
Dim options As MqttConnectOptions
options.Initialize("your_user", "your_password")
client.Connect2(options)
End Sub
Private Sub client_MessageArrived (Topic As String, Payload() As Byte)
Dim obj As Object = serializator.ConvertBytesToObject(Payload)
Dim msg As String = obj
Log("Topic: " & Topic & " Mensaje: " & msg)
End Sub