Connect to MQTT using the provided configuration.
MQTT configuration
Disconnect from MQTT.
Returns whether the underlying MQTT client is connected.
Registers a transport connection-status listener when the underlying adapter supports it; otherwise returns a no-op unsubscribe.
Invoked with { connected } on status changes
Unsubscribe function
Publish a message to a topic.
MQTT topic to publish to
Message payload to publish
Subscribe to a topic with a message handler.
MQTT topic to subscribe to
Callback invoked when a message is received on the topic
Unsubscribe from a topic, optionally removing a specific handler.
MQTT topic to unsubscribe from
Optionalhandler: (topic: string, payload: Buffer) => voidCallback that was used with ESPRMNeoMqtt.subscribe
StaticclearClears the singleton.
StaticgetReturns the singleton instance.
If ESPRMNeoMqtt.initialize was not called.
StatichasReturns true when ESPRMNeoMqtt.initialize has been called. Safe to call before init (does not throw).
StaticinitializeInitializes the singleton with an MQTT transport. Must be called before ESPRMNeoMqtt.getInstance.
MQTTTransport implementation to delegate to.
If already initialized. Call ESPRMNeoMqtt.clear first if you genuinely need to re-init (e.g. between test cases). A silent replacement is refused because in-flight subscriptions on the old adapter would be orphaned and messages would split between the two live transports.
Singleton
MQTTTransportthat forwards calls to the transport passed to ESPRMNeoMqtt.initialize. Use withNodeMQTTOrchestratoras in the example below.Example