├── app ├── src │ └── main │ │ ├── assets │ │ └── file │ │ ├── ic_launcher-playstore.png │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── arrow.png │ │ ├── drawable-ldpi │ │ │ └── arrow.png │ │ ├── drawable-mdpi │ │ │ └── arrow.png │ │ ├── drawable-xhdpi │ │ │ └── arrow.png │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── values │ │ │ ├── ic_launcher_background.xml │ │ │ ├── attrs_arrow.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── menu │ │ │ ├── activity_client_connections_contextual.xml │ │ │ ├── activity_connection_details.xml │ │ │ ├── activity_last_will.xml │ │ │ ├── activity_connection_details_disconnected.xml │ │ │ ├── activity_publish.xml │ │ │ ├── activity_subscribe.xml │ │ │ ├── activity_publish_disconnected.xml │ │ │ ├── activity_subscribe_disconnected.xml │ │ │ ├── activity_connections_logging.xml │ │ │ ├── activity_new_connection.xml │ │ │ ├── activity_advanced.xml │ │ │ └── activity_connections.xml │ │ ├── drawable │ │ │ ├── ic_add.xml │ │ │ ├── ic_cloud_circle.xml │ │ │ └── ic_launcher_foreground.xml │ │ ├── layout │ │ │ ├── list_view_text_view.xml │ │ │ ├── activity_connection_details.xml │ │ │ ├── connection_text_view.xml │ │ │ ├── client_connections.xml │ │ │ ├── filedialogitem.xml │ │ │ ├── activity_subscribe.xml │ │ │ ├── activity_new_connection.xml │ │ │ ├── activity_last_will.xml │ │ │ ├── activity_publish.xml │ │ │ └── activity_advanced.xml │ │ └── raw │ │ │ └── jsr47android.properties │ │ ├── resources │ │ └── io │ │ │ └── bytehala │ │ │ └── eclipsemqtt │ │ │ └── sample │ │ │ └── package.html │ │ ├── java │ │ └── io │ │ │ └── bytehala │ │ │ └── eclipsemqtt │ │ │ └── sample │ │ │ ├── CallbackBundle.java │ │ │ ├── MqttTraceCallback.java │ │ │ ├── SubscribeFragment.java │ │ │ ├── PublishFragment.java │ │ │ ├── PersistenceException.java │ │ │ ├── HistoryFragment.java │ │ │ ├── LastWillActivity.java │ │ │ ├── Notify.java │ │ │ ├── ActivityConstants.java │ │ │ ├── Connections.java │ │ │ ├── MqttCallbackHandler.java │ │ │ ├── OpenFileDialog.java │ │ │ ├── ActionListener.java │ │ │ ├── AdvancedActivity.java │ │ │ ├── NewConnectionActivity.java │ │ │ ├── Listener.java │ │ │ ├── Persistence.java │ │ │ ├── Connection.java │ │ │ └── ConnectionDetailsActivity.java │ │ └── AndroidManifest.xml ├── libs │ └── org.eclipse.paho.android.service-1.0.2.jar └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── jarRepositories.xml ├── markdown-navigator.xml └── markdown-navigator-enh.xml ├── .travis.yml ├── gradle.properties ├── import-summary.txt ├── gradlew.bat ├── README.md ├── .gitignore └── gradlew /app/src/main/assets/file: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/drawable-hdpi/arrow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/drawable-ldpi/arrow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/drawable-mdpi/arrow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/drawable-xhdpi/arrow.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/libs/org.eclipse.paho.android.service-1.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/libs/org.eclipse.paho.android.service-1.0.2.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bytehala/android-mqtt-quickstart/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Apr 06 17:16:30 MDT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_client_connections_contextual.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs_arrow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/resources/io/bytehala/eclipsemqtt/sample/package.html: -------------------------------------------------------------------------------- 1 | 2 | Contains classes for a basic graphical user interface to drive multiple MQTT clients. 3 |

Since the Android environment does not allow object references to be passed between activities, the classes Connection and Connections 4 | enable a basic Model to pass connections around using unique client handles.

5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cloud_circle.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_view_text_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_connection_details.xml: -------------------------------------------------------------------------------- 1 | 12 |

