inuits/android-inuits-mqttlib

Name: android-inuits-mqttlib

Owner: Inuits

Description: Android library for working with Paho Android Client via Intents

Created: 2017-10-18 10:22:02.0

Updated: 2017-12-02 17:34:55.0

Pushed: 2017-12-05 15:11:52.0

Homepage: null

Size: 104

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Android MQTT lib wrapper

This repository should wrap PAHO ECLIPSE ANDROID SERVICE library. Its main intended use is to expose librari api via intent calls.

InuitsMqttService

is subclass of IntentService and translates intent calls into PAHO Service library.

The services returns all messages also via intents:

nt intent = new Intent(Constants.MESSAGE_RECEIVED);
nt.putExtra(Constants.MESSAGE_TOPIC, topic);
nt.putExtra(Constants.MESSAGE_DATA, payload);
Broadcast(intent);
InuitsMqttControler

is simple wrapper to call intents. But you can also call the Intents by yourself.

Connect
nt mqttServiceIntent = null;
ServiceIntent = new Intent(this.context, InuitsMqttService.class);
ServiceIntent.putExtra(Constants.ACTION,Constants.ACTION_CONNECT);
ServiceIntent.putExtra(Constants.DATA_SERVER_URI,uri);
ServiceIntent.putExtra(Constants.DATA_CLIENT_ID,clientId);
.context.startService(mqttServiceIntent);
Disconnect
nt mqttServiceIntent = null;
ServiceIntent = new Intent(this.context, InuitsMqttService.class);
ServiceIntent.putExtra(Constants.ACTION,Constants.ACTION_DISCONNECT);
.context.startService(mqttServiceIntent);
Subscribe
nt mqttServiceIntent = null;
ServiceIntent = new Intent(this.context, InuitsMqttService.class);
ServiceIntent.putExtra(Constants.ACTION, Constants.ACTION_SUBSCRIBE);
ServiceIntent.putExtra(Constants.DATA_TOPIC, topic);
ServiceIntent.putExtra(Constants.DATA_QOS, qos);
.context.startService(mqttServiceIntent);
Unsubscribe
nt mqttServiceIntent = null;
ServiceIntent = new Intent(this.context, InuitsMqttService.class);
ServiceIntent.putExtra(Constants.ACTION, Constants.ACTION_UNSUBSCRIBE);
ServiceIntent.putExtra(Constants.DATA_TOPIC, topic);
.context.startService(mqttServiceIntent);
Publish
nt mqttServiceIntent = null;
ServiceIntent = new Intent(this.context, InuitsMqttService.class);
ServiceIntent.putExtra(Constants.ACTION, Constants.ACTION_PUBLISH);
ServiceIntent.putExtra(Constants.DATA_TOPIC, topic);
ServiceIntent.setData(Uri.parse(message));
.context.startService(mqttServiceIntent);

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.