Ticket #4459: 4459.patch

File 4459.patch, 2.9 KB (added by erikos, 10 years ago)

Based on nm_utils_wifi_freq_to_channel from NM add a table to support a band (5GHz)

  • extensions/deviceicon/network.py

    diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
    index b1686aa..f11df01 100644
    a b class WirelessPalette(Palette): 
    136136        self._set_channel(channel)
    137137
    138138    def _set_channel(self, channel):
    139         self._channel_label.set_text('%s: %d' % (_('Channel'), channel))
     139        if channel == 0:
     140            self._channel_label.set_text('%s: %s' % (_('Channel'),
     141                                                     _('Unknown')))
     142        else:
     143            self._channel_label.set_text('%s: %d' % (_('Channel'), channel))
    140144
    141145    def _set_ip_address(self, ip_address):
    142146        if ip_address is not None:
  • src/jarabe/model/network.py

    diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
    index 7aa7164..8047288 100644
    a b def get_error_by_reason(reason): 
    313313
    314314def frequency_to_channel(frequency):
    315315    """Returns the channel matching a given radio channel frequency. If a
    316     frequency is not in the dictionary channel 1 will be returned.
     316    frequency is not in the dictionary channel 0 will be returned.
    317317
    318318    Keyword arguments:
    319319    frequency -- The radio channel frequency in MHz.
    320320
    321     Return: Channel
     321    Return: Channel represented by the frequency or 0
    322322
    323323    """
    324     ftoc = {2412: 1, 2417: 2, 2422: 3, 2427: 4,
    325             2432: 5, 2437: 6, 2442: 7, 2447: 8,
    326             2452: 9, 2457: 10, 2462: 11, 2467: 12,
    327             2472: 13}
    328     if frequency not in ftoc:
     324    bg_table = {2412: 1, 2417: 2, 2422: 3, 2427: 4,
     325                2432: 5, 2437: 6, 2442: 7, 2447: 8,
     326                2452: 9, 2457: 10, 2462: 11, 2467: 12,
     327                2472: 13, 14: 2484}
     328
     329    a_table = {5035: 7, 5040: 8, 5045: 9, 5055: 11,
     330               5060: 12, 5080: 16, 5170: 34,
     331               5180: 36, 5190: 38, 5200: 40,
     332               5210: 42, 5220: 44, 5230: 46,
     333               5240: 48, 5250: 50, 5260: 52,
     334               5280: 56, 5290: 58, 5300: 60,
     335               5320: 64, 5500: 100, 5520: 104,
     336               5540: 108, 5560: 112, 5580: 116,
     337               5600: 120, 5620: 124, 5640: 128,
     338               5660: 132, 5680: 136, 5700: 140,
     339               5745: 149, 5760: 152, 5765: 153,
     340               5785: 157, 5800: 160, 5805: 161,
     341               5825: 165, 4915: 183, 4920: 184,
     342               4925: 185, 4935: 187, 4945: 188,
     343               4960: 192, 4980: 196}
     344
     345    if frequency not in bg_table and frequency not in a_table:
    329346        logging.warning('The frequency %s can not be mapped to a channel, '
    330                         'defaulting to channel 1.', frequency)
    331         return 1
    332     return ftoc[frequency]
     347                        'returning 0.', frequency)
     348        return 0
     349
     350    if frequency > 4900:
     351        return a_table[frequency]
     352    else:
     353        return bg_table[frequency]
    333354
    334355
    335356def is_sugar_adhoc_network(ssid):