Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nesslab-reader-api

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nesslab-reader-api - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

89

nesslab_reader.js

@@ -41,2 +41,30 @@ /*

/**
* On connection error
*/
this.socket.on('error', function(res){
self.emit('error',res);
});
/**
* On connection end
*/
this.socket.on('end', function(res){
self.emit('end',res);
});
/**
* On connection timeout
*/
this.socket.on('timeout', function(res){
self.emit('timeout',res);
});
/**
* On connection is closed
*/
this.socket.on('close', function(res){
self.emit('close',res);
});
/**
* When the socket returns any data

@@ -47,4 +75,2 @@ */

var type = dataStr.substring(0,2);
console.log(dataStr);
switch(type){

@@ -58,3 +84,17 @@ case '>b':

case '>e':
self.emit('antennaState', parseInt(dataStr.substring(2)));
var number = parseInt(dataStr.substring(2));
var result = {
port1: (number & 0x0001) > 0,
port2: (number & 0x0002) > 0,
port3: (number & 0x0004) > 0,
port4: (number & 0x0008) > 0
}
if(self.activateCallback){
self.activateCallback(result);
self.activateCallback = null;
}else{
self.emit('antennaState', result);
}
break;

@@ -115,3 +155,3 @@ case '>F':

default:
var tag = dataStr.substring(2);
var tag = dataStr.substring(1);
var result = {

@@ -158,2 +198,7 @@ tag: tag.substring(2,30),

/**
* activat antenna callback
*/
nesslab_reader.prototype.activateCallback = null;
/* ---------------------------------------------------

@@ -231,2 +276,19 @@ | |

nesslab_reader.prototype.enableAntenna = function(antennaport, callback){
var self = this;
this.activateCallback = function(res){
var port1 = antennaport == 1 ? true : res.port1;
var port2 = antennaport == 2 ? true : res.port2;
var port3 = antennaport == 3 ? true : res.port3;
var port4 = antennaport == 4 ? true : res.port4;
var num = (port1 ? 1 : 0) + ((port2 ? 1 : 0) << 1) + ((port3 ? 1 : 0) << 2) + ((port4 ? 1 : 0) << 3);
var str = '>x e '+num+' \r\n';
var buf = this.nodeVersion >= 5.10 ? Buffer.from(str) : new Buffer(str);
self.socket.write(buf);
if(callback){
callback();
}
};
this.getAntennaState();
return this;

@@ -243,2 +305,19 @@ }

nesslab_reader.prototype.disableAntenna = function(antennaport, callback){
var self = this;
this.activateCallback = function(res){
var port1 = antennaport == 1 ? false : res.port1;
var port2 = antennaport == 2 ? false : res.port2;
var port3 = antennaport == 3 ? false : res.port3;
var port4 = antennaport == 4 ? false : res.port4;
var num = (port1 ? 1 : 0) + ((port2 ? 1 : 0) << 1) + ((port3 ? 1 : 0) << 2) + ((port4 ? 1 : 0) << 3);
var str = '>x e '+num+' \r\n';
var buf = this.nodeVersion >= 5.10 ? Buffer.from(str) : new Buffer(str);
self.socket.write(buf);
if(callback){
callback();
}
};
this.getAntennaState();
return this;

@@ -293,2 +372,4 @@ }

/* ---------------------------------------------------

@@ -295,0 +376,0 @@ | |

2

package.json

@@ -18,3 +18,3 @@ {

],
"version": "0.2.0",
"version": "0.2.1",
"author": {

@@ -21,0 +21,0 @@ "name": "Jayr Alencar",

@@ -5,3 +5,3 @@ var ness = require('../nesslab_reader');

ness.on('connect', function(res) {
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc