Comparing version 0.0.1 to 0.0.2
@@ -37,6 +37,8 @@ var Board, Promise, SerialPort, assert, events, rfcontrol, serialport, | ||
this.serialPort.on("data", (function(_this) { | ||
return function(line) { | ||
var args, cmd; | ||
return function(_line) { | ||
var args, cmd, line; | ||
line = _line.replace(/\0/g, '').trim(); | ||
_this.emit("data", line); | ||
if (line === "ready") { | ||
_this.emit('ready'); | ||
return; | ||
@@ -57,3 +59,3 @@ } | ||
default: | ||
return console.log("unknown message received: " + data); | ||
return console.log("unknown message received: " + line); | ||
} | ||
@@ -64,10 +66,17 @@ }; | ||
Board.prototype.connect = function() { | ||
return this.serialPort.openAsync().then((function(_this) { | ||
Board.prototype.connect = function(timeout) { | ||
if (timeout == null) { | ||
timeout = 20000; | ||
} | ||
return this.pendingConnect = this.serialPort.openAsync().then((function(_this) { | ||
return function() { | ||
var resolver; | ||
resolver = null; | ||
return new Promise(function(resolve, reject) { | ||
return _this.serialPort.once("data", function(line) { | ||
return resolve(); | ||
}); | ||
}).timeout(3000); | ||
resolver = resolve; | ||
return _this.once("ready", resolve); | ||
}).timeout(timeout)["catch"](function(err) { | ||
_this.removeListener("ready", resolver); | ||
throw err; | ||
}); | ||
}; | ||
@@ -77,2 +86,9 @@ })(this)); | ||
Board.prototype.whenReady = function() { | ||
if (this.pendingConnect == null) { | ||
return Promise.reject(new Error("First call connect!")); | ||
} | ||
return this.pendingConnect; | ||
}; | ||
Board.prototype.digitalWrite = function(pin, value) { | ||
@@ -111,4 +127,4 @@ assert(typeof pin === "number"); | ||
return { | ||
temperature: args[0], | ||
humidity: args[1] | ||
temperature: parseFloat(args[0]), | ||
humidity: parseFloat(args[1]) | ||
}; | ||
@@ -124,8 +140,15 @@ }); | ||
Board.prototype.rfControlSend = function(pin, pulseLengths, pulses) { | ||
var i, pl, pulseLengthsArgs, _i, _len; | ||
assert(typeof pin === "numer"); | ||
assert(Array.isArray(pulseLengths)); | ||
assert(pulseLengths.length <= 8); | ||
assert(typeof pulses === "string"); | ||
Board.prototype.rfControlSendMessage = function(pin, protocolName, message) { | ||
var result; | ||
result = rfcontrol.encodeMessage(protocolName, message); | ||
return this.rfControlSendPulses(pin, result.pulseLengths, result.pulses); | ||
}; | ||
Board.prototype.rfControlSendPulses = function(pin, pulseLengths, pulses) { | ||
var i, pl, pulseLengthsArgs, repeats, _i, _len; | ||
assert(typeof pin === "number", "pin should be a number"); | ||
assert(Array.isArray(pulseLengths), "pulseLengths should be an array"); | ||
assert(pulseLengths.length <= 8, "pulseLengths.length should be <= 8"); | ||
assert(typeof pulses === "string", "pulses should be a string"); | ||
repeats = 5; | ||
pulseLengthsArgs = ""; | ||
@@ -142,3 +165,3 @@ i = 0; | ||
} | ||
return this.serialPort.writeAsync("RF send " + pin + " " + pulseLengthsArgs + " " + pulses + "\n").then(this._waitForAcknowledge); | ||
return this.serialPort.writeAsync("RF send " + pin + " " + repeats + " " + pulseLengthsArgs + " " + pulses + "\n").then(this._waitForAcknowledge); | ||
}; | ||
@@ -203,3 +226,3 @@ | ||
this.emit('rfReceive', info); | ||
results = rfcontrol.parsePulseSquence(info.pulseLengths, info.pulses); | ||
results = rfcontrol.decodePulses(info.pulseLengths, info.pulses); | ||
for (_j = 0, _len1 = results.length; _j < _len1; _j++) { | ||
@@ -206,0 +229,0 @@ r = results[_j]; |
{ | ||
"name": "homeduino", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Node.js library for interfacing with the homeduino ardunio library", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"bluebird": "~2.2.2", | ||
"rfcontroljs": "git+https://github.com/pimatic/rfcontroljs.git" | ||
"rfcontroljs": "0.0.4" | ||
}, | ||
@@ -34,0 +34,0 @@ "devDependencies": { |
@@ -13,4 +13,5 @@ homeduinojs | ||
Board = require('../index').Board | ||
board = new Board('/dev/ttyUSB0', 9600) | ||
homeduino = require('homeduino') | ||
Board = homeduino.Board | ||
board = new Board('/dev/ttyUSB0', 115200) | ||
@@ -17,0 +18,0 @@ board.connect().then( -> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
51185
213
62
0
+ Addedrfcontroljs@0.0.4(transitive)
Updatedrfcontroljs@0.0.4