CodeBardian / tplink-smartdevices-netstandard

.NET Standard 2.0 Library for Discovering and Operating TP-Link Smart Devices
https://codebardian.github.io/tplink-smartdevices-netstandard/
Apache License 2.0
18 stars 5 forks source link

usage of different broadcast address #15

Closed CodeBardian closed 4 years ago

CodeBardian commented 4 years ago

the discovery of devices within a network fails under certain circumstances. some routers seem to block udp packets to the broadcast address (255.255.255.255), which is used to send out for a discovery request.

In case of using different subnets, what seems to resolve the issue is broadcasting to the subnet's local broadcast IP (such as 192.168.0.255 if IP is 192.168.0.x with a subnet mask of 255.255.255.0) instead of IPAddress.Broadcast

these changes will allow to specify a broadcast address as parameter of discovery