Yep. What is the actual payload you wanted to send? MQTT doesn’t understand array payloads, you would need to represent it in some way your subscriber(s) understand. JSON perhaps? Or you just want a naked 6-byte pattern?
Naked 6-byte pattern I think.
Ok look, I want to publish it like this (displayed with MQTT.fx):
For Example I can achieve this with the following: /bin/sh -c "echo -en \"\xC0\x69\x02\x52\x9C\x65\" | mosquitto_pub -h 192.168.1.100 -t hbb33/config/nibe/read -s"
I really don’t know; it seems a bit of a hack changing the whole system for one application.
Maybe there’s a way to load just one string in a particular character set.
var testinput = '\u00C0\u0069\u0002\u0052\u009C\u0065'
val mqttActions = getActions("mqtt", "mqtt:broker:323e452a3a")
mqttActions.publishMQTT("debug/nibe",testinput )
Is there a function like the Java String using a specified charset that work in a dsl script? String(byte[] bytes, Charset charset) with Charset.forName("ISO-8859-1")
Thanks for your patience, but it doesn’t seem to work that way
var testinput = '\u00C0\u0069\u0002\u0052\u009C\u0065'
val byte[] iso88591bytes = testinput.getBytes(java.nio.charset.Charset.forName("ISO-8859-1"))
for ( byte b : iso88591bytes )
logInfo('',String.format("%x", b))
val str = new String ( iso88591bytes, java.nio.charset.Charset.forName("ISO-8859-1"))
logInfo('',str)
val mqttActions = getActions("mqtt", "mqtt:broker:323e452a3a")
mqttActions.publishMQTT("debug/nibe",str )
encoding work fine, in the logfile I see this output:
That’s a shame, but not too surprising, depending on internal string handling.
The Serial binding has an extra bit of magic to deal with this, the binary parameter.
As binary messages are perfectly legit in MQTT I think it might be worth logging a github enhancement request for MQTT binding for some similar feature.