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"""Derived class to control Linksys E1000 router.""" 6 7import ap_spec 8import linksyse2100_ap_configurator 9 10 11class Linksyse1000APConfigurator(linksyse2100_ap_configurator. 12 Linksyse2100APConfigurator): 13 """Derived class to control Linksys E1000 router.""" 14 15 def _set_mode(self, mode, band=None): 16 mode_mapping = {ap_spec.MODE_M:'Mixed', 17 ap_spec.MODE_B | ap_spec.MODE_G:'Wireless-B/G Only', 18 ap_spec.MODE_G:'Wireless-G Only', 19 ap_spec.MODE_B:'Wireless-B Only', 20 ap_spec.MODE_N:'Wireless-N Only', 21 ap_spec.MODE_D:'Disabled'} 22 mode_name = mode_mapping.get(mode) 23 if not mode_name: 24 raise RuntimeError('The mode %d not supported by router %s. ', 25 hex(mode), self.name) 26 xpath = '//select[@name="wl_net_mode"]' 27 self.select_item_from_popup_by_xpath(mode_name, xpath, 28 alert_handler=self._sec_alert) 29 30 31 def _set_channel(self, channel): 32 position = self._get_channel_popup_position(channel) 33 xpath = '//select[@name="wl_schannel"]' 34 channels = ['Auto', '1', '2', '3', '4', '5', '6', '7', '8', 35 '9', '10', '11'] 36 self.select_item_from_popup_by_xpath(channels[position], xpath) 37 38 39 def _set_channel_width(self, channel_wid): 40 """Sets the channel width for the wireless network.""" 41 channel_width_choice = ['Auto (20 MHz or 40 MHz)', '20MHz only'] 42 xpath = '//select[@name="_wl_nbw"]' 43 self.select_item_from_popup_by_xpath(channel_width_choice[channel_wid], 44 xpath) 45