def test_ap_spectrum_management_required(dev, apdev):
    'Open AP with spectrum management required'
    ssid = 'spectrum mgmt'
    params = {}
    params['ssid'] = ssid
    params['country_code'] = 'JP'
    params['hw_mode'] = 'a'
    params['channel'] = '36'
    params['ieee80211d'] = '1'
    params['local_pwr_constraint'] = '3'
    params['spectrum_mgmt_required'] = '1'
    try:
        hapd = None
        hapd = hostapd.add_ap(apdev[0], params)
        dev[0].connect(ssid, key_mgmt='NONE', scan_freq='5180')
        dev[0].wait_regdom(country_ie=True)
    finally:
        if hapd:
            hapd.request('DISABLE')
        dev[0].disconnect_and_stop_scan()
        hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
        dev[0].wait_event(['CTRL-EVENT-REGDOM-CHANGE'], timeout=0.5)
        dev[0].flush_scan_cache()
Open AP with spectrum management required
def test_ap_spectrum_management_required(dev, apdev):
    
    ssid = 'spectrum mgmt'
    params = {}
    params['ssid'] = ssid
    params['country_code'] = 'JP'
    params['hw_mode'] = 'a'
    params['channel'] = '36'
    params['ieee80211d'] = '1'
    params['local_pwr_constraint'] = '3'
    params['spectrum_mgmt_required'] = '1'
    try:
        hapd = None
        hapd = hostapd.add_ap(apdev[0], params)
        dev[0].connect(ssid, key_mgmt='NONE', scan_freq='5180')
        dev[0].wait_regdom(country_ie=True)
    finally:
        if hapd:
            hapd.request('DISABLE')
        dev[0].disconnect_and_stop_scan()
        hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
        dev[0].wait_event(['CTRL-EVENT-REGDOM-CHANGE'], timeout=0.5)
        dev[0].flush_scan_cache()