Hello,
I have a topic that publishes data in CBOR format. I installed the CBOR block so that I can convert data from CBOR to JSON.
When I try to show the converted message in the debug panel, I always get an empty message.
Where am I going wrong?
I don't know if anyone here has any experience of the CBOR node, so I doubt you'll get a direct answer.
But we can help you try to figure it out.
I assume you mean node-red-contrib-cbor - it is barely complete node, with no help text.
Looking at its code, I can see it will only decode msg.payload if it's a Buffer type object. So the question what is the MQTT node passing it. You can configure the MQTT node to always send a Buffer type object - I suggest you do that it you haven't already. It's always worth adding a Debug node so you can check exactly what you are passing into the CBOR node.
I already have the MQTT block passing a buffer. Also, using a debug node I can see that the output of the mqtt block is an array of cbor-encoded data.
What I expect as an output of the CBOR node is data in JSON format but all I get is an empty payload.
Also there are some limit on object size on the underlying library - https://www.npmjs.com/package/cbor - so how big is the object you are trying to decode ?
The CBOR block works fine. My problem is probably due to the fact that CBOR encoded data in input to the block were not encoded from a JSON but from an array of data.
I will probably have to change the block so that it can decode data that is not in JSON format.
Thanks!