Welcome to mqtt-tiny
🎉
mqtt-tiny
is a tiny MQTT 3.1.1 codec
implementation. It is limited to packet en-/decoding, and does not handle state or transport-level stuff.
use mqtt_tiny::packets::connect::MqttConnect;
// Create a simple connect packet
const CLIENT_ID: &str = "mqtttinyreadmeexample";
let connect = MqttConnect::new(
30, //keep_alive_secs: u16,
true, //clean_session: bool,
CLIENT_ID, //client_id: impl ToString,
);
// Serialize the connect packet
let connect_bytes = connect.write(Vec::new()).unwrap();
assert_eq!(connect_bytes.len(), 35);
To run the provided example, just set the MQTT_ADDRESS
, MQTT_USERNAME
and MQTT_PASSWORD
environment variables
respectively to connect to your server.