FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add discovery port 20004 by alams154 · Pull Request #1595 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion kasa/discover.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def __init__(
self.target = target
self.target_1 = (target, self.discovery_port)
self.target_2 = (target, Discover.DISCOVERY_PORT_2)
self.target_3 = (target, Discover.DISCOVERY_PORT_3)

self.discovered_devices = {}
self.unsupported_device_exceptions: dict = {}
Expand Down Expand Up @@ -333,6 +334,7 @@ async def do_discover(self) -> None:
break
self.transport.sendto(encrypted_req[4:], self.target_1) # type: ignore
self.transport.sendto(aes_discovery_query, self.target_2) # type: ignore
self.transport.sendto(aes_discovery_query, self.target_3) # type: ignore
await asyncio.sleep(sleep_between_packets)

def datagram_received(
Expand Down Expand Up @@ -361,7 +363,7 @@ def datagram_received(
if port == self.discovery_port:
json_func = Discover._get_discovery_json_legacy
device_func = Discover._get_device_instance_legacy
elif port == Discover.DISCOVERY_PORT_2:
elif port in (Discover.DISCOVERY_PORT_2, Discover.DISCOVERY_PORT_3):
json_func = Discover._get_discovery_json
device_func = Discover._get_device_instance
else:
Expand Down Expand Up @@ -422,6 +424,7 @@ class Discover:
}

DISCOVERY_PORT_2 = 20002
DISCOVERY_PORT_3 = 20004
DISCOVERY_QUERY_2 = binascii.unhexlify("020000010000000000000000463cb5d3")

_redact_data = True
Expand Down
3 changes: 2 additions & 1 deletion tests/test_discovery.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,13 @@ async def mock_discover(self):
async def test_discover_send(mocker):
"""Test discovery parameters."""
discovery_timeout = 0
discovery_ports = 3
proto = _DiscoverProtocol(discovery_timeout=discovery_timeout)
assert proto.discovery_packets == 3
assert proto.target_1 == ("255.255.255.255", 9999)
transport = mocker.patch.object(proto, "transport")
await proto.do_discover()
assert transport.sendto.call_count == proto.discovery_packets * 2
assert transport.sendto.call_count == proto.discovery_packets * discovery_ports


async def test_discover_datagram_received(mocker, discovery_data):
Expand Down
Loading

Back | FazBrowse Home | New Git URL