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

broadlink.setup fails because broadcasting the data fails #618

Closed
IgitBuh opened this issue Oct 4, 2021 · 1 comment
Closed

broadlink.setup fails because broadcasting the data fails #618

IgitBuh opened this issue Oct 4, 2021 · 1 comment

Comments

@IgitBuh
Copy link

IgitBuh commented Oct 4, 2021

I don't know the actual reason, but in my case, both broadlink.discover and broadlink.setup fail, because apparently their network broadcast doesn't reach its destination. However, what does work is to use the target IP directly or at least the subnet broadcast address:

Does not work im my case:
devices = broadlink.discover(timeout=5)
Does work in my case:
devices = broadlink.discover(timeout=5, discover_ip_address='192.168.10.255')

While this is mentioned in the README, the consequences are not.
If the network broadcast does not work, then broadlink.setup won't work either! This function sends the prepared packet like this:
sock.sendto(payload, ("255.255.255.255", 80))

It took me hours to find out, that I can simply solve the problem by providing the actual IP address of the device:
sock.sendto(payload, ("192.168.10.1", 80))
This does work!

Therefore, my suggestion would be to modify the setup function like this:

def setup(ssid: str, password: str, security_mode: int, target_ip: str = '255.255.255.255') -> None:
[...]
sock.sendto(payload, (target_ip, 80))

so it can be used like this:
setup_target("MySsid", "MyPassphrase", 3, "192.168.10.1")

Also, a minor side note: The README says "Manually connect to the WiFi SSID named BroadlinkProv.", but the SSID is actually "BroadLink_WiFi_Device" (at least for the Broadlink RM4 Pro).

@felipediel
Copy link
Collaborator

Thank you! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants