MQTT topic: CBOR conversion

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?

Here is the nodes I'm using.

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.

Given how little code is in the node (, there's not much I can see to go wrong, assuming its using the cbor library properly.

At this point, you'd need to raise an issue against the node so its author can provide some assistance -

If it is already a buffer then I'm not sure why they need to do this
msg.payload=cb.decode(new Buffer(msg.payload)); .

Also there are some limit on object size on the underlying library - - so how big is the object you are trying to decode ?

Certainly a simple object -> cbor -> object seems to work ok. but maybe there are extra encodings in the cbor buffer you have ? see

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.