turtlestitch/libraries/mqtt.xml

2 wiersze
15 KiB
XML
Czysty Zwykły widok Historia

<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><palette><category name="MQTT" color="143,0,100,1"/></palette><block-definition s="$cloudOutline MQTT connect to %&apos;broker&apos; $nl $options-1-192-192-192 %&apos;options&apos;" type="command" category="MQTT"><comment x="0" y="0" w="416.6666666666666" collapsed="false">Connect to a broker&#xD;&#xD;The options are not required but can be filled if needed&#xD;&#xD;1. username (some brokers need this)&#xD;2. password (some brokers need this)&#xD;3. keepalive (default time is 60 seconds but some brokers need a shorter time)&#xD;4. connection callback (ringed set of scripts to be run when connection is made or remade)&#xD;&#xD;Note: The connection callback doesn&apos;&apos;t have to be the 4th option - it just has to be the last (or only) option.&#xD;&#xD;ADVANCED: The brokers offered in the menu are accessed using default ports and basepaths (if needed). If accessing other brokers, the complete urls should be formed like this:&#xD;&#xD;siteURL:port/basepath &#xD;e.g mqtt.eclipseprojects.io:443/mqtt&#xD;&#xD;&#xD;</comment><header></header><code></code><translations></translations><inputs><input type="%s">broker.emqx.io<options>broker.emqx.io&#xD;mqtt.eclipseprojects.io&#xD;test.mosquitto.org&#xD;broker.xmqtt.net</options></input><input type="%mult%s"></input></inputs><script><block s="doApplyExtension"><l>src_load(url)</l><list><l>libraries/mqtt.js</l></list></block><block s="doApplyExtension"><l>src_load(url)</l><list><l>libraries/mqttExtension.js</l></list></block><block s="doIf"><block s="reportNot"><block s="reportJoinWords"><block var="options"/></block></block><script><block s="doSetVar"><l>options</l><block s="reportNewList"><list></list></block></block></script></block><block s="doDeclareVariables"><list><l>connection status</l><l>callback</l></list></block><block s="doSetVar"><l>connection status</l><l>connecting</l></block><block s="doSetVar"><l>callback</l><l></l></block><block s="doIf"><block s="reportIsA"><block s="reportListItem"><l><option>last</option></l><block var="options"/></block><l><option>command</option></l></block><script><block s="doSetVar"><l>callback</l><block s="reportListItem"><l><option>last</option></l><block var="options"/></block></block><block s="doDeleteFromList"><l><option>last</option></l><block var="options"/></block></script></block><block s="doSetVar"><l>options</l><block s="reportListAttribute"><l><option>json</option></l><block s="reportNewList"><list><block s="reportNewList"><list><l>username</l><block s="reportListItem"><l>1</l><block var="options"/></block></list></block><block s="reportNewList"><list><l>password</l><block s="reportListItem"><l>2</l><block var="options"/></block></list></block><block s="reportNewList"><list><l>keepalive</l><block s="reportListItem"><l>3</l><block var="options"/></block></list></block></list></block></block></block><block s="doApplyExtension"><l>mqt_connect(broker,callback,options)</l><list><block var="broker"/><block var="callback"/><block var="options"/></list></block><block s="doWaitUntil"><block s="reportNot"><block s="reportEquals"><block var="connection status"/><l>connecting</l></block></block></block><block s="doIf"><block s="reportNot"><block s="reportEquals"><block var="connection status"/><l>connected</l></block></block><script><block s="doApplyExtension"><l>err_error(msg)</l><list><block var="connection status"/></list></block></script></block></script></block-definition><block-definition s="$cloudOutline MQTT publish to %&apos;broker&apos; topic %&apos;topic&apos; payload %&apos;payload&apos; $nl $options-1-192-192-192 %&apos;options&apos;" type="command" category="MQTT"><comment x="0" y="0" w="200" collapsed="false">Publish a message to an MQTT broker&#xD;&#xD;The options are not required but can be filled if needed&#xD;&#xD;1. qos (quality of service 0,1 or 2)&#xD;2. retain flag (boolean)&#xD;</comment><header></header><code></code><translations></translations><inputs><input type="%s">broker.emqx.io<options>broker.emqx.io&#xD;mqtt.eclipseprojects.io&#xD;test.mosquit