This pull request introduces several enhancements and modifications to the MQTT client implementation in src/main.rs and src/packet.rs. The key changes include adding support for MQTT subscriptions, improving packet handling, and updating connection parameters.
MQTT Subscription Support:
src/main.rs: Added support for subscribing to topics upon connection, including encoding and sending MqttSubscribe packets and handling SUBACK responses.
src/packet.rs: Introduced the MqttSubscribe struct with an encode method to facilitate subscription packet creation.
Packet Handling Enhancements:
src/main.rs: Improved packet type handling in the main loop, including decoding PUBLISH packets and differentiating between known and unknown packet types.
src/packet.rs: Enhanced the MqttPublish struct to include dup and retain flags and updated the encode method to handle these flags.
Connection Parameter Updates:
src/main.rs: Changed the MQTT broker address and client ID for better testing and added a longer keep-alive interval to maintain the connection.
This pull request introduces several enhancements and modifications to the MQTT client implementation in
src/main.rs
andsrc/packet.rs
. The key changes include adding support for MQTT subscriptions, improving packet handling, and updating connection parameters.MQTT Subscription Support:
src/main.rs
: Added support for subscribing to topics upon connection, including encoding and sendingMqttSubscribe
packets and handlingSUBACK
responses.src/packet.rs
: Introduced theMqttSubscribe
struct with anencode
method to facilitate subscription packet creation.Packet Handling Enhancements:
src/main.rs
: Improved packet type handling in the main loop, including decodingPUBLISH
packets and differentiating between known and unknown packet types.src/packet.rs
: Enhanced theMqttPublish
struct to includedup
andretain
flags and updated theencode
method to handle these flags.Connection Parameter Updates:
src/main.rs
: Changed the MQTT broker address and client ID for better testing and added a longer keep-alive interval to maintain the connection.