2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
7 from remotehost import remote_compatible
10 logger = logging.getLogger()
15 def test_autoscan_periodic(dev, apdev):
16 """autoscan_periodic"""
17 hostapd.add_ap(apdev[0], { "ssid": "autoscan" })
20 if "OK" not in dev[0].request("AUTOSCAN periodic:1"):
21 raise Exception("Failed to set autoscan")
22 id = dev[0].connect("not-used", key_mgmt="NONE", scan_freq="2412",
26 logger.info("Waiting for scan to start")
28 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=5)
30 raise Exception("did not start a scan")
32 times[i] = stop - start
33 logger.info("Waiting for scan to complete")
34 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
36 raise Exception("did not complete a scan")
37 if times[0] > 1 or times[1] < 0.5 or times[1] > 1.5 or times[2] < 0.5 or times[2] > 1.5:
38 raise Exception("Unexpected scan timing: " + str(times))
40 # scan some more channels to allow some more time for reseting AUTOSCAN
41 # while a scan is in progress
42 dev[0].set_network(id, "scan_freq", "2412 2437 2462 5180 5200 5220 5240")
44 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=5)
46 raise Exception("did not start a scan")
47 if "OK" not in dev[0].request("AUTOSCAN periodic:2"):
48 raise Exception("Failed to (re)set autoscan")
49 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
51 raise Exception("did not complete a scan")
53 dev[0].request("AUTOSCAN ")
56 def test_autoscan_exponential(dev, apdev):
57 """autoscan_exponential"""
58 hostapd.add_ap(apdev[0], { "ssid": "autoscan" })
61 if "OK" not in dev[0].request("AUTOSCAN exponential:2:10"):
62 raise Exception("Failed to set autoscan")
63 dev[0].connect("not-used", key_mgmt="NONE", scan_freq="2412",
67 logger.info("Waiting for scan to start")
69 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=5)
71 raise Exception("did not start a scan")
73 times[i] = stop - start
74 logger.info("Waiting for scan to complete")
75 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
77 raise Exception("did not complete a scan")
78 if times[0] > 1 or times[1] < 1 or times[1] > 3 or times[2] < 3 or times[2] > 5:
79 raise Exception("Unexpected scan timing: " + str(times))
81 dev[0].request("AUTOSCAN ")