Skip to main content

MQTT Broker for Android Mobile

MQTT Broker 

    MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.


MQTT Broker for Android Mobile

    After the long search I could not find any working android application for running MQTT broker in my mobile, so I decided to make it myself. In this post I am going to show you how the MQTT broker can be written for Android.


Moquette for Android

    Finally I found the Moquette based GitHub fork for the android application. I decided to create simple (very simple... Even there is no UI  😼 ) application on top of Moquette using the above GitHub project. Thanks to andsel (Contributor of this GitHub)

Steps 

  • Download the Project from GitHub
  • Create the new Android project using Android Studio (The tutorial to create a new Android Project and setup the Android studio can be available here )
  • Change the settings.gradle and add the dependent project module paths like below
include ':app', ':broker', ':netty_parser', 'parser_commons'
project(':broker').projectDir = new File(settingsDir, '../moquette/broker/')
project(':netty_parser').projectDir = new File(settingsDir, '../moquette/netty_parser/')
project(':parser_commons').projectDir = new File(settingsDir, '../moquette/parser_commons/')
  • Create the object for Server and start the server. Add the below line in MainActivity.java
new Server().startServer();
  • Enable the Read Write permission for external storage. It can be enabled via Manifest.xml entry, if we using the Android M or Higher version then we need to enable the run time permission (The detailed tutorial to request a permissions in android can be available here)
  • That's all, we are ready to run the MQTT on android mobile. Now build and deploy the apk file. 
  • Start the application. The MQTT broker will be run on the default MQTT port 1883. Use the IP address of the mobile to access the broker.

Source Code and APK for MQTT Broker

The source code for the MQTT Broker application is available in the GitHub. The apk file can be downloaded from my Google Drive.

Comments

Popular posts from this blog

ESP8266 Firmware flash using Arduino

ESP8266 Firmware flash with Arduino The ESP8266 WiFi module firmware can be updated with the Arduino IDE and Board. Things Required ESP8266 Arduino Arduino IDE Jumber pins Firmware flashing tool Latest Firmware Connection between ESP8266 and Arduino ESP8266 Arduino VCC 3V GND GND RX RX TX TX CH_PD 3V GPIO1 GND Prerequisites  Step 1: Download the  AT25-SDK112 firmware  which will be supported with the  WiFiEsp Arduino library Step 2: Download the  Firmware update  tool Step 3: Before connecting the ESP8266 with Arduino clear the Arduino by uploading the below empty sketch. It remove the previously installed sketch from Arduino. void setup() { }  void loop() {  }  Step 4: Connect the ESP8266 and Arduino pins as mentioned in the above table. Step 4: Connect the Arduino with PC and find the connected COM port  Step 5: Close the Arduino IDE if it is ope...

Node Red Installation in Android Mobile

What is Node Red ? Node-RED is a programming tool for wiring together hardware devices. Node-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range of nodes. Node-RED is built on Node.js, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi. Node red also can be run in the Android mobile without root. How to run Node Red in Android ? Node Red can be installed in Android mobile with the help of Termux . What is Termux ? Termux is an  Android terminal emulator and Linux environment app  that works directly with no rooting or setup required. A minimal base system is installed automatically - additional packages are available using the APT package manager. Termux Installation Termux application can be easily installed from Google Play store Open the Termux application which will be looks like a Linux terminal. ...