1 # FST tests related definitions
2 # Copyright (c) 2015, Qualcomm Atheros, Inc.
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
12 logger = logging.getLogger()
14 fst_test_def_group='fstg0'
15 fst_test_def_freq_g='2412' # Channel 1
16 fst_test_def_freq_a='5180' # Channel 36
17 fst_test_def_chan_g='1'
18 fst_test_def_chan_a='36'
19 fst_test_def_prio_low='100'
20 fst_test_def_prio_high='110'
21 fst_test_def_llt='100'
22 fst_test_def_reg_domain='00'
31 if self.refcnt != 0 and self.changed == True:
32 self.restore_reg_domain()
35 if self.ifname != None:
36 hapd = hostapd.Hostapd(self.ifname)
37 self.changed = self.wait_hapd_reg_change(hapd)
40 if self.changed == True:
41 self.restore_reg_domain()
44 def add_ap(self, ifname, chan):
45 if self.changed == False and self.channel_may_require_reg_change(chan):
49 def channel_may_require_reg_change(chan):
55 def wait_hapd_reg_change(hapd):
56 state = hapd.get_status_field("state")
57 if state != "COUNTRY_UPDATE":
58 state = hapd.get_status_field("state")
59 if state != "ENABLED":
60 raise Exception("Unexpected interface state - expected COUNTRY_UPDATE")
62 logger.debug("fst hostapd: regulatory domain already set")
65 logger.debug("fst hostapd: waiting for regulatory domain to be set...")
67 ev = hapd.wait_event(["AP-ENABLED"], timeout=10)
69 raise Exception("AP setup timed out")
71 logger.debug("fst hostapd: regulatory domain set")
73 state = hapd.get_status_field("state")
74 if state != "ENABLED":
75 raise Exception("Unexpected interface state - expected ENABLED")
77 logger.debug("fst hostapd: regulatory domain ready")
81 def restore_reg_domain():
82 logger.debug("fst hostapd: waiting for regulatory domain to be restored...")
84 res = subprocess.call(['iw', 'reg', 'set', fst_test_def_reg_domain])
86 raise Exception("Cannot restore regulatory domain")
88 logger.debug("fst hostapd: regulatory domain ready")