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.
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.