node-lifx-lan-multi 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lifx-lan-udp.js +4 -2
- package/lib/lifx-lan.js +6 -3
- package/package.json +1 -1
package/lib/lifx-lan-udp.js
CHANGED
|
@@ -52,7 +52,7 @@ LifxLanUdp.prototype.destroy = function () {
|
|
|
52
52
|
/* ------------------------------------------------------------------
|
|
53
53
|
* Method: init()
|
|
54
54
|
* ---------------------------------------------------------------- */
|
|
55
|
-
LifxLanUdp.prototype.init = function () {
|
|
55
|
+
LifxLanUdp.prototype.init = function (config = {}) {
|
|
56
56
|
let promise = new Promise((resolve, reject) => {
|
|
57
57
|
this._source_id = Math.floor(Math.random() * 0xffffffff);
|
|
58
58
|
let netif_list = mAddress.getNetworkInterfaces();
|
|
@@ -74,7 +74,9 @@ LifxLanUdp.prototype.init = function () {
|
|
|
74
74
|
this._udp.on('message', (buf, rinfo) => {
|
|
75
75
|
this._receivePacket(buf, rinfo);
|
|
76
76
|
});
|
|
77
|
-
this._udp.bind({
|
|
77
|
+
this._udp.bind({
|
|
78
|
+
port: config.udp_receive_port ?? this._UDP_PORT
|
|
79
|
+
});
|
|
78
80
|
});
|
|
79
81
|
return promise;
|
|
80
82
|
};
|
package/lib/lifx-lan.js
CHANGED
|
@@ -13,8 +13,9 @@ const mLifxLanColor = require('./lifx-lan-color');
|
|
|
13
13
|
/* ------------------------------------------------------------------
|
|
14
14
|
* Constructor: LifxLan()
|
|
15
15
|
* ---------------------------------------------------------------- */
|
|
16
|
-
const LifxLan = function () {
|
|
16
|
+
const LifxLan = function (config = {}) {
|
|
17
17
|
// Private
|
|
18
|
+
this._config = config;
|
|
18
19
|
this._is_scaning = false;
|
|
19
20
|
this._initialized = false;
|
|
20
21
|
this._device_list = null;
|
|
@@ -28,7 +29,9 @@ LifxLan.prototype.init = function () {
|
|
|
28
29
|
if (this._initialized) {
|
|
29
30
|
resolve();
|
|
30
31
|
} else {
|
|
31
|
-
mLifxUdp.init(
|
|
32
|
+
mLifxUdp.init({
|
|
33
|
+
udp_receive_port: this._config.udp_receive_port
|
|
34
|
+
}).then(() => {
|
|
32
35
|
this._initialized = true;
|
|
33
36
|
resolve();
|
|
34
37
|
}).catch((error) => {
|
|
@@ -905,4 +908,4 @@ LifxLan.prototype.destroy = function () {
|
|
|
905
908
|
return promise;
|
|
906
909
|
};
|
|
907
910
|
|
|
908
|
-
module.exports =
|
|
911
|
+
module.exports = LifxLan;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-lifx-lan-multi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The node-lifx-lan is a Node.js module which allows you to communicate with the Wi-Fi LED smart light products \"LIFX\" using the LAN protocol.",
|
|
5
5
|
"main": "./lib/lifx-lan.js",
|
|
6
6
|
"files": [
|