![MqttTop.jpg](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2FMqttTop.jpg&hash=2d1c8e7efb9a40692713e9647d20254a)
This library was made based on MQTT Protocol
Installation instructions:
- Copy the .xml and .jar(s) files to your custom libraries folder
- Select in your REFERENCED LIBRARIES
![MqttRef.png](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2FMqttRef.png&hash=8111a951a57083a9040bbc33b49ad783)
Version history:
V1.0.0 (First public release - Donationware):
- Initial version
V1.0.2 (Release - Donationware):
- Implement method to get independence of threads
V1.0.4 (Release - Donationware):
- Implement method to subscribe a topic with QoS
V1.0.5 (Release - Donationware):
- Now can be used isConnected method "BEFORE" the first connection
V1.0.6 (Release - Donationware):
- not published
V1.0.7 (Release - Donationware):
- New methods: Publish2, Subscribe3, Subscribe4
This new methods return the token, then after when arrived or publish the messages, you can compare
MQTT
Author: Alberto Iglesias - alberto@visualnet.inf.br
Version: 1.07
- MQTT
Events:- connectionlost ( )
- deliverycomplete (Token As String)
- messageArrived (Topic As String, Message As String)
- onConnect (Status as boolean As )
- onDisconnect (Status as boolean As )
- onInitialized ( )
- CleanSession As Boolean
- JavaDebug As Boolean
- KeepAliveInterval As Int
- QoS_AtLeastOnce As Int
- QoS_AtMostOnce As Int
- QoS_ExactlyOnce As Int
- generatedClientId As String
- About As String
- Connect (broker As String, ClientID As String, Username As String, Password As String) As Boolean
- Disconnect As Boolean
- Initialize (eventname As String)
- Publish (Topic As String, Message As String, Qos As Int, Retained As Boolean)
- Publish2 (Topic AsString, Message AsString, Qos AsInt, Retained AsBoolean)
- Subscribe (Topic As String)
- Subscribe2 (Topic As String, QoS as int)
- Subscribe3 (Topic As String)
- Subscribe4 (Topic As String, QoS as int))
- Unsubscribe (Topic As String)
- Version As String
- isConnected As Boolean
- android.permission.ACCESS_WIFI_STATE
- android.permission.INTERNET
![MqttSample1.png](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2FMqttSample1.png&hash=12b622c52bd5460204fb5c825f39240d)
![MqttRef2.png](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2FMqttRef2.png&hash=dd020eef7d2b953ddce9793bfe032fa1)
How works the MQTT protocol
![MqttScheme1.jpg](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2FMqttScheme1.jpg&hash=c40799506e59b3945760610aab04a47f)
Communication Infrastructure
![MqttScheme2.png](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2FMqttScheme2.png&hash=1f5fd94c4542eded992f74e3f51f69a7)
References:
http://mqtt.org/
http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html
Mosquitto Broker: http://mosquitto.org/
* This version is fully functional, the only one difference is when publishing a message the text "Donationware" is delivery with your message.
Please consider a simple €10 donation and I send to you the Library without "Donationware" text in a publish method.
Already available in B4J too:
https://www.b4x.com/android/forum/threads/mqtt-mq-telemetry-transport-for-b4j.48184/
Already available in B4i too:
https://www.b4x.com/android/forum/threads/mqtt-mq-telemetry-transport-for-b4i.50036/
![](/android/forum/proxy.php?image=http%3A%2F%2Fwww.visualnet.inf.br%2Fimagens%2Fb4a%2Fbtn_donateCC_LG2.gif&hash=cff34af895682eebd262b074709d1769)
Attachments
-
MQTTB4ASample.zip7.8 KB · Views: 885
-
MQTT Library1.0.2.zip162 KB · Views: 572
-
MQTTSampleActivity.zip8.2 KB · Views: 697
-
SampleSubscribe2.zip8.3 KB · Views: 650
-
MQTT Library1.0.4.zip154.6 KB · Views: 496
-
MQTT Library1.0.5.zip154.9 KB · Views: 530
-
SampleIsConnected.zip8.3 KB · Views: 738
-
SampleWithToken.zip8.2 KB · Views: 526
-
MQTT Library1.0.7.zip155.6 KB · Views: 947
Last edited: