0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Julia: MQTT の Publish

Posted at

プログラム

publish.jl
#! /snap/bin/julia

# --------------------------------------------------------------------
import Pkg
# Pkg.add(url="https://github.com/denglerchr/Mosquitto.jl")
# Pkg.add("JSON")
using JSON
using Mosquitto

println(stderr,"*** 開始 ***")
client = Client("example.com", 1883)

for it =0 : 7
	unit_aa = Dict()
	unit_aa["ledno"] = it
	unit_aa["status"] = true
	json_str = JSON.json(unit_aa)
	publish(client, "M5Stack", json_str)
	sleep(2.0)
	unit_aa["status"] = false
	json_str = JSON.json(unit_aa)
	publish(client, "M5Stack", json_str)
end

disconnect(client)


println(stderr,"*** 終了 ***")
# --------------------------------------------------------------------

実行結果

$ ./publish.jl 
*** 開始 ***
Single thread, loop will be blocking, start it manually using loop_start(::Client) or call loop(client) regularly.
*** 終了 ***
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?