Modules@robinpath/mqtt

@robinpath/mqtt

0.1.1Public

MQTT client module for connecting to MQTT brokers, publishing messages, subscribing to topics, and handling incoming messages. Supports multiple concurrent client connections, QoS levels, last will messages, and message history tracking.

@robinpath/mqtt

MQTT client module for connecting to MQTT brokers, publishing messages, subscribing to topics, and handling incoming messages. Supports multiple concurrent client connections, QoS levels, last will messages, and message history tracking.

Category Functions Auth License

Why use this module?

The mqtt module lets you:

  • Publish a message to an MQTT topic
  • Subscribe to an MQTT topic
  • Unsubscribe from an MQTT topic
  • Register a message handler for incoming MQTT messages
  • Disconnect from an MQTT broker and clean up resources

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/mqtt

Quick Start

1. Set up credentials

mqtt.connect "your-credentials"

2. Publish a message to an MQTT topic

mqtt.publish

Available Functions

FunctionDescription
mqtt.connectConnect to an MQTT broker
mqtt.publishPublish a message to an MQTT topic
mqtt.subscribeSubscribe to an MQTT topic
mqtt.unsubscribeUnsubscribe from an MQTT topic
mqtt.onRegister a message handler for incoming MQTT messages
mqtt.disconnectDisconnect from an MQTT broker and clean up resources
mqtt.isConnectedCheck if an MQTT client is currently connected
mqtt.reconnectReconnect an existing MQTT client to its broker
mqtt.topicsList all topics the client is currently subscribed to
mqtt.lastMessageGet the last received message on a specific topic
mqtt.qosSet the default Quality of Service level for the client
mqtt.willSet the last will and testament message for the client

Examples

Publish a message to an MQTT topic

mqtt.publish

Subscribe to an MQTT topic

mqtt.subscribe

Unsubscribe from an MQTT topic

mqtt.unsubscribe

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/mqtt";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  mqtt.connect "your-credentials"
  mqtt.publish
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.1latestyesterday
Install
$ robinpath install @robinpath/mqtt
Version0.1.1
LicenseMIT
Unpacked Size4.9 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

web