Skip to content

Conversation

danielmeza
Copy link

@danielmeza danielmeza commented Jul 30, 2025

Define MQTT v5 protocol traits and base structs. as part of #83 and esp-rs/esp-idf-svc#589

This initial implementation covers the current MQTT v5 for IDF 5.3.

Some key design drivers:

  • Clients should be able to coexist since a device could be connected to different server with different versions.
  • Protocols should be able to be fixed or augmented without affect each other (regardless IDF use the same base API for both clients)
  • Client should be able to be created and started in separated processes/time this way consumers will be able to gracefully start the client (Ex, after wifi has been connected)
  • Client should be able to disconnect and report the disconnect reason.
  • No breaking changes should be introduced in the current v3 client.
  • Migration should be easy to perform from existing v3 client, to reduce the adoption overhead/friction.
  • Client should be easy to be distingue.

By following the previous drivers I came to this initial PR, I will be glad to adapt or change these drivers as needed as well as the implementation.

Please lest follow the discussion of this in the IDF implementation PR so we can see how this abstraction is been used and have a full picture view.

Please DO NOT MERGE until we agree a proper API and complete the esp-idf-svc implementation.

Introduces a new 'mqtt_protocol_v5' feature and the src/mqtt/client5.rs module implementing MQTT 5.0 protocol traits, property configs, and error codes. Updates src/mqtt.rs and src/mqtt/client.rs to integrate v5-specific APIs and types, enabling advanced MQTT 5.0 features such as user properties, message metadata, and extended event handling.
Added Default implementations for PublishPropertyConfig, SubscribePropertyConfig, UnsubscribePropertyConfig, and DisconnectPropertyConfig. Updated Client and Publish traits (and their async variants) to accept Option<T> for property config parameters, making them optional. This improves API ergonomics and allows callers to omit property configs when not needed.
@danielmeza danielmeza changed the title Mqtt protocol v5 Mqtt protocol v5 definition Jul 30, 2025
@danielmeza danielmeza changed the title Mqtt protocol v5 definition Mqtt protocol v5 definition [DO NOT MERGE] Jul 30, 2025
Updated the Event trait and UserPropertyList trait to use Vec<UserPropertyItem> instead of Box<dyn UserPropertyList> and adjusted lifetimes for better ergonomics and type safety. This simplifies the interface for accessing user properties in MQTT v5 and improves compatibility with standard collections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant