test mqtt
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-10-21 02:20:38 +02:00
parent 96179d3225
commit 3b9cbe5ef2
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -36,6 +36,7 @@ fun Application.module(testing: Boolean = false) {
connOpts.password = appConfig.property("ktor.mq.password").getString().toCharArray() connOpts.password = appConfig.property("ktor.mq.password").getString().toCharArray()
mqttClient.connect(connOpts) mqttClient.connect(connOpts)
message.qos = 0 message.qos = 0
mqttClient.publish("benchmark/startup", message)
} }
environment.monitor.subscribe(ApplicationStopped){ environment.monitor.subscribe(ApplicationStopped){
@ -52,6 +53,7 @@ fun Application.module(testing: Boolean = false) {
when (part) { when (part) {
is PartData.FormItem -> { is PartData.FormItem -> {
if (part.name == "description") { if (part.name == "description") {
println("Sending MQTT Message")
val msgObj: MessageObject = gson.fromJson(part.value,MessageObject::class.java) val msgObj: MessageObject = gson.fromJson(part.value,MessageObject::class.java)
mqttClient.publish("command/${msgObj.device_id}", message) mqttClient.publish("command/${msgObj.device_id}", message)
} }