npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cmdgateway

v1.0.0

Published

--- Thu, 13 Apr. 2017 01:38 PM

Downloads

3

Readme


Thu, 13 Apr. 2017 01:38 PM

Gateway per progetto "Cantiere Smart"

si parte dall'immagine del sistema operativo in Desktop/Backup: SDCardBackupPI3_5.img

Modifica del mosquitto bridging

per collegare il broker MQTT (servizio mosquitto già presente e gia configurato per essere collegato ad aws) bisogna effettuare i seguenti passaggi:

creare la dir: /home/pi/components/PlantGlue/cloudmqtt_conf.d

dentro questa dir creare il file: cloudmqtt.conf

con il seguente contenuto:

connection cloudmqtt
address m20.cloudmqtt.com:17203
remote_username publisher
remote_password publisher
try_private false
start_type automatic
topic # both

poi modificare il file: /etc/mosquitto/mosquitto.conf

in modo tale che abbia il seguente contenuto:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence false
#persistence_location /var/lib/mosquitto/

log_dest none

include_dir /home/pi/components/PlantGlue/cloudmqtt_conf.d

listener 1883
listener 1884
protocol websockets

Software per command gateway verso attuatori telecamera.

creare la dir: /home/pi/components/CmdGateway

in questa dir creare i seguenti files:

CmdGateway.js

'use strict'

var mqtt = require('mqtt')
var net = require('net');

//var HOST = '192.168.1.3';
var HOST = process.argv[2] || 'localhost';
var PORT = process.argv[3] || 8888;

var JsonSocket = require('json-socket');
var tcpclient = new JsonSocket(new net.Socket());

var clientId = 'mqttjs_' + Math.random().toString(16).substr(2, 8)

var host = 'mqtt://m20.cloudmqtt.com'

var options = {
  port: 17203,
  keepalive: 10,
  clientId: clientId,
  protocolId: 'MQTT',
  protocolVersion: 4,
  clean: true,
  reconnectPeriod: 1000,
  connectTimeout: 30 * 1000,
  will: {
    topic: 'WillMsg',
    payload: 'Connection Closed abnormally..!',
    qos: 0,
    retain: false
  },
  username: 'publisher',
  password: 'publisher',
  rejectUnauthorized: false
}

var client = mqtt.connect(host, options)

client.on('connect', function () {
  client.subscribe('Pan')
  client.subscribe('Tilt')
  client.subscribe('Zoom')
  client.subscribe('AttA')
  client.subscribe('AttB')
  client.subscribe('AttC')
  client.subscribe('AttD')
})

client.on('message', function (topic, message) {
  // message is Buffer
  var mymessage="{\"Command\": \""+topic+"\", \"Value\": "+message.toString()+"}";  
  console.log(mymessage);
  // Write a message to the socket as soon as the client is connected, the server will
  // receive it as message from the client 
  tcpclient.sendMessage({Command: topic, Value: parseFloat(message.toString())});
})

tcpclient.connect(PORT, HOST, function() {

    console.log('CONNECTED TO: ' + HOST + ':' + PORT);
});

ServerForTest

var net = require('net');

var HOST = 'localhost';
var PORT = 8888;

net.createServer(function(sock) {

    // We have a connection - a socket object is assigned to the connection automatically
    console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.remotePort);

    // Add a 'data' event handler to this instance of socket
    sock.on('data', function(data) {

        console.log('DATA ' + sock.remoteAddress + ': ' + data);        
    });

    // Add a 'close' event handler to this instance of socket
    sock.on('close', function(data) {
        console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort);
    });

}).listen(PORT, HOST);

console.log('Server listening on ' + HOST +':'+ PORT);

package.json

{
  "name": "CmdGateway",
  "version": "1.0.0",
  "description": "",
  "main": "CmdGateway.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "mqtt": "^2.4.0",
    "net": "^1.0.2"
  }
}

Installare le librerie necessarie al CmdGateway

dare i seguenti comandi

cd /home/pi/components/CmdGateway
npm install

per provare senza l'hardware della telecamera aprire 2 terminal e far partire rispettivamente in ogni terminal nell'ordine:

node ServerForTest.js

node GmdGateway.js

Installare CmdGateway.js come servizio con partenza al Boot

sudo forever-service install CmdGateway -s /home/pi/components/CmdGateway/CmdGateway.js -o " 127.0.0.1 8888"
sudo service CmdGateway status
sudo service CmdGateway start
sudo service CmdGateway stop

(For Testing Installare ServerForTest.js come servizio con partenza al Boot

sudo forever-service install CameraEmulator -s /home/pi/components/CmdGateway/ServerForTest.js
sudo service CameraEmulator status
sudo service CameraEmulator start
sudo service CameraEmulator stop