68 lines
1003 B
Julia
68 lines
1003 B
Julia
using Revise
|
|
using GeneralUtils
|
|
|
|
|
|
|
|
# text = "TODAY thought: what to do plan: wake up and going out action: 1. wake up 2. eat 3. sleep"
|
|
|
|
# sample_keywords = ["thought", "plan", "action"]
|
|
|
|
|
|
# resultdict = GeneralUtils.textToDict(text, sample_keywords; rightmarker=":", symbolkey=true)
|
|
|
|
|
|
# println(resultdict)
|
|
|
|
|
|
storedata = Channel(8)
|
|
keepalive = Channel(8)
|
|
|
|
function onMsgCallback_1(topic, payload)
|
|
jobj = JSON3.read(String(payload))
|
|
incomingMqttMsg = copy(jobj) # convert json object into julia dictionary recursively
|
|
|
|
topic = split(topic, "/")
|
|
if "keepalive" ∈ _topic
|
|
put!(keepaliveChannel, incomingMqttMsg)
|
|
elseif "testingprompt" ∈ topic
|
|
# @show incomingMqttMsg
|
|
put!(storedata, incomingMqttMsg)
|
|
else
|
|
@show "undefined condition"
|
|
end
|
|
end
|
|
|
|
mqttInstance = GeneralUtils.mqttClientInstance(
|
|
"mqtt.yiem.cc",
|
|
1883,
|
|
["/testingprompt"],
|
|
storedata,
|
|
keepalive,
|
|
onMsgCallback_1
|
|
)
|
|
|
|
|
|
_ = GeneralUtils.checkMqttConnection!(mqttInstance)
|
|
|
|
|
|
println("555")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|