wifi模块工作在Station模式

linux内核:linux-2.6.39

开发板平台:at91sam9x35

WIFI模块:rt3070


~ >: ifconfig wlan0 up

~ apps>:ls 

/apps >: ls
etc                  usb_modeswitch       zte_mf626.conf
iwconfig             wpa_supplicant
iwlist               wpa_supplicant.conf

1.扫描信号

/apps >: iwlist wlan0 scanning

Cell 02 - Address: C8:3A:35:C7:14:1F
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=33/70  Signal level=-77 dBm  
                    Encryption key:on
                    ESSID:"Router_LingYun"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 9 Mb/s
                              18 Mb/s; 36 Mb/s; 54 Mb/s
                    Bit Rates:6 Mb/s; 12 Mb/s; 24 Mb/s; 48 Mb/s
                    Mode:Master
                    Extra:tsf=0000000675dd746e
                    Extra: Last beacon: 3560ms ago
                    IE: Unknown: 0003355549
                    IE: Unknown: 010882848B961224486C
                    IE: Unknown: 030101
                    IE: Unknown: 2A0104
                    IE: Unknown: 32040C183060
                    IE: IEEE 802.11i/WPA Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
                    IE: Unknown: DD07000C4306000000
                    IE: Unknown: 2D1A6E0102FF000000000000000000000000000000000E0000000000
                    IE: Unknown: 3D1601050000000000000000000000000000000000000000
                    IE: Unknown: 3E0100
                    IE: Unknown: DD1E00904C336E0102FF000000000000000000000000000000000E0000000000
                    IE: Unknown: DD1A00904C3401050000000000000000000000000000000000000000

我们要连的wifi名为“Router_LingYun"

2.设置IP地址和子网掩码

/apps >: ifconfig wlan0 192.168.1.110 netmask 255.255.255.0 

3.运行wpa_supplicant

/apps >: ./wpa_supplicant -B -Dwext -iwlan0 -c/apps/wpa_supplicant.conf
Successfully initialized wpa_supplicant

/apps >: iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"Router_LingYun"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: C8:3A:35:C7:14:1F   
          Bit Rate=6.5 Mb/s   Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=29/70  Signal level=-81 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:1  Invalid misc:0   Missed beacon:0


/apps >: ping 192.168.1.1 -I wlan0
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: seq=0 ttl=64 time=2110.717 ms
64 bytes from 192.168.1.1: seq=1 ttl=64 time=1110.564 ms
64 bytes from 192.168.1.1: seq=2 ttl=64 time=110.606 ms

/apps >: cat wpa_supplicant.conf 

# WPA-PSK/TKIP
# http://www.linuxidc.com/Linux/2011-10/45202.htm
# wpa_supplicant -B -Dwext -iwlan0 -c/apps/etc/wireless/wpa_supplicant.conf


ctrl_interface=/var/run/wpa_supplicant


network={
        ssid="Roter_LingYun"     /*要连的wifi的名字*/
        key_mgmt=WPA-PSK
        proto=WPA    /*这个地方一定要看是哪种加密方式,上面用iwlist扫描后看到是WPA加密。这里一定要填对,不然连不上*/
        pairwise=CCMP
        group=CCMP
        psk="lingyun-emb"    /*密码*/

}

你可能感兴趣的:(wifi模块工作在Station模式)