Made module Wirething compatible
This commit is contained in:
parent
38d10719b0
commit
109393c0cf
28
Wirefile
Normal file
28
Wirefile
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "Lego Dimensions",
|
||||
"description": "Node.js and Wirething module for interacting with the Lego Dimensions ToyPad",
|
||||
"author": "Nathan Kunicki <me@nathankunicki.com>",
|
||||
"main": "./index.js",
|
||||
"devices": [{
|
||||
"name": "ToyPad",
|
||||
"type": "toypad",
|
||||
"outputs": [{
|
||||
"name": "Add",
|
||||
"event": "add",
|
||||
"params": [{
|
||||
"name": "Decoded Payload",
|
||||
"param": "payload",
|
||||
"type": "Object"
|
||||
}]
|
||||
},{
|
||||
"name": "Remove",
|
||||
"event": "remove",
|
||||
"params": [{
|
||||
"name": "Decoded Payload",
|
||||
"param": "payload",
|
||||
"type": "Object"
|
||||
}]
|
||||
}],
|
||||
"inputs": []
|
||||
}]
|
||||
}
|
@ -9,5 +9,7 @@
|
||||
"54 60 a2 5b 49 81": "Krusty-the-Clown",
|
||||
"87 b8 1a 7f 49 80": "Peter Venkman",
|
||||
"0a 2e aa 5c 49 81": "Kai",
|
||||
"cc cb 22 55 42 80": "Scooby-Doo"
|
||||
"cc cb 22 55 42 80": "Scooby-Doo",
|
||||
"5f 33 9a 58 49 80": "Green Lantern",
|
||||
"28 9e 32 83 49 80": "Supergirl"
|
||||
}
|
31
index.js
Normal file
31
index.js
Normal file
@ -0,0 +1,31 @@
|
||||
const EventEmitter = require("events").EventEmitter,
|
||||
debugLog = require("debug")("LegoDimensions"),
|
||||
fs = require("fs");
|
||||
|
||||
|
||||
const ToyPad = require("./src/toypad.js");
|
||||
|
||||
|
||||
class LegoDimensions extends EventEmitter {
|
||||
|
||||
|
||||
constructor (config) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
wirethingInit () {
|
||||
let toyPad = new ToyPad();
|
||||
this.emit("discover", toyPad);
|
||||
}
|
||||
|
||||
|
||||
static get wirething () {
|
||||
return JSON.parse(fs.readFileSync(`${__dirname}/Wirefile`));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = LegoDimensions;
|
@ -2,13 +2,14 @@
|
||||
"name": "retrodimensions",
|
||||
"version": "1.0.0",
|
||||
"description": "Retro Dimensions",
|
||||
"main": "main.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Nathan Kunicki <me@nathankunicki.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.0",
|
||||
"node-hid": "0.5.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
let EventEmitter = require("events").EventEmitter,
|
||||
const EventEmitter = require("events").EventEmitter,
|
||||
HID = require("node-hid");
|
||||
|
||||
|
||||
@ -35,6 +35,8 @@ class ToyPad extends EventEmitter {
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this.uuid = "1";
|
||||
this.deviceType = "toypad";
|
||||
this._device = null;
|
||||
this._requestId = 0;
|
||||
}
|
||||
@ -123,7 +125,7 @@ class ToyPad extends EventEmitter {
|
||||
});
|
||||
|
||||
this._device.on("error", (err) => {
|
||||
this.emit("error");
|
||||
this.emit("error", err);
|
||||
});
|
||||
|
||||
this._wake();
|
||||
|
Loading…
x
Reference in New Issue
Block a user