Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sample script, service metjod, public access
- Loading branch information
1 parent
27a491d
commit 643d42a
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Example of how to define how to send an arbitrary Mqtt message | ||
# | ||
# To see the result e.g. (your broker and channel may vary) | ||
# mosquitto_sub -v -h 'test.mosquitto.org' -t '/trains/#' | ||
# | ||
# Author: Bob Jacobsen, copyright 2020 | ||
|
||
import jmri | ||
import java | ||
import jarray | ||
from org.python.core.util import StringUtil | ||
|
||
# Find the MqttAdapter | ||
mqqtAdapter = jmri.InstanceManager.getDefault( jmri.jmrix.mqtt.MqttSystemConnectionMemo ).getMqttAdapter() | ||
|
||
|
||
# create some content | ||
topic = "jmri/test/topic" # note this will be prefixed by configured channel, i.e. "/trains/" | ||
payload = "message content" | ||
|
||
# send | ||
mqqtAdapter.publish(topic, payload) |