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 🙏

© 2024 – Pkg Stats / Ryan Hefner

iopa-mqtt-packet

v1.3.7

Published

API-first OASIS Message Queuing Telemetry Transport (MQTT) packet transport for the Internet of Things (IoT), based on the Internet of Protocols Alliance (IOPA) specification

Downloads

50

Readme

IOPA iopa-mqtt-packet

Build Status IOPA limerun

NPM

About

iopa-mqtt-packet is an API-first OASIS Message Queuing Telemetry Transport (MQTT) packet transport for the Internet of Things (IoT), based on the Internet of Protocols Alliance (IOPA) specification

It servers MQTT messages in standard IOPA format. It is a lower level utility package that is not required directly if you are using the recommended iopa-mqtt package.

It is not intended as a standalone MQTT server/broker, as it does not contain the standard protocol logic for acknowledges, subscribes etc., but can form the basis for one. See iopa-mqtt for an open-source, standards-based, drop-in replacement for MQTT clients and brokers such as mqtt.js mosca and aedes.

iopa-mqtt-packet uses the widely used library 'mqtt-packet' for protocol formatting to assure interoperability.

Written in plain javascript for maximum portability to constrained devices

Makes MQTT messages look to an application just like an HTTP message so little or no application changes required to support multiple REST protocols

Status

Fully working prototype include server and client.

Includes:

Server/Broker Functions

  • Layered protocol based on native TCP sockets and websockets over HTTP upgrade
  • Translation from RCP Raw Message to MQTT Packet in standard IOPA format, compatible with HTTP, COAP and MQTT applications including those written for Express, Connect, etc!

Client Functions

  • Layered protocol based on native TCP sockets and websockets over HTTP upgrade
  • Translation from MQTT Packet in standard IOPA format to MQTT Raw Message

Installation

npm install iopa-mqtt-packet

Usage

Simple Hello World server with raw protocol (use iopa-mqtt for simplified version)

const iopa = require('iopa')
    , mqtt = require('iopa-mqtt-packet')      
    , tcp = require('iopa-tcp')
  
var app = new iopa.App();
app.use(mqtt);

var sessionContextDemo;

app.use(function(context, next){
   if (["CONNACK", "PINGRESP"].indexOf(context.response["iopa.Method"]) >=0)
     context.response["iopa.Body"].end();

    
  if (["SUBACK"].indexOf(context.response["iopa.Method"]) >=0)
    {
       context.response["mqtt.Granted"] =[0,1,2,128];
       context.response["iopa.Body"].write("");
    }
    
   if (["CONNECT"].indexOf(context["iopa.Method"]) >=0)
        sessionContextDemo = context["server.ParentContext"];
       return next();

});
                  
var server = tcp.createServer(app.build());

if (!process.env.PORT)
  process.env.PORT = 1883;

var mqttClient;

server.listen(process.env.PORT, process.env.IP)
  .then(function(){
    return server.connect("mqtt://127.0.0.1");
  })
  .then(function(cl){
     mqttClient = cl;
     return mqttClient.send("/", "CONNECT");   
  }).then(function(response){
         return mqttClient.send("/projector", "SUBSCRIBE");
        })
  .then(function(response){
        sessionContextDemo.send("/projector", "PUBLISH", new Buffer('Hello World'));
       setTimeout(function(){
         server.close()}, 2000);
    })

Roadmap

Adding additional features of the protocol such as QOS1 and QOS2, is as simple as adding a new middleware function