Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine a wifi channel number used by wifi ap/network?

Tags:

c

android

wifi

Ive discovered that several android wifi-apps (WiFi Manager, WiFi Analyzer) shows a channel number of WiFi network additionally to BSSID/SSID etc. But I can't find any info on how they do it. The only thing I know is I can get some wifi frequency. Maybe they determine a channel corresponding to that frequency? Is there a way to detect channel of wifi network in android at all? Of course this info is not a big deal and I can live without it :) but still i'm curious...

like image 966
Stan Avatar asked Mar 30 '11 11:03

Stan


2 Answers

According to Radio-Electronics.com, channel number is truly related with frequency.

CHA LOWER   CENTER  UPPER
NUM FREQ    FREQ    FREQ
    MHZ     MHZ     MHZ
  1 2401    2412    2423
  2 2406    2417    2428
  3 2411    2422    2433
  4 2416    2427    2438
  5 2421    2432    2443
  6 2426    2437    2448
  7 2431    2442    2453
  8 2436    2447    2458
  9 2441    2452    2463
 10 2446    2457    2468
 11 2451    2462    2473
 12 2456    2467    2478
 13 2461    2472    2483
 14 2473    2484    2495

For Android, ScanResult contains the frequency of the channel.

like image 156
Dante May Code Avatar answered Oct 13 '22 03:10

Dante May Code


@SuppressWarnings("boxing")
private final static ArrayList<Integer> channelsFrequency = new ArrayList<Integer>(
        Arrays.asList(0, 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447,
                2452, 2457, 2462, 2467, 2472, 2484));

public static Integer getFrequencyFromChannel(int channel) {
    return channelsFrequency.get(channel);
}

public static int getChannelFromFrequency(int frequency) {
    return channelsFrequency.indexOf(Integer.valueOf(frequency));
}
like image 31
André Lemos Avatar answered Oct 13 '22 03:10

André Lemos