Skip to content

JS Mqtt - PR #2 Data model and packet logging#695

Open
bretambrose wants to merge 15 commits into
JsMqtt-1-Preliminariesfrom
JsMqtt-2-Model
Open

JS Mqtt - PR #2 Data model and packet logging#695
bretambrose wants to merge 15 commits into
JsMqtt-1-Preliminariesfrom
JsMqtt-2-Model

Conversation

@bretambrose
Copy link
Copy Markdown
Contributor

@bretambrose bretambrose commented Mar 3, 2026

Additional packet definitions and helper functions for the internal JS MQTT client. Beyond what we currently expose in mqtt5_packet, we add two additional models:

  1. An internal model that extends the public model of mqtt5_packet with fields we don't want to publicly expose (packet id, clean start, etc...), We decode into this model.
  2. A binary model (bytes or numbers only) for all operations, internal and external. We do this to ensure we only pay the binary conversion cost of strings to bytes once. This is the model we encode and write to the socket.

Also includes logging related functionality:

  1. Additional helper functions for function-based logging that require a log level check pass before generating the log string
  2. Helper functions for logging object properties to support packet logging

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bretambrose bretambrose changed the title Data model and packet logging JS Mqtt - PR #2 Data model and packet logging Mar 3, 2026
@bretambrose bretambrose marked this pull request as ready for review March 23, 2026 16:08
Comment thread lib/common/io.ts
Comment thread lib/browser/mqtt_internal/model.ts
export const CONNECT_FLAGS_HAS_WILL : number = 0x04;
export const CONNECT_FLAGS_QOS_SHIFT : number = 0x03;
export const CONNECT_FLAGS_WILL_RETAIN : number = 0x20;
export const CONNECT_FLAGS_CLEAN_SESSION : number = 0x02;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just griping to the void (you) that MQTT5 spec names this flag Clean Start and MQTT3.1.1 names it Clean Session

Comment thread lib/browser/mqtt_internal/model.ts
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.

3 participants