symeos-mqtt

0.1.3 • Public • Published

SYMEOS MQTT

An simple MQTT based client for connecting to symeos.net

Installation:

npm install symeos-mqtt

Example:

var Symeos = require('symeos-mqtt');
var config  = require('./symeosnet.json');

// Config Example
// {
//   "uuid": "4330072e-c3a5-4adb-b4c8-b57dd5baeebd",
//   "token": "ccf22051facbbe473a782ff5553e80e34da8d14e",
//   "hostname": "symeos.net",
//   "port": "1883",
//   "qos": 0, // MQTT Quality of Service (0=no confirmation, 1=confirmation, 2=N/A)
// }

var symeos = new Symeos(config);
console.log('starting...');

symeos.connect(function(response){
  // Update Device - response emits event 'config'
  symeos.update({uuid: config.uuid, type: 'smtp'});

  // Message - response emits event 'message'
  symeos.message({
    devices: [config.uuid],
    payload: {msg: 'Hello world !'},
    qos : 0, // MQTT Quality of Service (0=no confirmation, 1=confirmation, 2=N/A)
  });

  // On message
  symeos.on('message', function(message){
    console.log('recieved message', message);
  });

  // On config
  symeos.on('config', function(config){
    console.log('recieved config', config);
  });

  // On data
  symeos.on('data', function(data){
    console.log('recieved data', data);
  });

  // Generate Session Token
  symeos.generateAndStoreToken({uuid: config.uuid}, function(error, response){
    console.log('generated token', response);
  });

  // Reset Token
  //symeos.resetToken({uuid: config.uuid}, function(error, response){
  //  console.log('reset token', response);
  //});

  // Generate new public key
  symeos.getPublicKey({uuid: config.uuid}, function(error, response){
    console.log('retrieved publicKey', response.publicKey);
  });

  // Whoami
  symeos.whoami(function(error, device){
    console.log('whoami', device);
  });

});

LICENSE

(MIT License)

Copyright (c) 2015 Symeos contact@symeos.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i symeos-mqtt

Weekly Downloads

2

Version

0.1.3

License

none

Last publish

Collaborators

  • hepr