Compare commits
3 commits
77136476e2
...
abfc172642
| Author | SHA1 | Date | |
|---|---|---|---|
|
abfc172642 |
|||
|
3d2573f8aa |
|||
|
9e3a1c35db |
4 changed files with 23 additions and 14 deletions
|
|
@ -10,10 +10,9 @@ val keystoreProperties = Properties ()
|
||||||
keystoreProperties . load ( FileInputStream ( rootProject . file ("keystore.properties") ) )
|
keystoreProperties . load ( FileInputStream ( rootProject . file ("keystore.properties") ) )
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id ("com.android.application") . version ("8.13.1")
|
id ("com.android.application") . version ("9.0.0")
|
||||||
id ("org.jetbrains.kotlin.android") . version ("2.2.21")
|
id ("org.jetbrains.kotlin.plugin.compose") . version ("2.3.0")
|
||||||
id ("org.jetbrains.kotlin.plugin.compose") . version ("2.2.21")
|
id ("org.jetbrains.kotlin.plugin.serialization") . version ("2.3.0")
|
||||||
id ("org.jetbrains.kotlin.plugin.serialization") . version ("2.2.21")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
@ -49,7 +48,7 @@ android {
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
// Required even though we don't have any Java sources because it needs to match Kotlin's JVM version
|
// Required even though we don't have any Java sources because it needs to match Kotlin's JVM version
|
||||||
targetCompatibility = JavaVersion . VERSION_23
|
targetCompatibility = JavaVersion . VERSION_25
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
|
|
@ -58,22 +57,22 @@ android {
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
jvmTarget = JvmTarget . JVM_23
|
jvmTarget = JvmTarget . JVM_25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Android runtime libraries
|
// Android runtime libraries
|
||||||
implementation ( "com.google.android.material:material:1.13.0" )
|
implementation ( "com.google.android.material:material:1.13.0" )
|
||||||
implementation ( "androidx.activity:activity-compose:1.12.1" )
|
implementation ( "androidx.activity:activity-compose:1.12.2" )
|
||||||
implementation ( "androidx.core:core-ktx:1.17.0" )
|
implementation ( "androidx.core:core-ktx:1.17.0" )
|
||||||
implementation ( "androidx.compose.material3:material3:1.4.0" )
|
implementation ( "androidx.compose.material3:material3:1.4.0" )
|
||||||
implementation ( "androidx.compose.ui:ui:1.10.0" )
|
implementation ( "androidx.compose.ui:ui:1.10.1" )
|
||||||
implementation ( "androidx.compose.ui:ui-graphics:1.10.0" )
|
implementation ( "androidx.compose.ui:ui-graphics:1.10.1" )
|
||||||
debugImplementation ( "androidx.compose.ui:ui-tooling:1.10.0" )
|
debugImplementation ( "androidx.compose.ui:ui-tooling:1.10.1" )
|
||||||
implementation ( "androidx.lifecycle:lifecycle-runtime-ktx:2.10.0" )
|
implementation ( "androidx.lifecycle:lifecycle-runtime-ktx:2.10.0" )
|
||||||
implementation ( "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2" )
|
implementation ( "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2" )
|
||||||
implementation ( "org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0" )
|
implementation ( "org.jetbrains.kotlinx:kotlinx-serialization-json:1.10.0" )
|
||||||
// Other libraries
|
// Other libraries
|
||||||
implementation ( "io.github.davidepianca98:kmqtt-common:1.0.0" )
|
implementation ( "io.github.davidepianca98:kmqtt-common:1.0.0" )
|
||||||
implementation ( "io.github.davidepianca98:kmqtt-client:1.0.0" )
|
implementation ( "io.github.davidepianca98:kmqtt-client:1.0.0" )
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.kernelmaft.zanbur.common
|
||||||
|
|
||||||
|
|
||||||
object Config {
|
object Config {
|
||||||
const val MQTT_SERVER_HOST = "deorwine.kernelmaft.com"
|
const val MQTT_SERVER_HOST = "merovech.kernelmaft.com"
|
||||||
const val MQTT_SERVER_PORT = 1883
|
const val MQTT_SERVER_PORT = 1883
|
||||||
const val MQTT_TOPIC = "zigbee2mqtt"
|
const val MQTT_TOPIC = "zigbee2mqtt"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.kernelmaft.zanbur.network
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
val exceptionPrinter = CoroutineExceptionHandler { _ , throwable ->
|
||||||
|
throwable . printStackTrace ()
|
||||||
|
throw throwable
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ object MqttClient {
|
||||||
this . coroutineScope = coroutineScope
|
this . coroutineScope = coroutineScope
|
||||||
val json = Json { ignoreUnknownKeys = true }
|
val json = Json { ignoreUnknownKeys = true }
|
||||||
|
|
||||||
coroutineScope . launch (IO) {
|
coroutineScope . launch ( IO + exceptionPrinter ) {
|
||||||
client = MQTTClient ( MQTT5 , MQTT_SERVER_HOST , MQTT_SERVER_PORT , null ) {
|
client = MQTTClient ( MQTT5 , MQTT_SERVER_HOST , MQTT_SERVER_PORT , null ) {
|
||||||
for ( handler in publishHandlers ) handler ( it , json )
|
for ( handler in publishHandlers ) handler ( it , json )
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ object MqttClient {
|
||||||
fun addPublishHandler ( handler : MqttPublishHandler ) = publishHandlers . add (handler)
|
fun addPublishHandler ( handler : MqttPublishHandler ) = publishHandlers . add (handler)
|
||||||
|
|
||||||
fun publish ( topic : String , payload : UByteArray ) {
|
fun publish ( topic : String , payload : UByteArray ) {
|
||||||
coroutineScope !! . launch (IO) {
|
coroutineScope !! . launch ( IO + exceptionPrinter ) {
|
||||||
client !! . publish ( false , AT_MOST_ONCE , topic , payload )
|
client !! . publish ( false , AT_MOST_ONCE , topic , payload )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue