README
IoTize Device Com MQTT
Installation
Browser
Download latest version or use this link to load from jsdeliver.
<script src="https://cdn.jsdelivr.net/npm/@iotize/device-com-mqtt.js@latest/dist/iotize-device-com-mqtt.min.js" />
npm
npm install @iotize/device-com-mqtt.js
Usage
// Library name: IoTizeDeviceComMqtt
// Simple mqtt protocol
import { connect as mqttConnect, IClientOptions, MqttClient } from 'mqtt';
let mqttProtocol = IoTizeDeviceComMqtt.MqttProtocol();
// Mqtt protocol for IoTize relay
let mqttRelayProtocol = IoTizeDeviceComMqtt.createClientMQTTRelayProtocol({
connect: (brokerUrl?: string | any, options?: IClientOptions): MqttClient => {
return mqttConnect(brokerUrl, options);
},
serialNumber: 'your serial number',
netkey: 'testnetkey',
broker: {
username: 'broker username',
password: 'broker password',
url: 'ws://user.cloud.iotize.com:9001'
}
});
For more informations, read the documentation.