I'm not sure if this is the best place to ask this question, but I'm unable to find an active forum to ask about MQTT-SPY. I tried posting in mosquito forum, but got no reply. I would like to extract two bytes of data from a binary MQTT topic and graph the data as an integer. I've tried various solutions to create a formatter or a value expression for the Payload data in the graphing tool. I cannot find documentation for how to create either a formatter or and expression.
With the "help" of ChatGPT I've tried variations of
function format()
{
byte[] binaryData = receivedMessage.getPayload();
int lastTwoBytesAsInt = ByteBuffer.wrap(binaryData, binaryData.length-2, 2).getShort();
return Integer.toString(lastTwoBytesAsInt);
}
for a formatter or
$.readShort(payload.length - 2)
for a graph value expression.
Is it possible to do what I'm trying to do? If so, how? Perhaps there is another toolset that can easily do this instead of mqtt-spy?