You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

wifli

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wifli - npm Package Compare versions

Comparing version
0.3.1
to
0.4.0
+24
examples/lifecycle.js
'use strict';
var WiFli = require('../index')
, MockConnection = require('../lib/mock-connection')
;
var kopter = new WiFli();
// replace this with a real connect() call to send to real copter
kopter.connection = new MockConnection();
kopter.once('launch', function () {
kopter.runQueue(function (q) {
q.on('end', function () { kopter.land(); });
q.enqueue({hover : true}, 1000);
q.enqueue({hover : true, trim : -8}, 500);
q.enqueue({hover : true, trim : 8}, 1000);
});
});
kopter.once('land', function () { kopter.end(); });
kopter.once('end', function () { console.log("all done!"); });
kopter.launch();
'use strict';
function MockConnection() {
}
MockConnection.prototype.write = function (buffer) {
console.dir(buffer);
};
MockConnection.prototype.end = function () {
console.log('connection shut down');
};
module.exports = MockConnection;
+3
-11
'use strict';
var WiFli = require('../index');
var WiFli = require('../index')
, MockConnection = require('../lib/mock-connection')
;
function MockConnection() {
}
MockConnection.prototype.write = function (buffer) {
console.dir(buffer);
};
MockConnection.prototype.end = function () {
console.log('connection shut down');
};
var kopter = new WiFli();

@@ -17,0 +9,0 @@ // replace this with a real connect() call to send to real copter

@@ -14,4 +14,5 @@ 'use strict';

*/
var HELIADDRESS = '192.168.11.123'
, HELIPORT = 2000
var HELIADDRESS = '192.168.11.123'
, HELIPORT = 2000
, HOVER_SPEED = 30 // FIXME: SWAG
;

@@ -32,6 +33,9 @@

function WiFli () {
function WiFli (options) {
EventEmitter.call(this);
this.writable = true;
if (!options) options = {};
this.hoverSpeed = options.hoverSpeed || HOVER_SPEED;
// make it easy to stream commands to copter

@@ -87,5 +91,13 @@ this.on('data', function (command) {

if (command.reset) {
this.sendReset();
return true;
return this.sendReset();
}
else if (command.hover) {
return this.hover(command);
}
else if (command.launch) {
return this.launch();
}
else if (command.land) {
return this.land();
}
else {

@@ -116,6 +128,43 @@ var b = new Command(command).toBuffer();

WiFli.prototype.sendReset = function () {
this.sendCommand();
var status = this.sendCommand();
this.emit('reset');
return status;
};
WiFli.prototype.hover = function (command) {
if (command) {
delete command.hover;
}
else {
command = {};
}
command.rotorSpeed = this.hoverSpeed;
this.sendCommand(command);
this.emit('hover');
};
WiFli.prototype.launch = function () {
var self = this;
var launchSpeed = Math.floor(this.hoverSpeed * 1.1);
this.runQueue(function (q) {
q.once('end', function () { self.emit('launch'); });
q.enqueue({rotorSpeed : launchSpeed}, 1000);
q.enqueue({hover : true}, 0);
});
};
WiFli.prototype.land = function () {
var self = this;
Math.floor(self.hoverSpeed * 1.1);
this.runQueue(function (q) {
q.once('end', function () { self.emit('land'); });
q.enqueue({rotorSpeed : Math.floor(self.hoverSpeed * 0.8)}, 400);
q.enqueue({rotorSpeed : Math.floor(self.hoverSpeed * 0.95)}, 1000);
q.enqueue({hover : true}, 300);
q.enqueue({reset : true}, 0);
});
};
module.exports = WiFli;
{
"name": "wifli",
"version": "0.3.1",
"version": "0.4.0",
"author": {

@@ -19,3 +19,3 @@ "name": "Forrest L Norvell",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "tap test"
},

@@ -22,0 +22,0 @@ "repository": {

## Pending work
* Test streaming interface for use with joystick controller.
* Add high-level commands:
* launch
* hover
* land
* make hover point configurable