New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rfcontroljs

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfcontroljs - npm Package Compare versions

Comparing version 0.0.30 to 0.0.31

54

lib/protocols/switch15.js

@@ -33,14 +33,27 @@ module.exports = function(helper) {

decodePulses: function(pulses) {
var all, binary, result, unit;
var all, binary, result, state, unit, unitCode;
binary = helper.map(pulses, pulsesToBinaryMapping);
unit = 8 - helper.binaryToNumberLSBMSB(binary, 21, 23);
unitCode = helper.binaryToNumberLSBMSB(binary, 21, 23);
state = helper.binaryToBoolean(binary, 20);
all = false;
if (unit === 8) {
unit = 0;
all = true;
}
unit = ((function() {
switch (unitCode) {
case 7:
return 1;
case 6:
return 2;
case 5:
return 3;
case 3:
return 4;
default:
all = true;
state = !state;
return 0;
}
})());
return result = {
id: helper.binaryToNumber(binary, 0, 19),
unit: unit,
state: helper.binaryToBoolean(binary, 20),
state: state,
all: all

@@ -50,11 +63,24 @@ };

encodeMessage: function(message) {
var id, rfstring, state, unit;
var id, rfstring, state, unit, unitCode;
id = helper.numberToBinary(message.id, 20);
state = (message.state ? '1' : '0');
unit = helper.numberToBinaryLSBMSB(8 - message.unit, 3);
if (message.all != null) {
if (message.all === true) {
unit = helper.numberToBinaryLSBMSB(0, 3);
}
if (message.all) {
unitCode = 0;
state = !message.state;
} else {
unitCode = ((function() {
switch (message.unit) {
case 1:
return 7;
case 2:
return 6;
case 3:
return 5;
case 4:
return 3;
}
})());
state = message.state;
}
state = (state ? '1' : '0');
unit = helper.numberToBinaryLSBMSB(unitCode, 3);
rfstring = "" + id + state + unit;

@@ -61,0 +87,0 @@ rfstring = helper.map(rfstring, binaryToPulse);

@@ -28,3 +28,3 @@ module.exports = function(helper) {

pulseLengths: [300, 600, 23000],
pulseCount: 38,
pulseCount: 46,
decodePulses: function(pulses) {

@@ -34,5 +34,5 @@ var binary, result;

return result = {
id: helper.binaryToNumber(binary, 0, 7),
unit: helper.binaryToNumber(binary, 8, 15),
state: helper.binaryToBoolean(binary, 16)
id: helper.binaryToNumber(binary, 0, 11),
unit: helper.binaryToNumber(binary, 12, 19),
state: helper.binaryToBoolean(binary, 20)
};

@@ -42,3 +42,3 @@ },

var id, state, unit;
id = helper.map(helper.numberToBinary(message.id, 8), binaryToPulse);
id = helper.map(helper.numberToBinary(message.id, 12), binaryToPulse);
state = (message.state ? binaryToPulse['1'] : binaryToPulse['0']);

@@ -45,0 +45,0 @@ unit = helper.map(helper.numberToBinary(message.unit, 8), binaryToPulse);

{
"name": "rfcontroljs",
"version": "0.0.30",
"version": "0.0.31",
"description": "Protocol support for different 433mhz switches and weather stations for the RFControl Arduino library",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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