High-performance MQTT packet encoder and decoder.
Supports MQTT 3.1, 3.1.1, and 5.0 protocols with all 15 packet types.
Encoding
packet = %{type: :publish, topic: "test", payload: "hello", qos: 0, retain: false}
{:ok, binary} = MqttX.Packet.Codec.encode(4, packet)Decoding
{:ok, {packet, rest}} = MqttX.Packet.Codec.decode(4, binary)
Summary
Functions
Decode an MQTT packet from binary data.
Encode an MQTT packet to binary.
Encode an MQTT packet to iodata (more efficient, avoids binary copy).
Functions
Decode an MQTT packet from binary data.
Returns {:ok, {packet, rest}} on success, {:error, reason} on failure,
or {:error, :incomplete} if more data is needed.
Encode an MQTT packet to binary.
Returns {:ok, binary} on success or {:error, reason} on failure.
Encode an MQTT packet to iodata (more efficient, avoids binary copy).