Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "local_ip_address" option when discovering devices #2

Merged
merged 3 commits into from
Jun 27, 2017

Conversation

yarray
Copy link

@yarray yarray commented Jun 23, 2017

This update added a "local_ip_address" option just as in the python-broadlink api . This option is quite useful if multiple network interfaces exist and the one connecting to the target device is not the first. Also node's os.networkInterfaces cannot find all interfaces in some cases where providing a binding address may become a must (issue nodejs/node#498).

Use/test case with homebridge-broadlink-platform:

My raspberry pi connected to a router via eth0 along with my iphone. The raspberry pi also has a wireless interface wlan0 which I set as an AP. The network on eth0 has ip 192.168.0.10 and the network on wlan0 has ip 192.168.42.1. An SP1 device connected to wlan0.

Now if without the "local_ip_address" option, when sending the broadcast message to 255.255.255.255, the packet will be sent through only one (random) interface (see https://stackoverflow.com/questions/683624/udp-broadcast-on-all-interfaces) and perhaps under the network 192.168.0. Thus , it will not reach my SP1. By this update we can provide local_ip_address as 192.168.42.1 to solve the problem.

To achieve the above the homebridge-broadlink-platform package also has to be updated. I will submitted a pull request there: smka/homebridge-broadlink-platform#9.

Changes

This update only add a conditional branch. Otherwise the only change is that the socket is bound to the calculated address instead of the default (0.0.0.0), which is a rational change in my opinion.

@smka smka merged commit 59d0097 into smka:master Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants