Skip to content

Commit

Permalink
darwin: network: bugfix: wait for WiFiManagerClientDisable
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Feb 15, 2022
1 parent fb5af0f commit ae10089
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rpcclient/rpcclient/darwin/network.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ctypes
import logging
import time
from typing import List

from rpcclient.exceptions import BadReturnValueError, RpcClientException
Expand Down Expand Up @@ -83,6 +84,10 @@ def _set(self, is_on: bool):
if self._client.symbols.WiFiDeviceClientSetPower(self._device, is_on):
raise BadReturnValueError(f'WiFiDeviceClientSetPower failed ({self._client.last_error})')

# bugfix: this is an async operation, so we need to wait some time
while self.is_on() != is_on:
time.sleep(.1)

if is_on:
if self._client.symbols.WiFiManagerClientEnable(self._wifi_manager_client):
raise BadReturnValueError(f'WiFiManagerClientEnable failed ({self._client.last_error})')
Expand Down

0 comments on commit ae10089

Please sign in to comment.