plasticrake / tplink-smarthome-api

TP-Link Smarthome WiFi API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Client.startDiscovery() boardcast failed silently @ windows 10

aptxyz opened this issue · comments

No devices return from startDiscovery() @ windows 10. After some (crazy) digging, I figure out its because when broadcasting address, 255.255.255.255 will be sent through the first interface in the route table that matches the destination. Then I recall I might have messed up the internet interface somehow from wireshark or hyper-v or whatever it was.

after that, I used my wifi as the broadcasting interface, I am able to retrieve the devices from startDiscovery(), from Scott Lundberg@serverfault, it stated that it should be fixed at the application level. I don't think tplink-smarthome-api did anything wrong, instead the node package dgram should be responsible for that. I'm just reporting that to let you know, it will failed silently due to this.

You can specify the interface address you want to use by passing it to startDiscovery({address: '0.0.0.0'})

And you can specify the exact broadcast address to send to as well.

  /**
   * address to bind udp socket
   */
  address?: string;
  /**
   * port to bind udp socket
   */
  port?: number;
  /**
   * broadcast address
   * @defaultValue '255.255.255.255'
   */
  broadcast?: string;