14 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_last_will.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_connection_details_disconnected.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_connection_details.xml: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/connection_text_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | # Uncomment the lines below if you want to 5 | # use the latest revision of Android SDK Tools 6 | # - platform-tools 7 | - tools 8 | 9 | # The BuildTools version used by your project 10 | - build-tools-28.0.3 11 | 12 | # The SDK version used to compile your project 13 | - android-28 14 | 15 | # Additional components 16 | #- extra-google-m2repository 17 | #- extra-android-m2repository 18 | #- addon-google_apis-google-19 19 | 20 | # Specify at least one system image, 21 | # if you need to run emulator(s) during your tests 22 | #- sys-img-armeabi-v7a-android-19 23 | #- sys-img-x86-android-17 -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_publish.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 16 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_subscribe.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 16 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_publish_disconnected.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 16 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_subscribe_disconnected.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 16 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_connections_logging.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 19 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_new_connection.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_advanced.xml: -------------------------------------------------------------------------------- 1 | 12 | 15 | 16 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/CallbackBundle.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | 16 | import android.os.Bundle; 17 | 18 | /** 19 | * For File selector to share data 20 | * 21 | */ 22 | public interface CallbackBundle { 23 | abstract void callback(Bundle bundle); 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_connections.xml: -------------------------------------------------------------------------------- 1 | 12 | 14 | 15 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/MqttTraceCallback.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import org.eclipse.paho.android.service.MqttTraceHandler; 16 | 17 | import android.util.Log; 18 | 19 | public class MqttTraceCallback implements MqttTraceHandler { 20 | 21 | public void traceDebug(java.lang.String arg0, java.lang.String arg1) { 22 | Log.i(arg0, arg1); 23 | }; 24 | 25 | public void traceError(java.lang.String arg0, java.lang.String arg1) { 26 | Log.e(arg0, arg1); 27 | }; 28 | 29 | public void traceException(java.lang.String arg0, java.lang.String arg1, 30 | java.lang.Exception arg2) { 31 | Log.e(arg0, arg1, arg2); 32 | }; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/client_connections.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 17 | 18 | 25 | 26 | 27 | 28 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/SubscribeFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import android.os.Bundle; 16 | import android.view.LayoutInflater; 17 | import android.view.View; 18 | import android.view.ViewGroup; 19 | 20 | import androidx.fragment.app.Fragment; 21 | 22 | /** 23 | * Fragment for the subscribe pane for the client 24 | * 25 | */ 26 | public class SubscribeFragment extends Fragment { 27 | 28 | /** 29 | * @see Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle) 30 | */ 31 | @Override 32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 33 | Bundle savedInstanceState) { 34 | 35 | return LayoutInflater.from(getActivity()).inflate(R.layout.activity_subscribe, null); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/PublishFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import android.os.Bundle; 16 | import android.view.LayoutInflater; 17 | import android.view.View; 18 | import android.view.ViewGroup; 19 | 20 | import androidx.fragment.app.Fragment; 21 | 22 | /** 23 | * Fragment for the publish message pane. 24 | * 25 | */ 26 | public class PublishFragment extends Fragment { 27 | 28 | /** 29 | * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) 30 | */ 31 | @Override 32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 33 | Bundle savedInstanceState) { 34 | 35 | return LayoutInflater.from(getActivity()).inflate(R.layout.activity_publish, null); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion '28.0.3' 6 | 7 | defaultConfig { 8 | applicationId "io.bytehala.eclipsemqtt.sample" 9 | minSdkVersion 18 10 | targetSdkVersion 28 11 | multiDexEnabled true 12 | versionCode 3 13 | versionName "1.1-SNAPSHOT" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 20 | } 21 | } 22 | 23 | lintOptions { 24 | abortOnError false 25 | } 26 | 27 | compileOptions { 28 | sourceCompatibility '1.8' 29 | targetCompatibility '1.8' 30 | } 31 | } 32 | 33 | dependencies { 34 | implementation "androidx.core:core:1.2.0" 35 | implementation "com.google.android.material:material:1.1.0" 36 | implementation 'com.android.support:design:28.0.0' 37 | 38 | // Do not remove, even if using AndroidX. Used by :org.eclipse.paho.android.service 39 | implementation 'com.android.support:support-v4:28.0.0' 40 | // Eclipse MQTT libraries 41 | implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1' 42 | implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.2' 43 | 44 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/filedialogitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 35 | 36 | 37 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/PersistenceException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | /** 16 | * Persistence Exception, defines an error with persisting a {@link Connection} 17 | * fails. Example operations are {@link Persistence#persistConnection(Connection)} and {@link Persistence#restoreConnections(android.content.Context)}; 18 | * these operations throw this exception to indicate unexpected results occurred when performing actions on the database. 19 | * 20 | */ 21 | public class PersistenceException extends Exception { 22 | 23 | /** 24 | * Creates a persistence exception with the given error message 25 | * @param message The error message to display 26 | */ 27 | public PersistenceException(String message) { 28 | super(message); 29 | } 30 | 31 | /** Serialisation ID**/ 32 | private static final long serialVersionUID = 5326458803268855071L; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /import-summary.txt: -------------------------------------------------------------------------------- 1 | ECLIPSE ANDROID PROJECT IMPORT SUMMARY 2 | ====================================== 3 | 4 | Ignored Files: 5 | -------------- 6 | The following files were *not* copied into the new Gradle project; you 7 | should evaluate whether these are still needed in your project and if 8 | so manually move them: 9 | 10 | * build.xml 11 | * ic_launcher-web.png 12 | * proguard-project.txt 13 | 14 | Replaced Jars with Dependencies: 15 | -------------------------------- 16 | The importer recognized the following .jar files as third party 17 | libraries and replaced them with Gradle dependencies instead. This has 18 | the advantage that more explicit version information is known, and the 19 | libraries can be updated automatically. However, it is possible that 20 | the .jar file in your project was of an older version than the 21 | dependency we picked, which could render the project not compileable. 22 | You can disable the jar replacement in the import wizard and try again: 23 | 24 | android-support-v4.jar => com.android.support:support-v4:19.1.0 25 | 26 | Moved Files: 27 | ------------ 28 | Android Gradle projects use a different directory structure than ADT 29 | Eclipse projects. Here's how the projects were restructured: 30 | 31 | * AndroidManifest.xml => app/src/main/AndroidManifest.xml 32 | * assets/ => app/src/main/assets/ 33 | * libs/org.eclipse.paho.android.service-1.0.2.jar => app/libs/org.eclipse.paho.android.service-1.0.2.jar 34 | * libs/org.eclipse.paho.client.mqttv3-1.0.2.jar => app/libs/org.eclipse.paho.client.mqttv3-1.0.2.jar 35 | * res/ => app/src/main/res/ 36 | * src/ => app/src/main/java/ 37 | * src/org/eclipse/paho/android/service/sample/package.html => app/src/main/resources/org/eclipse/paho/android/service/sample/package.html 38 | 39 | Next Steps: 40 | ----------- 41 | You can now build the project. The Gradle project needs network 42 | connectivity to download dependencies. 43 | 44 | Bugs: 45 | ----- 46 | If for some reason your project does not build, and you determine that 47 | it is due to a bug or limitation of the Eclipse to Gradle importer, 48 | please file a bug at http://b.android.com with category 49 | Component-Tools. 50 | 51 | (This import summary is for your information only, and can be deleted 52 | after import once you are satisfied with the results.) 53 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/HistoryFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import android.os.Bundle; 16 | import android.text.Spanned; 17 | import android.widget.ArrayAdapter; 18 | 19 | import androidx.fragment.app.ListFragment; 20 | import io.bytehala.eclipsemqtt.sample.R; 21 | 22 | /** 23 | * This fragment displays the history information for a client 24 | * 25 | */ 26 | public class HistoryFragment extends ListFragment { 27 | 28 | /** Client handle to a {@link Connection} object **/ 29 | String clientHandle = null; 30 | /** {@link ArrayAdapter} to display the formatted text **/ 31 | ArrayAdapter arrayAdapter = null; 32 | 33 | /** 34 | * @see ListFragment#onCreate(Bundle) 35 | */ 36 | @Override 37 | public void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | 40 | //Pull history information out of bundle 41 | 42 | clientHandle = getArguments().getString("handle"); 43 | Connection connection = Connections.getInstance(getActivity()).getConnection(clientHandle); 44 | 45 | Spanned[] history = connection.history(); 46 | 47 | //Initialise the arrayAdapter, view and add data 48 | arrayAdapter = new ArrayAdapter(getActivity(), R.layout.list_view_text_view); 49 | 50 | arrayAdapter.addAll(history); 51 | setListAdapter(arrayAdapter); 52 | 53 | } 54 | 55 | /** 56 | * Updates the data displayed to match the current history 57 | */ 58 | public void refresh() { 59 | if (arrayAdapter != null) { 60 | arrayAdapter.clear(); 61 | arrayAdapter.addAll(Connections.getInstance(getActivity()).getConnection(clientHandle).history()); 62 | arrayAdapter.notifyDataSetChanged(); 63 | } 64 | 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 53 | 56 | 57 | 58 | 59 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/LastWillActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import android.app.Activity; 16 | import android.content.Intent; 17 | import android.os.Bundle; 18 | import android.view.Menu; 19 | import android.view.MenuItem; 20 | import android.view.MenuItem.OnMenuItemClickListener; 21 | import android.widget.CheckBox; 22 | import android.widget.EditText; 23 | import android.widget.RadioGroup; 24 | 25 | import androidx.appcompat.app.AppCompatActivity; 26 | 27 | /** 28 | * Activity for setting the last will message for the client 29 | * 30 | */ 31 | public class LastWillActivity extends AppCompatActivity { 32 | 33 | /** 34 | * Reference to the current instance of LastWillActivity for use with anonymous listener 35 | */ 36 | private LastWillActivity last = this; 37 | 38 | /** 39 | * @see Activity#onCreate(Bundle) 40 | */ 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_last_will); 45 | 46 | } 47 | 48 | /** 49 | * @see Activity#onCreateOptionsMenu(Menu) 50 | */ 51 | @Override 52 | public boolean onCreateOptionsMenu(Menu menu) { 53 | getMenuInflater().inflate(R.menu.activity_last_will, menu); 54 | 55 | menu.findItem(R.id.publish).setOnMenuItemClickListener(new OnMenuItemClickListener() { 56 | 57 | @Override 58 | public boolean onMenuItemClick(MenuItem item) { 59 | 60 | Intent result = new Intent(); 61 | 62 | String message = ((EditText) findViewById(R.id.lastWill)).getText().toString(); 63 | String topic = ((EditText) findViewById(R.id.lastWillTopic)).getText().toString(); 64 | 65 | RadioGroup radio = (RadioGroup) findViewById(R.id.qosRadio); 66 | int checked = radio.getCheckedRadioButtonId(); 67 | int qos = ActivityConstants.defaultQos; 68 | 69 | //determine which qos value has been selected 70 | switch (checked) 71 | { 72 | case R.id.qos0 : 73 | qos = 0; 74 | break; 75 | case R.id.qos1 : 76 | qos = 1; 77 | break; 78 | case R.id.qos2 : 79 | qos = 2; 80 | break; 81 | } 82 | 83 | boolean retained = ((CheckBox) findViewById(R.id.retained)).isChecked(); 84 | 85 | //package the data collected into the intent 86 | result.putExtra(ActivityConstants.message, message); 87 | result.putExtra(ActivityConstants.topic, topic); 88 | result.putExtra(ActivityConstants.qos, qos); 89 | result.putExtra(ActivityConstants.retained, retained); 90 | 91 | //set the result and finish activity 92 | last.setResult(RESULT_OK, result); 93 | last.finish(); 94 | 95 | return false; 96 | } 97 | 98 | }); 99 | return true; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/Notify.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import java.util.Calendar; 16 | import io.bytehala.eclipsemqtt.sample.R; 17 | import android.app.Notification; 18 | import android.app.NotificationManager; 19 | import android.app.PendingIntent; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | import android.widget.Toast; 23 | 24 | import androidx.core.app.NotificationCompat; 25 | 26 | /** 27 | * Provides static methods for creating and showing notifications to the user. 28 | * 29 | */ 30 | public class Notify { 31 | 32 | /** Message ID Counter **/ 33 | private static int MessageID = 0; 34 | 35 | /** 36 | * Displays a notification in the notification area of the UI 37 | * @param context Context from which to create the notification 38 | * @param messageString The string to display to the user as a message 39 | * @param intent The intent which will start the activity when the user clicks the notification 40 | * @param notificationTitle The resource reference to the notification title 41 | */ 42 | static void notifcation(Context context, String messageString, Intent intent, int notificationTitle) { 43 | 44 | //Get the notification manage which we will use to display the notification 45 | String ns = Context.NOTIFICATION_SERVICE; 46 | NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); 47 | 48 | Calendar.getInstance().getTime().toString(); 49 | 50 | long when = System.currentTimeMillis(); 51 | 52 | //get the notification title from the application's strings.xml file 53 | CharSequence contentTitle = context.getString(notificationTitle); 54 | 55 | //the message that will be displayed as the ticker 56 | String ticker = contentTitle + " " + messageString; 57 | 58 | //build the pending intent that will start the appropriate activity 59 | PendingIntent pendingIntent = PendingIntent.getActivity(context, 60 | ActivityConstants.showHistory, intent, 0); 61 | 62 | //build the notification 63 | NotificationCompat.Builder notificationCompat = new NotificationCompat.Builder(context); 64 | notificationCompat.setAutoCancel(true) 65 | .setContentTitle(contentTitle) 66 | .setContentIntent(pendingIntent) 67 | .setContentText(messageString) 68 | .setTicker(ticker) 69 | .setWhen(when) 70 | .setSmallIcon(R.mipmap.ic_launcher); 71 | 72 | Notification notification = notificationCompat.build(); 73 | //display the notification 74 | mNotificationManager.notify(MessageID, notification); 75 | MessageID++; 76 | 77 | } 78 | 79 | /** 80 | * Display a toast notification to the user 81 | * @param context Context from which to create a notification 82 | * @param text The text the toast should display 83 | * @param duration The amount of time for the toast to appear to the user 84 | */ 85 | static void toast(Context context, CharSequence text, int duration) { 86 | Toast toast = Toast.makeText(context, text, duration); 87 | toast.show(); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_subscribe.xml: -------------------------------------------------------------------------------- 1 | 12 | 17 | 18 | 22 | 23 | 29 | 30 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 57 | 58 | 65 | 66 | 67 | 73 | 74 | 79 | 80 | 85 | 86 | 87 | 88 | 89 | 90 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /app/src/main/res/raw/jsr47android.properties: -------------------------------------------------------------------------------- 1 | # Properties file which configures the operation of the JDK logging facility. 2 | # 3 | # The configuration in this file is the suggesgted configuration 4 | # for collecting trace for helping debug problems related to the 5 | # Paho MQTT client. It configures trace to be continuosly collected 6 | # in memory with minimal impact on performance. 7 | # 8 | # When the push trigger (by default a Severe level message) or a 9 | # specific request is made to "push" the in memory trace then it 10 | # is "pushed" to the configured target handler. By default 11 | # this is the standard java.util.logging.FileHandler. The Paho Debug 12 | # class can be used to push the memory trace to its target 13 | # 14 | # To enable trace either: 15 | # - use this properties file as is and set the logging facility up 16 | # to use it by configuring the util logging system property e.g. 17 | # 18 | # >java -Djava.util.logging.config.file=\jsr47android.properties 19 | # 20 | # - explicitly load this file as the configuration file for a LogManager 21 | # 22 | # - This contents of this file can also be merged with another 23 | # java.util.logging config file to ensure provide wider logging 24 | # and trace including Paho trace 25 | 26 | # Global logging properties. 27 | # ------------------------------------------ 28 | # The set of handlers to be loaded upon startup. 29 | # Comma-separated list of class names. 30 | handlers=java.util.logging.FileHandler 31 | 32 | # Default global logging level. 33 | # Loggers and Handlers may override this level 34 | #.level=INFO 35 | 36 | # Loggers 37 | # ------------------------------------------ 38 | # A FileHandler is attached to the paho packages 39 | # and the level specified to collected all trace related 40 | # to paho packages. This will override any root/global 41 | # level handlers if set. 42 | org.eclipse.paho.client.mqttv3.handlers=java.util.logging.FileHandler 43 | 44 | org.eclipse.paho.client.mqttv3.level=ALL 45 | # It is possible to set more granular trace on a per class basis e.g. 46 | #org.eclipse.paho.client.mqttv3.internal.ClientComms.level=ALL 47 | 48 | # Handlers 49 | # ----------------------------------------- 50 | # Note: the target handler that is associated with the MemoryHandler is not a root handler 51 | # and hence not returned when getting the handlers from root. It appears accessing 52 | # target handler programatically is not possible as target is a private variable in 53 | # class MemoryHandler 54 | java.util.logging.MemoryHandler.level=FINEST 55 | java.util.logging.MemoryHandler.size=10000 56 | java.util.logging.MemoryHandler.push=SEVERE 57 | java.util.logging.MemoryHandler.target=java.util.logging.FileHandler 58 | #java.util.logging.MemoryHandler.target=java.util.logging.ConsoleHandler 59 | 60 | 61 | # --- FileHandler --- 62 | # Override of global logging level 63 | java.util.logging.FileHandler.level=ALL 64 | 65 | # Naming style for the output file: 66 | # (The output file is placed in the directory 67 | # defined by the "java.io.tmpdir" System property.) 68 | # See java.util.logging for more options 69 | java.util.logging.FileHandler.pattern=%t/paho%u.log 70 | 71 | # Limiting size of output file in bytes: 72 | java.util.logging.FileHandler.limit=200000 73 | 74 | # Number of output files to cycle through, by appending an 75 | # integer to the base file name: 76 | java.util.logging.FileHandler.count=3 77 | 78 | # Style of output (Simple or XML): 79 | java.util.logging.FileHandler.formatter=org.eclipse.paho.client.mqttv3.logging.SimpleLogFormatter 80 | 81 | # --- ConsoleHandler --- 82 | # Override of global logging level 83 | #java.util.logging.ConsoleHandler.level=INFO 84 | #java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter 85 | #java.util.logging.ConsoleHandler.formatter=org.eclipse.paho.client.mqttv3.internal.logging.SimpleLogFormatter 86 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/ActivityConstants.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import org.eclipse.paho.client.mqttv3.MqttMessage; 16 | 17 | /** 18 | * This Class provides constants used for returning results from an activity 19 | * 20 | */ 21 | public class ActivityConstants { 22 | 23 | /** Application TAG for logs where class name is not used*/ 24 | static final String TAG = "MQTT Android"; 25 | 26 | /*Default values **/ 27 | 28 | /** Default QOS value*/ 29 | static final int defaultQos = 0; 30 | /** Default timeout*/ 31 | static final int defaultTimeOut = 1000; 32 | /** Default keep alive value*/ 33 | static final int defaultKeepAlive = 10; 34 | /** Default SSL enabled flag*/ 35 | static final boolean defaultSsl = false; 36 | /** Default message retained flag */ 37 | static final boolean defaultRetained = false; 38 | /** Default last will message*/ 39 | static final MqttMessage defaultLastWill = null; 40 | /** Default port*/ 41 | static final int defaultPort = 1883; 42 | 43 | /** Connect Request Code */ 44 | static final int connect = 0; 45 | /** AdvancedActivity Connect Request Code **/ 46 | static final int advancedConnect = 1; 47 | /** Last will Request Code **/ 48 | static final int lastWill = 2; 49 | /** Show History Request Code **/ 50 | static final int showHistory = 3; 51 | 52 | /* Bundle Keys */ 53 | 54 | /** Server Bundle Key **/ 55 | static final String server = "server"; 56 | /** Port Bundle Key **/ 57 | static final String port = "port"; 58 | /** ClientID Bundle Key **/ 59 | static final String clientId = "clientId"; 60 | /** Topic Bundle Key **/ 61 | static final String topic = "topic"; 62 | /** History Bundle Key **/ 63 | static final String history = "history"; 64 | /** Message Bundle Key **/ 65 | static final String message = "message"; 66 | /** Retained Flag Bundle Key **/ 67 | static final String retained = "retained"; 68 | /** QOS Value Bundle Key **/ 69 | static final String qos = "qos"; 70 | /** User name Bundle Key **/ 71 | static final String username = "username"; 72 | /** Password Bundle Key **/ 73 | static final String password = "password"; 74 | /** Keep Alive value Bundle Key **/ 75 | static final String keepalive = "keepalive"; 76 | /** Timeout Bundle Key **/ 77 | static final String timeout = "timeout"; 78 | /** SSL Enabled Flag Bundle Key **/ 79 | static final String ssl = "ssl"; 80 | /** SSL Key File Bundle Key **/ 81 | static final String ssl_key = "ssl_key"; 82 | /** Connections Bundle Key **/ 83 | static final String connections = "connections"; 84 | /** Clean Session Flag Bundle Key **/ 85 | static final String cleanSession = "cleanSession"; 86 | /** Action Bundle Key **/ 87 | static final String action = "action"; 88 | 89 | /* Property names */ 90 | 91 | /** Property name for the history field in {@link Connection} object for use with {@link java.beans.PropertyChangeEvent} **/ 92 | static final String historyProperty = "history"; 93 | 94 | /** Property name for the connection status field in {@link Connection} object for use with {@link java.beans.PropertyChangeEvent} **/ 95 | static final String ConnectionStatusProperty = "connectionStatus"; 96 | 97 | /* Useful constants*/ 98 | 99 | /** Space String Literal **/ 100 | static final String space = " "; 101 | /** Empty String for comparisons **/ 102 | static final String empty = new String(); 103 | 104 | } 105 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | xmlns:android 17 | 18 | ^$ 19 | 20 | 21 | 22 |
23 |
24 | 25 | 26 | 27 | xmlns:.* 28 | 29 | ^$ 30 | 31 | 32 | BY_NAME 33 | 34 |
35 |
36 | 37 | 38 | 39 | .*:id 40 | 41 | http://schemas.android.com/apk/res/android 42 | 43 | 44 | 45 |
46 |
47 | 48 | 49 | 50 | .*:name 51 | 52 | http://schemas.android.com/apk/res/android 53 | 54 | 55 | 56 |
57 |
58 | 59 | 60 | 61 | name 62 | 63 | ^$ 64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 | style 73 | 74 | ^$ 75 | 76 | 77 | 78 |
79 |
80 | 81 | 82 | 83 | .* 84 | 85 | ^$ 86 | 87 | 88 | BY_NAME 89 | 90 |
91 |
92 | 93 | 94 | 95 | .* 96 | 97 | http://schemas.android.com/apk/res/android 98 | 99 | 100 | ANDROID_ATTRIBUTE_ORDER 101 | 102 |
103 |
104 | 105 | 106 | 107 | .* 108 | 109 | .* 110 | 111 | 112 | BY_NAME 113 | 114 |
115 |
116 |
117 |
118 | 119 | 121 |
122 |
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > :warning: **Please feel free to create issues if it does not run for you. 2 | # android-mqtt-quickstart [![Build Status](https://travis-ci.org/bytehala/android-mqtt-quickstart.svg?branch=master)](https://travis-ci.org/bytehala/android-mqtt-quickstart) 3 | Android Studio port of the Eclipse paho MQTT sample project. 4 | Beside that you can use subscribe/pulish to a MQTT server, sms functionality is added to this project. 5 | 6 | 7 | ## How sms functionality is working ? 8 | If you want to send sms, you have to first subscribe to sms topic in application 9 | To set your phone number in messages received via sms topic, The thirteen first characters of your message will be the phone number you want to send 10 | example: 11 | ``` 12 | message topic: sms 13 | payload: +989375915077 Hello 14 | ``` 15 | 16 | 17 | It is highly recommended to change the default phone number in ```src\main\java\io\bytehala\eclipsemqtt\sample\MqttCallbackHandler.java``` line 141 18 | 19 | ## Environment Tested On 20 | 1. OpenJDK Java 11 by Amazon (sdkman 11.0.6-amzn) 21 | 2. Samsung galaxy mini s5570 SDK version 18 ( OS android, Cyanogen mod ) 22 | 3. Android Studio 4.1.1 23 | 24 | #### This information are from the forked repo 25 | 26 | I am maintaining this on my own, and as such am unable to test on multiple devices and environments. 27 | 28 | You can support me buy contributing code, filing bugs, asking/answering questions, or buying me a coffee. 29 | 30 | 31 | Buy Me a Coffee at ko-fi.com 32 | 33 | 34 | ## Getting Started 35 | 1. Download the code `git clone http://www.github.com/bytehala/android-mqtt-quickstart` 36 | 2. Open the project in Android Studio 37 | 3. Build and run it. 38 | 39 | ## Using the Sample App 40 | To test the app, you need an MQTT broker. Luckily, HiveMQ provides a free one which we can use for testing. 41 | ![HiveMQ broker](http://i.imgur.com/zStIVr4.png "MQTT Settings") 42 | 43 | After successfully connecting, you can start subscribing and publishing to topics using the app. 44 | ![Subscribing](http://i.imgur.com/dPSryih.png "Subscribing") 45 | 46 | ![Success](http://i.imgur.com/gao1R0x.png "Success") 47 | 48 | ## More About MQTT 49 | MQTT is a messaging protocol which has applications in the Internet of Things (IoT). 50 | This sample project uses Eclipse's open-source implementation called the Paho Project. 51 | If you go to the [original source](https://github.com/eclipse/paho.mqtt.java) where I lifted this project from, there are non-Android sample projects that use the Paho library. 52 | 53 | This youtube video explains the MQTT for IoT at a very basic level. 54 | 55 | [![](http://img.youtube.com/vi/1XzC3WqmiBs/0.jpg)](http://www.youtube.com/watch?v=1XzC3WqmiBs "Basics of MQTT IoT") 56 | 57 | Learn more about the other MQTT options such as QOS, Last Will, etc from this really helpful 12 part series by HiveMQ 58 | http://www.hivemq.com/blog/mqtt-essentials/ 59 | 60 | ## Create Your Own App 61 | All you need is an MQTT broker. 62 | This app is just piggybacking on HiveMQ's free broker. 63 | 64 | Take note of the dependencies in this project. 65 | `org.eclipse.paho.android.service` and `org.eclipse.paho.client.mqttv3` depend on the old android-support-v4, specifically the LocalBroadcastManager class. 66 | 67 | Maybe we can migrate to mqttv5 using the plain Java library at https://github.com/eclipse/paho.mqtt.java 68 | 69 | The eclipse sources can be found at: 70 | https://github.com/eclipse/paho.mqtt.android 71 | 72 | Honestly, when I made an MQTT app for a client, I just built on top of this sample project. 73 | 74 | # Word of Warning 75 | This app was made in 2015-2016, and is a demo of how to use the Eclipse MQTT Libraries, not how to code in Android. 76 | 77 | Architecture components are a thing now, and I strongly advise the use of ViewModel and LifecycleHook. 78 | 79 | # Work In Progress 80 | Definitely look at the "jetpacknav" branch which aims to transform everything into a Single-Activity application, which has been the Android recommendation since 2018. It's currently a work in progress but a clear example of how to transform legacy apps from the old Android paradigm (multiple-Activity) to the newer ones (single-Activity Jetpack). 81 | 82 | # MQTT V3 vs V5 83 | This project uses MQTT v3 and I will be looking into using v3 and v5 in the near future. -------------------------------------------------------------------------------- /.idea/markdown-navigator-enh.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_new_connection.xml: -------------------------------------------------------------------------------- 1 | 12 | 17 | 18 | 22 | 23 | 29 | 30 | 37 | 38 | 39 | 45 | 46 | 52 | 53 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 107 | 108 | 109 | 117 | 118 | -------------------------------------------------------------------------------- /app/src/main/java/io/bytehala/eclipsemqtt/sample/Connections.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1999, 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | */ 13 | package io.bytehala.eclipsemqtt.sample; 14 | 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | import android.content.Context; 20 | 21 | import org.eclipse.paho.android.service.MqttAndroidClient; 22 | 23 | /** 24 | * Connections is a singleton class which stores all the connection objects 25 | * in one central place so they can be passed between activities using a client 26 | * handle 27 | * 28 | */ 29 | public class Connections { 30 | 31 | /** Singleton instance of Connections**/ 32 | private static Connections instance = null; 33 | 34 | /** List of {@link Connection} objects**/ 35 | private HashMap connections = null; 36 | 37 | /** {@link Persistence} object used to save, delete and restore connections**/ 38 | private Persistence persistence = null; 39 | 40 | /** 41 | * Create a Connections object 42 | * @param context Applications context 43 | */ 44 | private Connections(Context context) 45 | { 46 | connections = new HashMap(); 47 | 48 | //attempt to restore state 49 | persistence = new Persistence(context); 50 | try { 51 | List l = persistence.restoreConnections(context); 52 | for (Connection c : l) { 53 | connections.put(c.handle(), c); 54 | } 55 | } 56 | catch (PersistenceException e) { 57 | e.printStackTrace(); 58 | } 59 | 60 | } 61 | 62 | /** 63 | * Returns an already initialised instance of Connections, if Connections has yet to be created, it will 64 | * create and return that instance 65 | * @param context The applications context used to create the Connections object if it is not already initialised 66 | * @return Connections instance 67 | */ 68 | public synchronized static Connections getInstance(Context context) 69 | { 70 | if (instance == null) { 71 | instance = new Connections(context); 72 | } 73 | 74 | return instance; 75 | } 76 | 77 | /** 78 | * Finds and returns a connection object that the given client handle points to 79 | * @param handle The handle to the Connection to return 80 | * @return a connection associated with the client handle, null if one is not found 81 | */ 82 | public Connection getConnection(String handle) 83 | { 84 | 85 | return connections.get(handle); 86 | } 87 | 88 | /** 89 | * Adds a Connection object to the collection of connections associated with this object 90 | * @param connection connection to add 91 | */ 92 | public void addConnection(Connection connection) 93 | { 94 | connections.put(connection.handle(), connection); 95 | try { 96 | persistence.persistConnection(connection); 97 | } 98 | catch (PersistenceException e) 99 | { 100 | //error persisting well lets just swallow this 101 | e.printStackTrace(); 102 | } 103 | } 104 | 105 | /** 106 | * Create a fully initialised MqttAndroidClient for the parameters given 107 | * @param context The Applications context 108 | * @param serverURI The ServerURI to connect to 109 | * @param clientId The clientId for this client 110 | * @return new instance of MqttAndroidClient 111 | */ 112 | public MqttAndroidClient createClient(Context context, String serverURI, String clientId) 113 | { 114 | MqttAndroidClient client = new MqttAndroidClient(context, serverURI, clientId); 115 | return client; 116 | } 117 | 118 | /** 119 | * Get all the connections associated with this Connections object. 120 | * @return Map of connections 121 | */ 122 | public Map getConnections() 123 | { 124 | return connections; 125 | } 126 | 127 | /** 128 | * Removes a connection from the map of connections 129 | * @param connection connection to be removed 130 | */ 131 | public void removeConnection(Connection connection) { 132 | connections.remove(connection.handle()); 133 | persistence.deleteConnection(connection); 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_last_will.xml: -------------------------------------------------------------------------------- 1 | 12 | 18 | 19 | 23 | 24 | 30 | 31 | 39 | 40 | 41 | 42 | 43 | 44 | 50 | 57 | 58 | 66 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 85 | 86 | 92 | 93 | 100 | 101 | 106 | 107 | 112 | 113 | 114 | 115 | 116 | 122 | 128 | 129 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_publish.xml: -------------------------------------------------------------------------------- 1 | 12 | 18 | 19 | 23 | 24 | 30 | 31 | 39 | 40 | 41 | 42 | 43 | 44 | 50 | 57 | 58 | 66 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 84 | 85 | 91 | 92 | 99 | 100 | 105 | 106 | 111 | 112 | 113 | 120 | 121 | 126 | 127 | 128 | 129 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/java,gradle,kotlin,android,androidstudio 3 | # Edit at https://www.gitignore.io/?templates=java,gradle,kotlin,android,androidstudio 4 | 5 | ### Android ### 6 | # Built application files 7 | *.apk 8 | *.ap_ 9 | *.aab 10 | 11 | # Files for the ART/Dalvik VM 12 | *.dex 13 | 14 | # Java class files 15 | *.class 16 | 17 | # Generated files 18 | bin/ 19 | gen/ 20 | out/ 21 | release/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Android Studio Navigation editor temp files 37 | .navigation/ 38 | 39 | # Android Studio captures folder 40 | captures/ 41 | 42 | # IntelliJ 43 | *.iml 44 | .idea/workspace.xml 45 | .idea/tasks.xml 46 | .idea/gradle.xml 47 | .idea/assetWizardSettings.xml 48 | .idea/dictionaries 49 | .idea/libraries 50 | # Android Studio 3 in .gitignore file. 51 | .idea/caches 52 | .idea/modules.xml 53 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 54 | .idea/navEditor.xml 55 | 56 | # Keystore files 57 | # Uncomment the following lines if you do not want to check your keystore files in. 58 | #*.jks 59 | #*.keystore 60 | 61 | # External native build folder generated in Android Studio 2.2 and later 62 | .externalNativeBuild 63 | 64 | # Google Services (e.g. APIs or Firebase) 65 | # google-services.json 66 | 67 | # Freeline 68 | freeline.py 69 | freeline/ 70 | freeline_project_description.json 71 | 72 | # fastlane 73 | fastlane/report.xml 74 | fastlane/Preview.html 75 | fastlane/screenshots 76 | fastlane/test_output 77 | fastlane/readme.md 78 | 79 | # Version control 80 | vcs.xml 81 | 82 | # lint 83 | lint/intermediates/ 84 | lint/generated/ 85 | lint/outputs/ 86 | lint/tmp/ 87 | # lint/reports/ 88 | 89 | ### Android Patch ### 90 | gen-external-apklibs 91 | output.json 92 | 93 | # Replacement of .externalNativeBuild directories introduced 94 | # with Android Studio 3.5. 95 | .cxx/ 96 | 97 | ### Java ### 98 | # Compiled class file 99 | 100 | # Log file 101 | 102 | # BlueJ files 103 | *.ctxt 104 | 105 | # Mobile Tools for Java (J2ME) 106 | .mtj.tmp/ 107 | 108 | # Package Files # 109 | *.jar 110 | *.war 111 | *.nar 112 | *.ear 113 | *.zip 114 | *.tar.gz 115 | *.rar 116 | 117 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 118 | hs_err_pid* 119 | 120 | ### Kotlin ### 121 | # Compiled class file 122 | 123 | # Log file 124 | 125 | # BlueJ files 126 | 127 | # Mobile Tools for Java (J2ME) 128 | 129 | # Package Files # 130 | 131 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 132 | 133 | ### Gradle ### 134 | .gradle 135 | 136 | # Ignore Gradle GUI config 137 | gradle-app.setting 138 | 139 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 140 | !gradle-wrapper.jar 141 | 142 | # Cache of project 143 | .gradletasknamecache 144 | 145 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 146 | # gradle/wrapper/gradle-wrapper.properties 147 | 148 | ### Gradle Patch ### 149 | **/build/ 150 | 151 | ### AndroidStudio ### 152 | # Covers files to be ignored for android development using Android Studio. 153 | 154 | # Built application files 155 | 156 | # Files for the ART/Dalvik VM 157 | 158 | # Java class files 159 | 160 | # Generated files 161 | 162 | # Gradle files 163 | 164 | # Signing files 165 | .signing/ 166 | 167 | # Local configuration file (sdk path, etc) 168 | 169 | # Proguard folder generated by Eclipse 170 | 171 | # Log Files 172 | 173 | # Android Studio 174 | /*/build/ 175 | /*/local.properties 176 | /*/out 177 | /*/*/build 178 | /*/*/production 179 | *.ipr 180 | *~ 181 | *.swp 182 | 183 | # Android Patch 184 | 185 | # External native build folder generated in Android Studio 2.2 and later 186 | 187 | # NDK 188 | obj/ 189 | 190 | # IntelliJ IDEA 191 | *.iws 192 | /out/ 193 | 194 | # User-specific configurations 195 | .idea/caches/ 196 | .idea/libraries/ 197 | .idea/shelf/ 198 | .idea/.name 199 | .idea/compiler.xml 200 | .idea/copyright/profiles_settings.xml 201 | .idea/encodings.xml 202 | .idea/misc.xml 203 | .idea/scopes/scope_settings.xml 204 | .idea/vcs.xml 205 | .idea/jsLibraryMappings.xml 206 | .idea/datasources.xml 207 | .idea/dataSources.ids 208 | .idea/sqlDataSources.xml 209 | .idea/dynamic.xml 210 | .idea/uiDesigner.xml 211 | 212 | # OS-specific files 213 | .DS_Store 214 | .DS_Store? 215 | ._* 216 | .Spotlight-V100 217 | .Trashes 218 | ehthumbs.db 219 | Thumbs.db 220 | 221 | # Legacy Eclipse project files 222 | .classpath 223 | .project 224 | .cproject 225 | .settings/ 226 | 227 | # Mobile Tools for Java (J2ME) 228 | 229 | # Package Files # 230 | 231 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 232 | 233 | ## Plugin-specific files: 234 | 235 | # mpeltonen/sbt-idea plugin 236 | .idea_modules/ 237 | 238 | # JIRA plugin 239 | atlassian-ide-plugin.xml 240 | 241 | # Mongo Explorer plugin 242 | .idea/mongoSettings.xml 243 | 244 | # Crashlytics plugin (for Android Studio and IntelliJ) 245 | com_crashlytics_export_strings.xml 246 | crashlytics.properties 247 | crashlytics-build.properties 248 | fabric.properties 249 | 250 | ### AndroidStudio Patch ### 251 | 252 | !/gradle/wrapper/gradle-wrapper.jar 253 | 254 | # End of https://www.gitignore.io/api/java,gradle,kotlin,android,androidstudio -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | Bytehala MQTT 15 | Settings 16 | Server 17 | Port 18 | Connect 19 | 20 | New Connection 21 | + 22 | 23 | New Connection 24 | Client ID 25 | Connected to 26 | 27 | Disconnect 28 | Subscribe 29 | Publish 30 | Subscribe 31 | Disconnected from 32 | Topic 33 | History 34 | History 35 | Subscribed to 36 | org.eclipse.paho.android.service.sample.ClientConnections 37 | Unknown connection status to 38 | Connecting to 39 | Disconnecting from 40 | An error occurred connecting to 41 | 42 | Publish 43 | Message 44 | 0 45 | 1 46 | 2 47 | 48 | QOS 49 | Retained 50 | Clean Session 51 | Advanced Options 52 | Advanced 53 | Advanced 54 | User Name 55 | Password 56 | SSL 57 | Time Out 58 | Keep Alive \nTimeout 59 | 60 | Last Will Message 61 | Set Last Will Message 62 | Set Last Will Message 63 | Last Will 64 | MQTT Message Received 65 | MQTT Client Has Lost Connection 66 | 67 | Save 68 | Connection Details 69 | Enable Logging 70 | Disable Logging 71 | ClientID, server address or Port number is missing. Please correct or press back arrow cancel. 72 | 73 | dd/MM/yy \'at\' HH:mm:ss 74 | Unknown Error 75 | Delete Connection 76 | Disconnect Client? 77 | The selected client is currently connected or connecting, deleting this connection will cause it to be disconnected. 78 | Continue 79 | Cancel 80 | 81 | 82 | Received message %1$s <br/> <small>Topic: %2$s </small> 83 | <br/> <small> %1$s </small> 84 | %1$s has received %2$s on topic %3$s 85 | Published message: %1$s to topic: %2$s 86 | Subscribed to %1$s 87 | Disconnected 88 | Failed to publish message: %1$s to topic: %2$s 89 | Failed to subscribe to %1$s 90 | %1$s has lost connection to %2$s 91 | Disconnect failed.<br/> <small>Reason: %s</small> 92 | Client failed to connect.<br/> <small>Reason: %s</small> 93 | Client connected successfully 94 | 95 | 96 | broker.hivemq.com 97 | 1883 98 | Enable SSL 99 | Clean Session 100 | hello 101 | Hello World 102 | user 103 | password 104 | 60 105 | 200 106 | file:// 107 | select 108 | Send Message 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_advanced.xml: -------------------------------------------------------------------------------- 1 | 12 | 17 | 18 | 22 | 23 | 29 | 30 | 39 | 40 | 41 | 42 | 48 | 49 | 55 | 56 | 64 | 65 | 66 | 72 | 73 | 79 | 80 | 85 | 86 | 95 | 96 | 97 | 98 |