Paho - EyesOfThings/Software GitHub Wiki
Index
MQTT protocol
MQTT is a lightweight publish/subscribe protocol designed for use over TCP/IP networks which provides an efficient 1-to-n communication mechanism. MQTT has been designed for low bandwidth and unreliable or intermittent connections, thus being a strong candidate in the Internet of Things scenario. MQTT-enabled devices can open a connection and keep it open using very little power.
The typical scenario is that of an embedded client which connects to an MQTT server (message broker) in the cloud:
Again, in this scenario the brokering service has to be purchased by the user, or else it has to be installed on a locally-managed server. In the EoT project a novel architecture in which each EoT device can act as a broker is proposed. This way no external server will be required, and data will not be initially sent through the Internet. In fact, the configuration device (another device as smartphone, tablet or PC) and the EoT node do not need to be in a WiFi network infrastructure, since an ad hoc network is created by the EoT device by default. This allows setting up applications in which only the EoT and another device are involved. That is in fact the default mode upon boot, with the additional possibility of connecting to an existing WiFi network. As a result, depending on the final application an EoT device can be configured to work at 3 levels:
- Single device mode (with the only requirement of a configuration device, typically a smartphone, tablet or laptop, connecting to the EoT-generated ad-hoc WiFi).
- Home, i.e. EoT device connecting to a local WiFi infrastructure.
- EoT device connecting to the cloud (through the WiFi infrastructure).
Read more about MQTT protocol and approach in the EoT project here.
Introduction
An MQTT client can act as a publisher, a subscriber or both. Due to the small resources needed by the MQTT protocol, an MQTT client may run in any device from a micro controller up to a server. Basically any device that has a TCP/IP stack can use MQTT over it using:
- A plain TCP socket.
- A secure SSL/TLS socket.
Paho Java Client is an MQTT client library written in Java for developing applications that runs on the Java Virtual Machine, JVM. Moreover, it can be used under Android through the Paho Android Service.
Paho provides two APIs: MqttAsyncClient and MqttClient.
- MqttAsyncClient provides a fully asychronous API where completion of activities is notified via registered callbacks.
- MqttClient is a lightweight client that blocks the application until an operation is complete. This class implements the blocking IMqttClient client interface.
Licensing
The Java MQTT library is published under Eclipse Public License.
Additional information
Additional information can be checked in following links: