-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
392 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
var Packet = { | ||
size: 0 | ||
}; | ||
|
||
module.exports = Packet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
var Packet = { | ||
size: 2 | ||
}; | ||
|
||
/** | ||
* Converts packet specific data from a buffer to an object | ||
* @param {Buffer} buf Buffer containing only packet specific data no header | ||
* @return {Object} Information contained in packet | ||
*/ | ||
Packet.toObject = function(buf) { | ||
var obj = {}; | ||
var offset = 0; | ||
|
||
if (buf.length !== this.size) { | ||
throw new Error('Invalid length given for setInfrared LIFX packet'); | ||
} | ||
|
||
obj.brightness = buf.readUInt16LE(offset); | ||
offset += 2; | ||
|
||
return obj; | ||
}; | ||
|
||
/** | ||
* Converts the given packet specific object into a packet | ||
* @param {Object} obj object with configuration data | ||
* @param {Number} obj.brightness between 0 and 65535 | ||
* @return {Buffer} packet | ||
*/ | ||
Packet.toBuffer = function(obj) { | ||
var buf = new Buffer(this.size); | ||
buf.fill(0); | ||
var offset = 0; | ||
|
||
if (typeof obj.brightness !== 'number' && obj.brightness < 0 && obj.brightness > 65535) { | ||
throw new RangeError('Invalid brightness given for setInfrared LIFX packet, must be a number between 0 and 65535'); | ||
} | ||
buf.writeUInt16LE(obj.brightness, offset); | ||
offset += 2; | ||
|
||
return buf; | ||
}; | ||
|
||
module.exports = Packet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
var Packet = { | ||
size: 2 | ||
}; | ||
|
||
/** | ||
* Converts packet specific data from a buffer to an object | ||
* @param {Buffer} buf Buffer containing only packet specific data no header | ||
* @return {Object} Information contained in packet | ||
*/ | ||
Packet.toObject = function(buf) { | ||
var obj = {}; | ||
var offset = 0; | ||
|
||
if (buf.length !== this.size) { | ||
throw new Error('Invalid length given for stateInfrared LIFX packet'); | ||
} | ||
|
||
obj.brightness = buf.readUInt16LE(offset); | ||
offset += 2; | ||
|
||
return obj; | ||
}; | ||
|
||
/** | ||
* Converts the given packet specific object into a packet | ||
* @param {Object} obj object with configuration data | ||
* @return {Buffer} packet | ||
*/ | ||
Packet.toBuffer = function(obj) { | ||
var buf = new Buffer(this.size); | ||
buf.fill(0); | ||
var offset = 0; | ||
|
||
buf.writeUInt16LE(obj.brightness, offset); | ||
offset += 2; | ||
|
||
return buf; | ||
}; | ||
|
||
module.exports = Packet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
[ | ||
{ | ||
"vid": 1, | ||
"name": "LIFX", | ||
"products": [ | ||
{ | ||
"pid": 1, | ||
"name": "Original 1000", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 3, | ||
"name": "Color 650", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 10, | ||
"name": "White 800 (Low Voltage)", | ||
"features": { | ||
"color": false, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 11, | ||
"name": "White 800 (High Voltage)", | ||
"features": { | ||
"color": false, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 18, | ||
"name": "White 900 BR30 (Low Voltage)", | ||
"features": { | ||
"color": false, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 20, | ||
"name": "Color 1000 BR30", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 22, | ||
"name": "Color 1000", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 27, | ||
"name": "LIFX A19", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 28, | ||
"name": "LIFX BR30", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 29, | ||
"name": "LIFX+ A19", | ||
"features": { | ||
"color": true, | ||
"infrared": true, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 30, | ||
"name": "LIFX+ BR30", | ||
"features": { | ||
"color": true, | ||
"infrared": true, | ||
"multizone": false | ||
} | ||
}, | ||
{ | ||
"pid": 31, | ||
"name": "LIFX Z", | ||
"features": { | ||
"color": true, | ||
"infrared": false, | ||
"multizone": true | ||
} | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.