1# Copyright (c) 2013 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""Class to control the Asus66RAP router.""" 6 7import ap_spec 8import asus_qis_ap_configurator 9 10 11class Asus66RAPConfigurator(asus_qis_ap_configurator.AsusQISAPConfigurator): 12 """Derives class for Asus RT-AC66R.""" 13 14 def set_mode(self, mode, band=None): 15 self.set_security_disabled() # To avoid the modal dialog. 16 self.add_item_to_command_list(self._set_mode, (mode, band), 1, 900) 17 18 19 def _set_mode(self, mode, band=None): 20 if band: 21 self._set_band(band) 22 if mode == ap_spec.MODE_AUTO: 23 mode_popup = 'Auto' 24 elif mode == ap_spec.MODE_N: 25 mode_popup = 'N Only' 26 else: 27 raise RuntimeError('Invalid mode passed %x' % mode) 28 xpath = '//select[@name="wl_nmode_x"]' 29 self.select_item_from_popup_by_xpath(mode_popup, xpath, 30 alert_handler=self._invalid_security_handler) 31 32 33 def set_channel(self, channel): 34 self.add_item_to_command_list(self._set_channel, (channel,), 1, 900) 35 36 37 def _set_channel(self, channel): 38 position = self._get_channel_popup_position(channel) 39 channel_choices = ['Auto', '1', '2', '3', '4', '5', '6', 40 '7', '8', '9', '10', '11'] 41 xpath = '//select[@name="wl_chanspec"]' 42 if self.current_band == ap_spec.BAND_5GHZ: 43 channel_choices = ['Auto', '36', '40', '44', '48', '149', '153', 44 '157', '161'] 45 self.select_item_from_popup_by_xpath(str(channel_choices[position]), 46 xpath) 47