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

Allow subnet to be specified for broadcast #965

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jorticus
Copy link

@jorticus jorticus commented Mar 9, 2021

This is to address issue #584 - discover doesn't work on Windows unless you specify the correct interface's subnet.

Usage:

> py -m miio.vacuum_cli discover --handshake 1 --subnet 192.168.4.255
INFO:miio.miioprotocol:Sending discovery to 192.168.4.255 with timeout of 5s..
INFO:miio.miioprotocol:  IP 192.168.4.1 (ID: 13e7927b) - token: b'...'

Closes #584

miio/miioprotocol.py Show resolved Hide resolved
miio/miioprotocol.py Show resolved Hide resolved
Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, could you please change the parameter order & fix the linting problem (e.g., by running pre-commit run -a)? After those this is ready to be merged.

@@ -90,18 +90,22 @@ def send_handshake(self, *, retry_count=3) -> Message:
return m

@staticmethod
def discover(addr: str = None, timeout: int = 5) -> Any:
def discover(addr: str = None, is_broadcast: bool = True, timeout: int = 5) -> Any:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def discover(addr: str = None, is_broadcast: bool = True, timeout: int = 5) -> Any:
def discover(addr: str = None, timeout: int = 5, *, is_broadcast: bool = True) -> Any:

Let's move the is_broadcast to be the last parameter, and make it kwarg-only for clarity.

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

Successfully merging this pull request may close these issues.

Discover uses wrong IP for broadcasts on Windows
2 participants