opensts-js
v1.0.10
Published
Package to show how to use OpenSTS services to subscribe to data topics using MQTT
Downloads
123
Readme
OpenSTS Javascript MQTT Client
This package demonstrates how to connect to the OpenSTS MQTT broker, subscribe to topics, and handle messages.
Installation
npm install opensts-js
Usage
Create an .env
file with the following lines. Add your own service ID and service secret key in the .env
file.
MQTT_BROKER=example.opensts.com
MQTT_PORT=1888
MQTT_USERNAME=service_42
MQTT_SECRET_KEY=your-secret-key
Add the topics you want to subscribe to in the topics.js file.
The format for the topic you want is applications/{application_id/devices/{devices_id}
.
// Topics to subscribe are defined here
const topics = [
'applications/24/devices/34',
'applications/24/devices/42',
'applications/20/devices/42'
];
module.exports = topics;
You can execute the script using the following command
npx opensts-js topics.js