I am a beginner on android and MQTT . I have been trying to figure out how to make an app which send simple messages to the MQTT server(broker). I cant find any simple explanation. Even the sample apps are too complicated to grasp. I know I need the server address, host, client id, user id and password to connect but the question is HOW? Any help will be great, please just try to keep it simple as possible. Thanks!
Here is some tips to make your own mqtt service if you still have a question for this.
1. Server Application - mosquitto
Visit the site to get a binary or source code. then build or install the mosquitto server for your operating system.
2. Running and testing the mosquitto broker.
mosquitto -c $MOSQUITTO_HOME/conf/mosquitto.conf -d > $MOSQUITTO_HOME/log/mosquitto.log
mosquitto_sub -h 127.0.0.1 -t /test/1
mosquitto_pub -h 127.0.0.1 -t /test/1 -m "Hello Mosquitt"
3. Paho java client - mqtt client
You can use mqtt clients for the site list using any programming language you are familiar with.
I think you can use java client and android service is the best choice.
The java client might be needed for debugging and the core library.
you can choose either a jframe implementation for the standare jdk or swt-plugin implementation for eclipse ide from the github .
You can also check my customized jframe version of mine . it might be helpful how mqtt message can be published and subscribed by the broker.
4. Paho client for android
Get a source code from github . Be sure to have the core library from the java client library at the step 3. You can use pre-compiled version of this core library from my github . Then, compile and build app with whatever ide tools like eclipse+ADT or android studio(recommended)
You can check the images since successfully installed the paho app and can also refer my customized android app version from github .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.