{"id":13607902,"url":"https://github.com/adonmo/killerbee","last_synced_at":"2025-07-14T04:33:15.274Z","repository":{"id":126204236,"uuid":"370022783","full_name":"adonmo/killerbee","owner":"adonmo","description":"MQTT android client","archived":false,"fork":false,"pushed_at":"2024-10-18T07:16:34.000Z","size":210,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-07T13:38:08.718Z","etag":null,"topics":["android","gradle","iot","java","kotlin","mqtt","mqtt-android-client","paho"],"latest_commit_sha":null,"homepage":"https://medium.com/adonmo-tech/killer-bee-3d88ef82d1de","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adonmo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-05-23T10:30:29.000Z","updated_at":"2024-10-18T07:16:38.000Z","dependencies_parsed_at":"2024-01-16T23:30:42.717Z","dependency_job_id":"893b018d-03bd-4ecd-ac6f-1228e4d571ec","html_url":"https://github.com/adonmo/killerbee","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonmo%2Fkillerbee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonmo%2Fkillerbee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonmo%2Fkillerbee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adonmo%2Fkillerbee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adonmo","download_url":"https://codeload.github.com/adonmo/killerbee/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225950709,"owners_count":17550311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","gradle","iot","java","kotlin","mqtt","mqtt-android-client","paho"],"created_at":"2024-08-01T19:01:22.657Z","updated_at":"2024-11-22T19:17:38.788Z","avatar_url":"https://github.com/adonmo.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# killerbee\nMQTT android client\n\nFor comparison with [Paho Client](https://github.com/eclipse/paho.mqtt.android) check the blog on [Killer Bee vs Paho](https://medium.com/adonmo-tech/killer-bee-3d88ef82d1de).\n\n## Adding as a Dependency\nThis package is currently hosted as a github package. Github currently supports public package hosting but requires github personal access token to fetch them.\nIn short you need to have a github account to use this as a dependency.\n\n### Setting up github credentials\n* [Generate an github personal access token with repo actions and read:packages access](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) \n* Create a file `github.properties` in project root. \n* Add `github.properties` filename to `.gitgnore` to avoid adding it to version control.\n* Add the github values to the `github.properties` file\n```bash\nGITHUB_USER=\nGITHUB_PERSONAL_ACCESS_TOKEN=\n```\n\n### Add maven repository for github package\n\nAdd the maven repo for `KillerBee` as shown below in `build.gradle` of the project root.\n```groovy\ndef githubProperties = new Properties()\ngithubProperties.load(new FileInputStream(rootProject.file(\"github.properties\")))\n\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n        //Use for local testing of library after assemble and publishToMavenLocal\n        //mavenLocal()\n\n        maven {\n            name = \"KillerBee\"\n            url = uri(\"https://maven.pkg.github.com/adonmo/killerbee\")\n            credentials {\n                username = githubProperties['GITHUB_USER']\n                password = githubProperties['GITHUB_PERSONAL_ACCESS_TOKEN']\n            }\n        }\n    }\n}\n```\n### Add dependency to build.gradle in app folder\n```groovy\nimplementation 'com.adonmo.libraries:killerbee:1.0.1'\n```\n\n## Sample Implementation\n```java\npackage com.adonmo.sample.killerbee\n\nimport android.os.Bundle\nimport android.os.Handler\nimport android.os.HandlerThread\nimport android.util.Log\nimport androidx.appcompat.app.AppCompatActivity\nimport com.adonmo.killerbee.AndroidMQTTClient\nimport com.adonmo.killerbee.IMQTTConnectionCallback\nimport com.adonmo.killerbee.action.MQTTActionStatus\nimport com.adonmo.killerbee.adapter.ConnectOptions\nimport com.adonmo.killerbee.helper.Constants.LOG_TAG\nimport java.util.concurrent.ScheduledThreadPoolExecutor\n\nclass MainActivity : AppCompatActivity(), IMQTTConnectionCallback {\n    private lateinit var mqttThread: HandlerThread\n    private lateinit var mqttHandler: Handler\n\n    private lateinit var mqttClient: AndroidMQTTClient\n    private lateinit var executor: ScheduledThreadPoolExecutor\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        Log.v(LOG_TAG, \"Running on thread [${Thread.currentThread()}]\")\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n        mqttThread = HandlerThread(\"mqttThread\")\n        mqttThread.start()\n        mqttHandler = Handler(mqttThread.looper)\n\n        /* As it stands a minimum of 4 threads seems to be necessary to let the MQTT client run\n            as it blocks a few of them(3 based on testing) with a looper  most likely */\n        executor = ScheduledThreadPoolExecutor(4)\n        mqttClient = AndroidMQTTClient(\n            ConnectOptions(\n                clientID = \"OG\",\n                serverURI = \"tcp://broker.hivemq.com:1883\",\n                cleanSession = true,\n                keepAliveInterval = 30,\n                maxReconnectDelay = 60000,\n                automaticReconnect = true,\n            ),\n            mqttHandler,\n            this,\n            executorService = executor\n        )\n        mqttClient.connect()\n    }\n\n    override fun connectActionFinished(\n        status: MQTTActionStatus,\n        connectOptions: ConnectOptions,\n        throwable: Throwable?\n    ) {\n        if (status == MQTTActionStatus.SUCCESS) {\n            mqttClient.subscribe(\"Jello\", 1)\n            mqttClient.subscribe(arrayOf(\"HelloBee\", \"BeeHello\"), intArrayOf(1, 0))\n        } else {\n            Log.e(\n                LOG_TAG,\n                \"Connection Action Failed for [${connectOptions.clientID}] to [${connectOptions.serverURI}]\"\n            )\n        }\n    }\n\n    override fun disconnectActionFinished(status: MQTTActionStatus, throwable: Throwable?) {\n        Log.d(LOG_TAG, \"Disconnect Action Status: [$status]\")\n    }\n\n    override fun publishActionFinished(\n        status: MQTTActionStatus,\n        messagePayload: ByteArray,\n        throwable: Throwable?\n    ) {\n        if (status == MQTTActionStatus.SUCCESS) {\n            Log.d(LOG_TAG, \"Published message $messagePayload\")\n        }\n    }\n\n    override fun subscribeActionFinished(\n        status: MQTTActionStatus,\n        topic: String,\n        throwable: Throwable?\n    ) {\n        if (status == MQTTActionStatus.SUCCESS) {\n            mqttClient.publish(\"HelloBee\", \"World\".toByteArray(), 1, false)\n        }\n    }\n\n    override fun subscribeMultipleActionFinished(\n        status: MQTTActionStatus,\n        topics: Array\u003cString\u003e,\n        throwable: Throwable?\n    ) {\n        if (status == MQTTActionStatus.SUCCESS) {\n            mqttClient.publish(\"HelloBee\", \"World\".toByteArray(), 1, false)\n        }\n    }\n\n    override fun connectionLost(connectOptions: ConnectOptions, throwable: Throwable?) {\n        Log.d(\n            LOG_TAG,\n            \"Connection lost for [${connectOptions.clientID}] from [${connectOptions.serverURI}]\"\n        )\n    }\n\n    override fun messageArrived(\n        topic: String?,\n        message: ByteArray?\n    ) {\n        message?.let {\n            Log.d(LOG_TAG, \"Received message [$message]\")\n        }\n        //mqttClient.disconnect()\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadonmo%2Fkillerbee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadonmo%2Fkillerbee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadonmo%2Fkillerbee/lists"}