The current connection state.
The active device credential once provisioned, otherwise null.
Provision (claim once, or load the stored credential) and open the auto-reconnecting MQTT-over-TLS session. Resolves once connected.
Declare (or re-declare) the device's capability set. The manifest is
validated locally, published on the current session, and re-published on
every subsequent connect. Throws a CapabilityError on an invalid
declaration.
Gracefully close the session. The state becomes closed (terminal).
Register a handler for commands addressed to one capability key.
The SDK subscribes command/# once and dispatches by key, decoding the
payload first: a settable capability's handler receives the decoded value;
a trigger capability's handler is invoked with no value.
A malformed payload or a throwing handler is reported through onError
without interrupting dispatch. Returns an unregister function.
Subscribe to transport errors. Returns an unsubscribe function.
Subscribe to inbound messages. Returns an unsubscribe function.
Subscribe to connection-state transitions. Returns an unsubscribe function.
Publish a payload to a (device-relative) topic.
A QoS 1 publish carries a msg-id user property. When the gateway answers
it with a failed PUBACK (reason code 0x80 or above), it is published again
with the same msg-id, after a capped, jittered backoff, so the gateway
stores it once.
Optionaloptions: IClientPublishOptionsPayloadTooLargeError when the payload exceeds the ceiling the gateway advertised in CONNACK (qualithm/pm#126) — caught before the bytes go on the wire, so the device is told rather than silently dropped.
Start soft-AP provisioning mode: serve the claim exchange on the device's setup network until the companion app claims the device.
Only available before a gateway session exists — never alongside one. A
successful claim persists the credential, stops the server and the setup
access point, and invokes onProvisioned; connect() then proceeds with
the stored credential. While the server is serving, the device's state is
provisioning.
Optionaloptions: Omit<ProvisioningServerOptions, "provisioningUrl" | "store">ConnectionError when a gateway session is active or the device is closed.
ProvisioningError when the device is already provisioned or the server fails to start.
Subscribe to one or more (device-relative) topic filters.
Optionaloptions: IClientSubscribeOptions
A connected Qualithm device.
Example