kamilfb / mqtt-spy

Please use the new Eclipse Paho GitHub repo instead.
https://github.com/eclipse/paho.mqtt-spy/wiki
346 stars 68 forks source link

possible extension to Wiki #123

Closed MarthaZeppelin closed 6 years ago

MarthaZeppelin commented 6 years ago

Hi, there's an example on how to publish binary data on https://github.com/kamilfb/mqtt-spy/blob/development/mqtt-spy/src/test/resources/scripts/publish_image.js. Another way of having binary data would be in the form of a base64-encoded string. I managed (with the help of a friend) to solve this: `function publish() { var bytes = decodeBase64("CgAAAA0ADAHhhA==") mqttspy.publish("ASTRA/snd/189", bytes, 2, true); return true; }

publish();

function decodeBase64(encodedString) {
try { var base64Class = Java.type("java.util.Base64"); var decoder = base64Class.getDecoder() return decoder.decode(encodedString) } catch(exception) { return "Fehler: " + exception; } } ` Maybe there are more convinient ways to do it. An example within the wiki would be helpful. Thanks.

MarthaZeppelin commented 6 years ago

mived to eclipse/paho.mqtt-spy