ludocode / mpack

MPack - A C encoder/decoder for the MessagePack serialization format / msgpack.org[C]
MIT License
521 stars 82 forks source link

How to use the protocol on both client side and server side #82

Closed ahmedwahdan closed 2 years ago

ahmedwahdan commented 3 years ago

Hello,

I want to use a serialization protocol between embedded device communicating through MQTT with an NodeJs broker. First thing: I don't know how to define the msg structure to be packed/unpacked. Second thing: How to use the same protocol/structure on server side?

Regards,

ludocode commented 2 years ago

Sorry, I'm not sure if I can offer much help integrating this with MQTT. Assuming your device has malloc(), probably your best bet is to use the growable writer and the dynamic node reader. Both of these will handle all allocations automatically and work with plain byte arrays that you can send to and receive from the broker. As for the message structure, that's up to you. The benefit of MessagePack is it's schemaless so you can define it ad hoc in code. I hope this helps.