Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions kasa/smart/smartdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,26 +512,13 @@ def _net_for_scan_info(res):
bssid=res["bssid"],
)

async def _query_networks(networks=None, start_index=0):
_LOGGER.debug("Querying networks using start_index=%s", start_index)
if networks is None:
networks = []
_LOGGER.debug("Querying networks")

resp = await self.protocol.query(
{"get_wireless_scan_info": {"start_index": start_index}}
)
network_list = [
_net_for_scan_info(net)
for net in resp["get_wireless_scan_info"]["ap_list"]
]
networks.extend(network_list)

if resp["get_wireless_scan_info"].get("sum", 0) > start_index + 10:
return await _query_networks(networks, start_index=start_index + 10)

return networks

return await _query_networks()
resp = await self.protocol.query({"get_wireless_scan_info": {"start_index": 0}})
networks = [
_net_for_scan_info(net) for net in resp["get_wireless_scan_info"]["ap_list"]
]
return networks

async def wifi_join(self, ssid: str, password: str, keytype: str = "wpa2_psk"):
"""Join the given wifi network.
Expand Down