/bin/wifi: fix Quantenna stopap and stopclient.
Change-Id: I95c86edcd6a449d1357f8947477c09dfbaeb21de
diff --git a/wifi/quantenna.py b/wifi/quantenna.py
index 9498df1..12ae6f4 100755
--- a/wifi/quantenna.py
+++ b/wifi/quantenna.py
@@ -109,15 +109,6 @@
return True
-def _stop(_):
- """Disable wifi."""
- if not _get_interface():
- return False
-
- _qcsapi('rfenable', '0')
- return True
-
-
def set_wifi(opt):
return _set('ap', opt)
@@ -126,9 +117,23 @@
return _set('sta', opt)
-def stop_ap_wifi(opt):
- return _stop(opt)
+def stop_ap_wifi(_):
+ """Disable AP."""
+ if not _get_interface():
+ return False
+
+ if _qcsapi('get_mode', 'wifi0') == 'Access point':
+ _qcsapi('rfenable', '0')
+
+ return True
-def stop_client_wifi(opt):
- return _stop(opt)
+def stop_client_wifi(_):
+ """Disable client."""
+ if not _get_interface():
+ return False
+
+ if _qcsapi('get_mode', 'wifi0') == 'Station':
+ _qcsapi('rfenable', '0')
+
+ return True
diff --git a/wifi/quantenna_test.py b/wifi/quantenna_test.py
index d4b4aed..19aa0a2 100755
--- a/wifi/quantenna_test.py
+++ b/wifi/quantenna_test.py
@@ -19,6 +19,10 @@
return '1' if ['startprod', 'wifi0'] in calls else '0'
if args[0] == 'get_bssid':
return '00:11:22:33:44:55'
+ if args[0] == 'get_mode':
+ i = [c for c in matching_calls_indices(['update_config_param'])
+ if calls[c][2] == 'mode']
+ return 'Access point' if calls[i[-1]][3] == 'ap' else 'Station'
bridge_interfaces = set()
@@ -185,12 +189,15 @@
@wvtest.wvtest
def stop_wifi_test():
opt = FakeOptDict()
+ opt.bridge = 'br0'
set_fakes()
+ wvtest.WVPASS(quantenna.set_wifi(opt))
+ new_calls_start = len(calls)
wvtest.WVPASS(quantenna.stop_ap_wifi(opt))
- wvtest.WVPASS(['rfenable', '0'] in calls)
- set_fakes()
+ wvtest.WVPASS(['rfenable', '0'] in calls[new_calls_start:])
+ new_calls_start = len(calls)
wvtest.WVPASS(quantenna.stop_client_wifi(opt))
- wvtest.WVPASS(['rfenable', '0'] in calls)
+ wvtest.WVPASS(['rfenable', '0'] not in calls[new_calls_start:])
if __name__ == '__main__':