MqttX.Packet (MqttX v0.11.2)

Copy Markdown View Source

Public entry point for the MQTT wire codec.

A thin façade over MqttX.Packet.Codec — use this module when you have your own transport and only need packet encoding/decoding.

Example

packet = %{type: :publish, topic: "test", payload: "hello", qos: 0,
           retain: false, dup: false, properties: %{}}

{:ok, binary} = MqttX.Packet.encode(4, packet)
{:ok, {decoded, rest}} = MqttX.Packet.decode(4, binary)

Summary

Functions

Declared total size of a buffered packet. See MqttX.Packet.Codec.declared_length/1.

Decode an MQTT packet from a binary. See MqttX.Packet.Codec.decode/2.

Encode an MQTT packet map to a binary. See MqttX.Packet.Codec.encode/2.

Encode an MQTT packet map to iodata. See MqttX.Packet.Codec.encode_iodata/2.

Functions

declared_length(data)

Declared total size of a buffered packet. See MqttX.Packet.Codec.declared_length/1.

decode(version, data)

Decode an MQTT packet from a binary. See MqttX.Packet.Codec.decode/2.

encode(version, packet)

Encode an MQTT packet map to a binary. See MqttX.Packet.Codec.encode/2.

encode_iodata(version, packet)

Encode an MQTT packet map to iodata. See MqttX.Packet.Codec.encode_iodata/2.