Skip to content

Mqtt protocol v5 definition (rebased onto 0.29 + per-message properties) - #87

Open
danielmeza wants to merge 3 commits into
esp-rs:masterfrom
danielmeza:feat/mqtt5-client5
Open

Mqtt protocol v5 definition (rebased onto 0.29 + per-message properties)#87
danielmeza wants to merge 3 commits into
esp-rs:masterfrom
danielmeza:feat/mqtt5-client5

Conversation

@danielmeza

@danielmeza danielmeza commented Aug 16, 2026

Copy link
Copy Markdown

Rebase of #84 (mqtt-protocol-v5) onto the current master (0.29.0).

Changes

  • Rebased the three original commits (Add MQTT 5.0 protocol support with client5 module, Add Default impls and make property configs optional in MQTT v5, Refactor user properties API for MQTT v5) onto upstream master.
  • Resolved the Cargo.toml conflict by keeping the current dependency versions (heapless 0.9, embedded-io 0.7) — the old defmt-03 feature flags were dropped in favor of the current defmt feature.
  • Keeps the mqtt_protocol_v5 feature flag; adds the client5 module with MQTT v5 client traits (Client, Publish, Subscribe, Unsubscribe, Enqueue, property configs, UserPropertyItem/UserPropertyList).

Design drivers (from the original PR)

  • Clients should be able to coexist since a device could be connected to different servers with different versions.
  • Protocols should be able to be fixed or augmented without affecting each other (regardless IDF uses the same base API for both).

How the traits map onto the MQTT 5.0 specification

References are to MQTT Version 5.0, OASIS Standard, 07 March 2019; each link is a section anchor in that published HTML.

Trait / type Specification section
PublishPropertyConfig §3.3.2.3 PUBLISH Properties
SubscribePropertyConfig §3.8.2.1 SUBSCRIBE Properties
UnsubscribePropertyConfig §3.10.2.1 UNSUBSCRIBE Properties
UserPropertyItem / UserPropertyList §3.3.2.3.7 (PUBLISH), §3.8.2.1.3 (SUBSCRIBE), §3.10.2.1.2 (UNSUBSCRIBE)

The property configs are arguments of the publish/subscribe/unsubscribe methods rather than client construction parameters because MQTT 5.0 places them in the Variable Header of each packet. UserPropertyList is a list rather than a map because §3.3.2.3.7 states "The User Property is allowed to appear multiple times to represent multiple name, value pairs. The same name is allowed to appear more than once." Connection-scoped properties (§3.1.2.11 CONNECT Properties) stay on the client configuration, where they belong.

Part of #83 and esp-rs/esp-idf-svc#589.

Testing

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.
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.
danielmeza added a commit to danielmeza/esp-idf-svc that referenced this pull request Aug 16, 2026
Cargo validates `dep/feature` references in the manifest even when the
feature is not activated, so naming `embedded-svc/mqtt_protocol_v5` fails
resolution against the published embedded-svc 0.29.0 regardless of gating.
Add embedded-svc to the existing sibling-crate patch table, the same way
esp-idf-sys and esp-idf-hal are already handled, so the crate resolves once
esp-rs/embedded-svc#87 lands on master.
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