Skip to content

Instantly share code, notes, and snippets.

@dpjanes
Created January 15, 2016 16:30
Show Gist options
  • Save dpjanes/c6f599c8327e31e49c6d to your computer and use it in GitHub Desktop.
Save dpjanes/c6f599c8327e31e49c6d to your computer and use it in GitHub Desktop.
Send IOTDB things to MQTT
/*
make sure to
homestar install iotdb-transport-mqtt
homestar install iotdb-transport-iotdb
(npm install will probably work too)
Further reading on transporter
https://homestar.io/about/transporters
*/
var iotdb = require('iotdb');
// this puts all your IOTDB things into a transporter
var things = iotdb.connect();
var IOTDBTransporter = require('iotdb-transport-iotdb').Transport;
var iotdb_transporter = new IOTDBTransporter(things);
// this sets up a blank MQTT transporter
var MQTTTransporter = require('iotdb-transport-mqtt').Transport;
var mqtt_transporter = new MQTTTransporter({
host: "127.0.0.1", // my mosquitto
});
// this sends everything inside of IOTDB to the MQTT transporter
iotdb_transporter.push_to(mqtt_transporter);
// note if you're clever, you can send to Express, Firebase, &c
// at some point in the future there will be a COAP transporter
@dpjanes
Copy link
Author

dpjanes commented Jan 15, 2016

you could also do things = iotdb.things() if you're doing setup elsewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment