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.26 to 0.0.27

lib/protocols/led2.js

2

lib/controller.js

@@ -6,3 +6,3 @@ var doesProtocolMatch, helper, protocols, sortIndices,

protocols = ['weather1', 'weather2', 'weather3', 'weather4', 'weather5', 'weather6', 'weather7', 'switch1', 'switch2', 'switch3', 'switch4', 'switch5', 'switch6', 'switch7', 'switch8', 'switch9', 'switch10', 'switch11', 'switch12', 'rolling1', 'dimmer1', 'pir1', 'pir2', 'pir3', 'contact1', 'contact2', 'generic', 'alarm1', 'led1'];
protocols = ['weather1', 'weather2', 'weather3', 'weather4', 'weather5', 'weather6', 'weather7', 'switch1', 'switch2', 'switch3', 'switch4', 'switch5', 'switch6', 'switch7', 'switch8', 'switch9', 'switch10', 'switch11', 'switch12', 'switch13', 'rolling1', 'dimmer1', 'pir1', 'pir2', 'pir3', 'pir4', 'pir5', 'contact1', 'contact2', 'generic', 'alarm1', 'led1', 'led2', 'led3'];

@@ -9,0 +9,0 @@ protocols = protocols.map((function(_this) {

@@ -140,2 +140,18 @@ var ParsingError,

return data[i] === '1';
},
createParityBit: function(stringForParity) {
var bit, parity, paritybitRef, _i, _len;
parity = 0;
for (_i = 0, _len = stringForParity.length; _i < _len; _i++) {
bit = stringForParity[_i];
if (bit === '1') {
parity++;
}
}
if (parity < 2) {
paritybitRef = parity === 1;
} else {
paritybitRef = (parity % 2) !== 0;
}
return paritybitRef;
}

@@ -142,0 +158,0 @@ };

module.exports = function(helper) {
var binaryToPulse, protocolInfo, pulsesToBinaryMapping;
pulsesToBinaryMapping = {
'10': '0',
'01': '1',
'10': '1',
'01': '0',
'02': ''
};
binaryToPulse = {
'1': '01',
'0': '10'
'0': '01',
'1': '10'
};
return protocolInfo = {
name: 'led1',
type: 'switch',
type: 'command',
values: {

@@ -19,31 +19,53 @@ id: {

},
unit: {
type: "number"
},
state: {
type: "boolean"
command: {
type: "string"
}
},
brands: ["LED Stripe RF Dimmer (no name)"],
pulseLengths: [348, 1051, 10864],
pulseLengths: [439, 1240, 12944],
pulseCount: 50,
decodePulses: function(pulses) {
var binary, result;
var binary, command, commandcode, result;
binary = helper.map(pulses, pulsesToBinaryMapping);
commandcode = binary.slice(16, 24);
switch (commandcode) {
case "00100001":
command = "on/off";
break;
case "00100100":
command = "up";
break;
case "00100010":
command = "down";
break;
default:
command = "code:" + commandcode;
}
return result = {
id: helper.binaryToNumber(binary, 0, 20),
unit: helper.binaryToNumber(binary, 21, 23),
state: true
id: helper.binaryToNumber(binary, 0, 15),
command: command
};
},
encodeMessage: function(message) {
var id, unit;
if (message.state === false) {
return "0";
var commandcode, id;
id = helper.map(helper.numberToBinary(message.id, 16), binaryToPulse);
switch (message.command) {
case "on/off":
commandcode = "00100001";
break;
case "up":
commandcode = "00100100";
break;
case "down":
commandcode = "00100010";
break;
default:
if (message.command.slice(0, 5) === "code:") {
commandcode = message.command.slice(5);
}
}
id = helper.map(helper.numberToBinary(message.id, 21), binaryToPulse);
unit = helper.map(helper.numberToBinary(message.unit, 3), binaryToPulse);
return "" + id + unit + "02";
commandcode = helper.map(commandcode, binaryToPulse);
return "" + id + commandcode + "02";
}
};
};

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

'02': '0',
'13': '',
'03': ''

@@ -28,4 +29,4 @@ };

brands: ["Europe RS-200"],
pulseLengths: [562, 1313, 3234, 52149],
pulseCount: 44,
pulseLengths: [562, 1313, 3234, 34888],
pulseCount: 52,
decodePulses: function(pulses) {

@@ -35,4 +36,4 @@ var binary, result;

return result = {
id: helper.binaryToNumber(binary, 0, 9),
unit: helper.binaryToNumber(binary, 20, 21),
id: helper.binaryToNumber(binary, 0, 13),
unit: helper.binaryToNumber(binary, 16, 17),
state: helper.binaryToBoolean(binary, 19)

@@ -42,11 +43,11 @@ };

encodeMessage: function(message) {
var id, state, state_inv, unit1, unit2;
id = helper.map(helper.numberToBinary(message.id, 10), binaryToPulse);
state = (message.state ? binaryToPulse['1'] : binaryToPulse['0']);
state_inv = (message.state ? binaryToPulse['0'] : binaryToPulse['1']);
unit2 = helper.map(helper.numberToBinary(message.unit, 2), binaryToPulse);
unit1 = helper.map(helper.numberToBinary(message.unit + 1, 2), binaryToPulse);
return "" + id + state + "1" + unit2 + "1" + state + "11" + state_inv + state + unit2 + "03";
var id, rfstring, state, state_inv, unit1;
id = helper.numberToBinary(message.id, 14);
state = (message.state ? '1' : '0');
state_inv = (message.state ? '0' : '1');
unit1 = helper.numberToBinary(message.unit, 2);
rfstring = helper.map("" + id + state + "1" + unit1 + "1" + state + "11" + state_inv + state + "0", binaryToPulse);
return "" + rfstring + "03";
}
};
};
{
"name": "rfcontroljs",
"version": "0.0.26",
"version": "0.0.27",
"description": "Protocol support for different 433mhz switches and weather stations for the RFControl Arduino library",

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

@@ -76,2 +76,19 @@ // Generated by CoffeeScript 1.8.0

}, {
protocol: 'pir4',
pulseLengths: [268, 1282, 2632, 10168],
pulses: ['0200010001010001000001000100010100010000010100010001000100010000010100000100010001010001000001010001000001000101000100000100010100000101000001000103', '020001000101000100000100010001010001000001010001000100010001000001010000010001000101000100000101000100000100010001010000010001010003'],
values: [
{
id: 13040182,
all: false,
presence: true,
unit: 9
}, {
id: 13040182,
all: false,
presence: false,
unit: 9
}
]
}, {
protocol: 'weather1',

@@ -78,0 +95,0 @@ pulseLengths: [456, 1990, 3940, 9236],

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