update
This commit is contained in:
67
test/runtest.jl
Normal file
67
test/runtest.jl
Normal file
@@ -0,0 +1,67 @@
|
||||
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")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user