@tuyapi/link
Advanced tools
Comparing version 0.3.4 to 0.4.0
@@ -28,3 +28,3 @@ const {TuyaContext} = require('@tuya/tuya-connector-nodejs'); | ||
class TuyaLinkWizard { | ||
constructor({email, password, region = 'us', timezone = 'America/Chicago', apiKey, apiSecret, schema} = {}) { | ||
constructor({email, password, region = 'us', timezone = 'America/Chicago', apiKey, apiSecret, schema, bindAddr} = {}) { | ||
if (!email || !password) { | ||
@@ -38,2 +38,3 @@ throw new Error('Both email and password must be provided'); | ||
this.timezone = timezone; | ||
this.bindAddr = bindAddr; | ||
@@ -128,3 +129,4 @@ this.api = new TuyaContext({ | ||
ssid, | ||
wifiPassword}); | ||
wifiPassword, | ||
bindAddr: this.bindAddr}); | ||
@@ -131,0 +133,0 @@ // While UDP packets are being sent, start polling for device |
const dgram = require('dgram'); | ||
const delay = require('delay'); | ||
const debug = require('debug')('@tuyapi/link:manual'); | ||
const os = require('os'); | ||
@@ -17,2 +18,3 @@ /** | ||
this.abortBroadcasting = false; | ||
this.bindAddr = undefined; | ||
} | ||
@@ -70,2 +72,17 @@ | ||
if (options.bindAddr !== undefined) { | ||
if (typeof options.bindAddr !== 'string') { | ||
throw new TypeError('Invalid binding address'); | ||
} | ||
const interfaces = os.networkInterfaces(); | ||
if (!Object.keys(interfaces).some(name => | ||
!interfaces[name].some(assigned => assigned.address.toLowerCase() === options.bindAddr.toLowerCase()) | ||
)) { | ||
throw new Error('Invalid binding address'); | ||
} | ||
this.bindAddr = options.bindAddr; | ||
} | ||
debug('Sending SmartLink initialization packets'); | ||
@@ -340,3 +357,3 @@ | ||
}); | ||
this.udpClient.bind(0); | ||
this.udpClient.bind(0, this.bindAddr); | ||
} | ||
@@ -343,0 +360,0 @@ |
{ | ||
"name": "@tuyapi/link", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "📡 Effortlessly connect devices to WiFi and the cloud", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20663
493