Binary message formatter I am currently developing an IoT device with arduino and i want to minimise the data payload. First i used json which is not very efficent in fixed messages (the format will always be the same). Then i found something like messagepack which also sounds nice but i think you could do even better with just binary. I hope to find something like that:

I have a message for example:

#BOOL#INT#INT#FLOAT#BOOL#STRING#


The position of this variables never change so i could represent the message in binary and i could save a lot of bytes. Is there any library which can de/encode such formats and generate messages from given values?

If not i think it would be very useful in further IoT devices!
Passing messages across computers and/or microcontrollers with different architectures can be a real pain (endianness...). So do not fall into NIH / reinventing the wheel traps but keep standing on the shoulders of giants! Several message serialization protocols exist.


BSON
MessagePack
Protocol Buffers
CBOR (Concise Binary Object Representation)
...


Several implementations of such protocols exist (even for Arduino).

I suggest to have a look in a search engine for such protocols and add Arduino.

I've found:


BSON


ardubson

MessagePack


msgpack-mcu
arduino_msgpack
MsgPacketizer
msgpack-arduino
ArduinoJSON serializeMsgPack / deserializeMsgPack

Protocol Buffers


nanopb

CBOR


Arduino-Cbor

...


PS: You might read https://scottlocklin.wordpress.com/2017/04/02/please-stop-writing-new-serialization-protocols/
and have a look at https://xkcd.com/927/
Just choose a giant compatible with your requirements ;-)

https://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats may help