From ae100893b2a1338dc5e0cae6dd826992e82f7cdb Mon Sep 17 00:00:00 2001 From: doron zarhi Date: Tue, 15 Feb 2022 16:21:33 +0200 Subject: [PATCH] darwin: network: bugfix: wait for WiFiManagerClientDisable --- src/rpcclient/rpcclient/darwin/network.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpcclient/rpcclient/darwin/network.py b/src/rpcclient/rpcclient/darwin/network.py index ae075a80..5225db1b 100644 --- a/src/rpcclient/rpcclient/darwin/network.py +++ b/src/rpcclient/rpcclient/darwin/network.py @@ -1,5 +1,6 @@ import ctypes import logging +import time from typing import List from rpcclient.exceptions import BadReturnValueError, RpcClientException @@ -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})')