using Revise using GeneralUtils, MQTTClient, JSON3 mqttMsgReceiveTopic = ["/receivetopic_1", "/receivetopic_2"] mqttMsgReceiveChannel = (ch1=Channel(8), ch2=Channel(32)) keepaliveChannel = Channel(8) function onMsgCallback(topic, payload) jobj = JSON3.read(String(payload)) incomingMqttMsg = copy(jobj) # convert json object into julia dictionary recursively if occursin("topic_1", topic) put!(mqttMsgReceiveChannel[:ch1], incomingMqttMsg) elseif occursin("topic_2", topic) put!(mqttMsgReceiveChannel[:ch2], incomingMqttMsg) elseif occursin("keepalive", topic) put!(keepaliveChannel, incomingMqttMsg) else println("undefined condition ", @__FILE__, " ", @__LINE__) end end mqttInstance = GeneralUtils.mqttClientInstance_v2( "mqtt.yiem.cc", mqttMsgReceiveTopic, mqttMsgReceiveChannel, keepaliveChannel, onMsgCallback ) _ = GeneralUtils.checkMqttConnection!(mqttInstance) println("GeneralUtils test done")