KEMBAR78
MTK Wi-Fi STA Software Programming Guide v1.1 | PDF | Computing | Software
0% found this document useful (0 votes)
444 views82 pages

MTK Wi-Fi STA Software Programming Guide v1.1

Uploaded by

Anderson JS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
444 views82 pages

MTK Wi-Fi STA Software Programming Guide v1.1

Uploaded by

Anderson JS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

N LY

US AL
EO
om TI
y.c N
ra IDE
MTK Wi-Fi STA Software Programming Guide
em F
og ON
@ C
01 K
02 TE

Version: 1.1
50 A

Release date: 2012-10-31


29 DI
E
M

© 2008 - 2012 MediaTek Inc.


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

Specifications are subject to change without notice.


R
FO

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Document Revision History

N
US AL
EO
Revision Date Author Description
1.0 2012/10/29 Pan Liu Initial Version
1.1 2012/10/31 Pan Liu Add sample code

om TI
y.c N
ra IDE
em F
og ON
@ C
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 2 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Table of Contents

N
Document Revision History .................................................................................................................. 2

US AL
EO
Table of Contents ................................................................................................................................... 3
1 Introduction................................................................................................................................... 8
2 Wi-Fi STA driver Profile Default Setting ..................................................................................... 9

om TI
2.1 WLAN Profile Description ................................................................................................... 10
2.1.1 CountryRegion ................................................................................................... 10
2.1.2 CountryRegionForABand ................................................................................... 11

y.c N
2.1.3 CountryCode ...................................................................................................... 11
2.1.4 ChannelGeography ............................................................................................ 11

ra IDE
2.1.5 SSID ................................................................................................................... 11
2.1.6 NetworkType ...................................................................................................... 12
2.1.7 WirelessMode ..................................................................................................... 12
2.1.8 Channel .............................................................................................................. 12
2.1.9 BeaconPeriod ..................................................................................................... 12
em F
2.1.10 TxPower ............................................................................................................. 13
2.1.11 BGProtection ...................................................................................................... 13
og ON

2.1.12 TxPreamble ........................................................................................................ 13


2.1.13 RTSThreshold .................................................................................................... 13
2.1.14 FragThreshold .................................................................................................... 13
2.1.15 TxBurst ............................................................................................................... 13
@ C

2.1.16 PktAggregate ...................................................................................................... 14


2.1.17 WmmCapable ..................................................................................................... 14
2.1.18 AckPolicy ............................................................................................................ 14
01 K

2.1.19 AuthMode ........................................................................................................... 14


2.1.20 EncrypType ........................................................................................................ 15
02 TE

2.1.21 WPAPSK ............................................................................................................ 15


2.1.22 DefaultKeyID ...................................................................................................... 15
2.1.23 Key1Type ........................................................................................................... 15
2.1.24 Key1Str ............................................................................................................... 15
50 A

2.1.25 Key2Type ........................................................................................................... 15


2.1.26 Key2Str ............................................................................................................... 16
29 DI

2.1.27 Key3Type ........................................................................................................... 16


2.1.28 Key3Str ............................................................................................................... 16
2.1.29 Key4Type ........................................................................................................... 16
E

2.1.30 Key4Str ............................................................................................................... 16


2.1.31 PSMode .............................................................................................................. 17
FO M

2.1.32 AutoRoaming ...................................................................................................... 17


2.1.33 RoamThreshold .................................................................................................. 17
2.1.34 APSDCapable .................................................................................................... 17
2.1.35 APSDAC ............................................................................................................. 17
2.1.36 FixedTxMode ...................................................................................................... 17
R

2.1.37 HT_RDG ............................................................................................................. 18


2.1.38 HT_EXTCHA ...................................................................................................... 18
2.1.39 HT_OpMode ....................................................................................................... 18
MediaTek Confidential © 2012 MediaTek Inc. Page 3 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.40 HT_MpduDensity................................................................................................ 18
2.1.41 HT_BW ............................................................................................................... 19
2.1.42 HT_BADecline .................................................................................................... 19

N
2.1.43 HT_AutoBA ........................................................................................................ 19
2.1.44 HT_AMSDU ........................................................................................................ 19

US AL
EO
2.1.45 HT_BAWinSize ................................................................................................... 19
2.1.46 HT_GI ................................................................................................................. 20
2.1.47 HT_MCS ............................................................................................................. 20
2.1.48 HT_MIMOPSMode ............................................................................................. 20

om TI
2.1.49 HT_DisallowTKIP ............................................................................................... 20
2.1.50 HT_STBC ........................................................................................................... 20
2.1.51 IEEE80211H ....................................................................................................... 21

y.c N
2.1.52 WirelessEvent .................................................................................................... 21
2.1.53 CarrierDetect ...................................................................................................... 21

ra IDE
2.1.54 AntDiversity ........................................................................................................ 21
2.1.55 BeaconLostTime ................................................................................................ 21
2.1.56 PSP_XLINK_MODE ........................................................................................... 22
2.1.57 WscManufacturer ............................................................................................... 22
2.1.58 WscModelName ................................................................................................. 22
em F
2.1.59 WscDeviceName ................................................................................................ 22
og ON
2.1.60 WscModelNumber .............................................................................................. 22
2.1.61 WscSerialNumber .............................................................................................. 22
2.1.62 RadioOn ............................................................................................................. 23
2.1.63 Wsc4digitPinCode .............................................................................................. 23
@ C

3 Wi-Fi STA driver iwpriv command ............................................................................................ 24


3.1 Debug ................................................................................................................................. 24
3.2 DriverVersion ...................................................................................................................... 24
01 K

3.3 CountryRegion .................................................................................................................... 24


3.4 CountryRegionABand ......................................................................................................... 25
02 TE

3.5 SSID ................................................................................................................................... 25


3.6 WirelessMode ..................................................................................................................... 25
3.7 TxBurst ............................................................................................................................... 26
3.8 TxPreamble ........................................................................................................................ 26
50 A

3.9 TxPower.............................................................................................................................. 26
3.10 Channel .............................................................................................................................. 26
29 DI

3.11 BGProtection ...................................................................................................................... 26


3.12 RTSThreshold..................................................................................................................... 27
3.13 FragThreshold .................................................................................................................... 27
E

3.14 HtBw ................................................................................................................................... 27


3.15 HtMcs .................................................................................................................................. 27
FO M

3.16 HtGi ..................................................................................................................................... 27


3.17 HtOpMode .......................................................................................................................... 28
3.18 HtStbc ................................................................................................................................. 28
3.19 HtExtcha ............................................................................................................................. 28
3.20 HtMpduDensity ................................................................................................................... 28
R

3.21 HtBaWinSize....................................................................................................................... 28
3.22 HtRdg .................................................................................................................................. 29
3.23 HtAmsdu ............................................................................................................................. 29
MediaTek Confidential © 2012 MediaTek Inc. Page 4 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
3.24 HtAutoBa ............................................................................................................................ 29
3.25 HtBaDecline ........................................................................................................................ 29
3.26 HtProtect ............................................................................................................................. 29

N
3.27 HtMimoPs ........................................................................................................................... 30
3.28 HtDisallowTKIP ................................................................................................................... 30

US AL
EO
3.29 HtBssCoex .......................................................................................................................... 30
3.30 PktAggregate ...................................................................................................................... 30
3.31 WmmCapable ..................................................................................................................... 30
3.32 IEEE80211H ....................................................................................................................... 31

om TI
3.33 NetworkType....................................................................................................................... 31
3.34 AuthMode ........................................................................................................................... 31
3.35 EncrypType......................................................................................................................... 31

y.c N
3.36 DefaultKeyID....................................................................................................................... 32
3.37 Key1 .................................................................................................................................... 32

ra IDE
3.38 Key2 .................................................................................................................................... 32
3.39 Key3 .................................................................................................................................... 32
3.40 Key4 .................................................................................................................................... 32
3.41 WPAPSK ............................................................................................................................ 32
3.42 ResetCounter...................................................................................................................... 33
em F
3.43 PSMode .............................................................................................................................. 33
og ON
3.44 FixedTXMode ..................................................................................................................... 33
3.45 BeaconLostTime ................................................................................................................. 33
3.46 AutoRoaming ...................................................................................................................... 33
3.47 SiteSurvey .......................................................................................................................... 34
3.48 AutoReconnect ................................................................................................................... 34
@ C

3.49 AdhocN ............................................................................................................................... 34


4 iwpriv ra0 usage ......................................................................................................................... 35
01 K

4.1 connStatus .......................................................................................................................... 35


4.2 driverVer ............................................................................................................................. 35
02 TE

4.3 bainfo .................................................................................................................................. 35


4.4 rxbulk .................................................................................................................................. 35
4.5 txbulk .................................................................................................................................. 35
4.6 radio_off .............................................................................................................................. 35
50 A

4.7 radio_on .............................................................................................................................. 36


4.8 get_site_survey .................................................................................................................. 36
29 DI

4.9 stat ...................................................................................................................................... 36


4.10 bbp (Debug only) ................................................................................................................ 36
4.11 mac (Debug only) ............................................................................................................... 36
E

4.12 rf (Debug only) .................................................................................................................... 37


4.13 e2p (Debug only) ................................................................................................................ 37
FO M

5 iwpriv ra0 show command ........................................................................................................ 38


6 iwpriv examples .......................................................................................................................... 39
6.1 Infrastructure Security Mode .............................................................................................. 39
6.1.1 OPEN/NONE ...................................................................................................... 39
R

6.1.2 SHARED/WEP ................................................................................................... 39


6.1.3 WPAPSK/TKIP ................................................................................................... 39
6.1.4 WPAPSK/AES .................................................................................................... 39

MediaTek Confidential © 2012 MediaTek Inc. Page 5 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
6.1.5 WPA2PSK/TKIP ................................................................................................. 40
6.2 Ad-hoc mode ...................................................................................................................... 40
6.2.1 OPEN/NONE ...................................................................................................... 40

N
6.2.2 WPANONE/TKIP ................................................................................................ 40
6.3 Get Site Survey result ......................................................................................................... 40

US AL
EO
6.4 Get WLAN Statistics ........................................................................................................... 40
6.5 To Link with AP ................................................................................................................... 41
7 WPS Wi-Fi PROTECTED SETUP ............................................................................................... 42

om TI
7.1 WPS iwpriv command ........................................................................................................ 42
7.1.1 wsc_conf_mode ................................................................................................. 42
7.1.2 wsc_mode .......................................................................................................... 43

y.c N
7.1.3 wsc_pin .............................................................................................................. 43
7.1.4 wsc_ssid ............................................................................................................. 43

ra IDE
7.1.5 wsc_bssid ........................................................................................................... 43
7.1.6 wsc_start ............................................................................................................ 43
7.1.7 wsc_stop ............................................................................................................ 43
7.1.8 wsc_gen_pincode ............................................................................................... 44
7.1.9 wsc_cred_count ................................................................................................. 44
em F
7.1.10 wsc_cred_ssid .................................................................................................... 44
7.1.11 wsc_cred_auth ................................................................................................... 44
og ON

7.1.12 wsc_cred_encr ................................................................................................... 44


7.1.13 wsc_cred_keyIdx ................................................................................................ 45
7.1.14 wsc_cred_key..................................................................................................... 45
7.1.15 wsc_cred_mac ................................................................................................... 45
@ C

7.1.16 wsc_conn_by_idx ............................................................................................... 45


7.1.17 wsc_auto_conn .................................................................................................. 46
7.1.18 wsc_ap_band ..................................................................................................... 46
01 K

7.1.19 Wsc4digitPinCode .............................................................................................. 46


7.2 WPS STA as an Enrollee or Registrar ............................................................................... 46
02 TE

7.2.1 Enrollee Mode .................................................................................................... 46


7.2.2 PBC mode .......................................................................................................... 47
7.3 Registrar Mode ................................................................................................................... 47
7.3.1 PIN Mode ........................................................................................................... 47
50 A

7.3.2 PBC Mode .......................................................................................................... 48


7.4 WPS Command & OID Example ........................................................................................ 48
29 DI

7.4.1 Iwpriv command without argument .................................................................... 48


7.4.2 Iwpriv command with one INT argument............................................................ 49
7.4.3 Iwpriv command with string argument................................................................ 49
E

7.5 WPS OID Sample Program ................................................................................................ 50


8 Wi-Fi DIRECT (P2P) .................................................................................................................... 52
FO M

8.1 Wi-Fi DIRECT iwpriv Command ......................................................................................... 52


8.1.1 P2pOpMode ....................................................................................................... 52
8.1.2 p2pEnable .......................................................................................................... 53
8.1.3 p2pScan ............................................................................................................. 53
8.1.4 p2pTable ............................................................................................................ 53
R

8.1.5 p2pGoInt ............................................................................................................. 53


8.1.6 p2pDevName ..................................................................................................... 53

MediaTek Confidential © 2012 MediaTek Inc. Page 6 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
8.1.7 p2pWscMode ..................................................................................................... 53
8.1.8 p2pWscConf ....................................................................................................... 54
8.1.9 p2pLisCh ............................................................................................................ 54

N
8.1.10 p2pOpCh ............................................................................................................ 54
8.1.11 p2pLink ............................................................................................................... 54

US AL
EO
8.1.12 p2pInv ................................................................................................................. 54
8.1.13 p2pProv .............................................................................................................. 55
8.1.14 p2pCfg ................................................................................................................ 55
8.1.15 p2pStat ............................................................................................................... 55

om TI
8.1.16 p2pReset ............................................................................................................ 55
8.1.17 p2pDefConfMthd ................................................................................................ 55
8.1.18 p2pDevDisc ........................................................................................................ 55

y.c N
8.1.19 p2pLinkDown ...................................................................................................... 56
8.2 P2P Example iwpriv command ........................................................................................... 56

ra IDE
8.2.1 Configure WLAN driver as Autonomous GO ..................................................... 56
8.2.2 Configure WLAN driver as Autonomous GO start WPS PBC ............................ 56
8.2.3 Configure WLAN driver as autonomous GO start WPS PIN-Display ................ 57
8.2.4 Configure WLAN driver as autonomous GO start WPS PIN-KeyPad ............... 57
8.2.5 Configure WLAN driver as P2P device start WPS PIN-Display ......................... 58
em F
8.2.6 Configure WLAN driver as P2P device start WPS PBC .................................... 58
og ON

9 OID programming ....................................................................................................................... 60


9.1 OID Set Data ...................................................................................................................... 60
9.2 OID Get Data ...................................................................................................................... 60
9.3 OID set Raw Data with flags ............................................................................................... 60
@ C

9.4 OID Get Raw Data with Flags ............................................................................................ 65


10 IOCTL Sample Code ................................................................................................................... 70
10.1 Check connection status .................................................................................................... 70
01 K

10.2 Polling WPS status ............................................................................................................. 72


10.3 Site survey .......................................................................................................................... 73
02 TE

10.4 Display Rate and BW ......................................................................................................... 81


50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 7 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
1 Introduction

N
This document is the Software programming guide for Mediatek Wi-Fi STA driver. The Software

US AL
Programming guide covers profile setting, command list, and OID examples to demonstrate how to

EO
programming the WLAN driver.

om TI
y.c N
ra IDE
em F
og ON
@ C
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 8 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2 Wi-Fi STA driver Profile Default Setting

N
US AL
EO
#The word of "Default" must not be removed
Default
CountryRegion=5
CountryRegionABand=7
CountryCode=

om TI
ChannelGeography=1
SSID=11n-AP
NetworkType=Infra

y.c N
WirelessMode=5
Channel=0

ra IDE
BeaconPeriod=100
TxPower=100
BGProtection=0
TxPreamble=0
RTSThreshold=2347
FragThreshold=2346
em F
TxBurst=1
PktAggregate=0
og ON
WmmCapable=1
AckPolicy=0;0;0;0
AuthMode=OPEN
EncrypType=NONE
WPAPSK=
@ C

DefaultKeyID=1
Key1Type=0
Key1Str=
01 K

Key2Type=0
Key2Str=
Key3Type=0
02 TE

Key3Str=
Key4Type=0
Key4Str=
PSMode=CAM
50 A

AutoRoaming=0
RoamThreshold=70
APSDCapable=0
29 DI

APSDAC=0;0;0;0
HT_RDG=1
HT_EXTCHA=0
E

HT_OpMode=0
HT_MpduDensity=4
HT_BW=1
FO M

HT_AutoBA=1
HT_BADecline=0
HT_AMSDU=0
HT_BAWinSize=64
HT_GI=1
HT_MCS=33
R

HT_MIMOPSMode=3
HT_DisallowTKIP=1
HT_STBC=0

MediaTek Confidential © 2012 MediaTek Inc. Page 9 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
IEEE80211H=0
WirelessEvent=0
CarrierDetect=0
AntDiversity=0

N
BeaconLostTime=4
PSP_XLINK_MODE=0

US AL
EO
WscManufacturer=
WscModelName=
WscDeviceName=
WscModelNumber=

om TI
WscSerialNumber=
RadioOn=1
Wsc4digitPinCode=0

y.c N
2.1 WLAN Profile Description

ra IDE
Syntax is 'Param'='Value' and describes below.

SectionNumber Param
Value
...
...
em F
...
og ON

The WLAN driver needs to be restart, after WLAN profile has been modified.
Otherwise settings will not take any effect.

A interface down/ up could do that.


EX:
@ C

ifconfig ra0 down


ifconfig ra0 up
01 K

2.1.1 CountryRegion
Description: Country region for WLAN radio 2.4G HZ regulation.
02 TE

Value:
CountryRegion=5
50 A

Region Channels
0 1-11
29 DI

1 1-13

2 10-11
E

3 10-13

4 14
FO M

5 1-14

6 3-9

7 5-13

31 1-14
R

32 1-11 active scan, 12 and 13 passive scan

33 1-14 all active scan, 14 b mode only

MediaTek Confidential © 2012 MediaTek Inc. Page 10 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.2 CountryRegionForABand
Description: Country region for WLAN radio 5G HZ regulation.
Value:

N
CountryRegionABand=7

US AL
EO
Region Channels
0 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165

1 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140

om TI
2 36, 40, 44, 48, 52, 56, 60, 64

3 52, 56, 60, 64, 149, 153, 157, 161

y.c N
4 149, 153, 157, 161, 165

5 149, 153, 157, 161

ra IDE
6 36, 40, 44, 48

7 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165

8 52, 56, 60, 64

9 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
em F
10 36, 40, 44, 48, 149, 153, 157, 161, 165

11 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
og ON

2.1.3 CountryCode
@ C

Description: County Code for WLAN radio regulation.


Value: ( Default is empty)
CountryCode=
01 K

2 characters, like TW for Taiwan.


02 TE

Please refer to ISO3166 code list for other countries and can be found at
http://www.iso.org/iso/prods-services/iso3166ma/02iso-3166-code-
lists/country_names_and_code_elements

Note:
50 A

1. This parameter can be set from EEPRM or EFUSE.


2. EEPROM/EFUSE has higher priority than the WLAN Profile.
29 DI

2.1.4 ChannelGeography
E

Description: For Channel list builder


Value:
FO M

ChannelGeography=1
0: Outdoor
1: Indoor
2: Both
R

2.1.5 SSID
Description: The target BSSID string name
MediaTek Confidential © 2012 MediaTek Inc. Page 11 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Value:
SSID=11n-AP

N
0~z, 1~32 ASCII characters.

US AL
EO
2.1.6 NetworkType
Description: Network type
Value:

om TI
NetworkType=Infra

Infra: infrastructure mode

y.c N
Adhoc: adhoc mode

ra IDE
2.1.7 WirelessMode
Description: Wireless Mode
Value:
WirelessMode=5
em F
0: legacy 11b/g mixed
og ON

1: legacy 11B only


2: legacy 11A only
3: legacy 11a/b/g mixed
4: legacy 11G only
5: 11ABGN mixed
@ C

6: 11N only
7: 11GN mixed
8: 11AN mixed
01 K

9: 11BGN mixed
10: 11AGN mixed
11: 11N only in 5G band only
02 TE

14: 11A/AN/AC mixed 5G band only (Only 11AC chipset support)

2.1.8 Channel
50 A

Description: WLAN Radio channel (2.4G Band or 5G band)


Value:
29 DI

Channel=0

Depends on CountryRegion or CountryRegionForABand.


E

Default value = 0, the driver scan BSSID’s channel automatically.


FO M

2.1.9 BeaconPeriod
Description: Beacon period setting (It is SoftAP only)
Value:
BeaconPeriod=100
R

MediaTek Confidential © 2012 MediaTek Inc. Page 12 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.10 TxPower
Description: WLAN Radio Transmit Power setting in percentage
Value:

N
TxPower=100

US AL
EO
0~100

om TI
2.1.11 BGProtection
Description: Enable/disable WLAN 11B or 11G protection
Value:

y.c N
BGProtection=0

ra IDE
0: disable
1: enable

2.1.12 TxPreamble
em F
Description: Enable or disable Tx preamble
og ON

Value:
TxPreamble=0

0: disable
@ C

1: enable
01 K

2.1.13 RTSThreshold
Description: Set RTS Threshold
02 TE

Value:
RTSThreshold=2347
50 A

1~2347
29 DI

2.1.14 FragThreshold
Description: Set Fragment threshold
E

Value:
FragThreshold=2346
FO M

256~2346

2.1.15 TxBurst
R

Description: Enable or disable Tx burst


Value:

MediaTek Confidential © 2012 MediaTek Inc. Page 13 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
TxBurst=1

0: disable

N
1: enable

US AL
EO
2.1.16 PktAggregate
Description: Enable or disable Tx Aggregate

om TI
Value:
PktAggregate=0

y.c N
0: disable
1: enable

ra IDE
2.1.17 WmmCapable
Description: Enable or disable WMM QOS function
Value:
em F
WmmCapable=1
og ON

0: disable
1: enable
@ C

2.1.18 AckPolicy
Description: Ack policy supports normal Ack or no Ack (AC_BK, AC_BE, AC_VI, AC_VO)
01 K

Value:
AckPolicy=0;0;0;0
02 TE

0: No ack
1: normal Ack
50 A

2.1.19 AuthMode
29 DI

Description: WLAN security Authentication mode


Value:
AuthMode=OPEN
E

OPEN For open system


FO M

SHARED For shared key system


WEPAUTO Auto switch between OPEN and SHARED
WPAPSK For WPA pre-shared key (Infra)
WPA2PSK For WPA2 pre-shared key (Infra)
WPANONE For WPA pre-shared key (Adhoc)
WPA For enterprise mode (Need wpa_supplicant)
R

WPA2 For enterprise mode (Need wpa_supplicant)

MediaTek Confidential © 2012 MediaTek Inc. Page 14 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.20 EncrypType
Description: WLAN security Encryption type
Value:

N
EncrypType=NONE

US AL
EO
NONE For AuthMode=OPEN
WEP For AuthMode=OPEN or AuthMode=SHARED
TKIP For AuthMode=WPAPSK or WPA2PSK
AES For AuthMode=WPAPSK or WPA2PSK

om TI
2.1.21 WPAPSK

y.c N
Description: WLAN Security string for (TKIP/AES)
Value:

ra IDE
WPAPSK=

8~63 ASCII
Or
64 HEX characters
em F
og ON

2.1.22 DefaultKeyID
Description: Default key ID
Value:
DefaultKeyID=1
@ C

1~4
01 K

2.1.23 Key1Type
02 TE

Description: Key 1 type


Value:
Key1Type=0
50 A

0: Hexadecimal type
29 DI

1: ASCII type
E

2.1.24 Key1Str
Description: Key 1 string
FO M

Value:
Key1Str=
10 or 26 characters (key type=0)
5 or 13 characters (key type=1)
R

2.1.25 Key2Type
Description: Key 2 type
MediaTek Confidential © 2012 MediaTek Inc. Page 15 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Value:
Key2Type=0

N
0: Hexadecimal type
1: ASCII type

US AL
EO
2.1.26 Key2Str
Description: Key 2 string

om TI
Value:
Key2Str=
10 or 26 characters (key type=0)

y.c N
5 or 13 characters (key type=1)

ra IDE
2.1.27 Key3Type
Description: Key 3 type
Value:
Key3Type=0
em F
og ON

0: Hexadecimal type
1: ASCII type

2.1.28 Key3Str
@ C

Description: Key 3 string


Value:
01 K

Key3Str=
10 or 26 characters (key type=0)
5 or 13 characters (key type=1)
02 TE

2.1.29 Key4Type
50 A

Description: Key 4 type


Value:
29 DI

Key4Type=0

0: Hexadecimal type
E

1: ASCII type
FO M

2.1.30 Key4Str
Description: Key 4 string
Value:
Key4Str=
R

10 or 26 characters (key type=0)


5 or 13 characters (key type=1)

MediaTek Confidential © 2012 MediaTek Inc. Page 16 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.31 PSMode
Description: WLAN Power Saving mode
Value:

N
PSMode=CAM

US AL
EO
CAM Constantly Awake Mode
Max_PSP Max Power Saving
Fast_PSP Fast Power Saving
Legacy_PSP Legacy Power Saving

om TI
2.1.32 AutoRoaming

y.c N
Description: Enable or disable WLAN driver auto roaming between APs.
Value:

ra IDE
AutoRoaming=0

0: disable
1: enable
em F
2.1.33 RoamThreshold
og ON

Description: WLAN Roaming RSSI threshold


Value:
RoamThreshold=70
@ C

2.1.34 APSDCapable
01 K

Description: Enable or disable APSD Capable support


Value:
02 TE

APSDCapable=0

0: disable
50 A

1: enable
29 DI

2.1.35 APSDAC
Description: Enable or disable APSD access control
E

Value:
APSDAC=0;0;0;0
FO M

0: disable
1: enable

2.1.36 FixedTxMode
R

Description: Fix Transmit mode


Value:

MediaTek Confidential © 2012 MediaTek Inc. Page 17 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
FixedTxMode=ofdm

CCK

N
OFDM
HT

US AL
EO
2.1.37 HT_RDG

om TI
Description: Enable or disable HT Reverse Direction Grant
Value:
HT_RDG=1

y.c N
0: disable

ra IDE
1: enable

2.1.38 HT_EXTCHA
Description: To locate the 40MHz channel in combination with the control
em F
Value:
HT_EXTCHA=0
og ON

0: Below
1: Above
@ C

2.1.39 HT_OpMode
01 K

Description: HT operation mode


Value:
02 TE

HT_OpMode=0

0: HT mixed mode
1: HT Greenfield mode
50 A
29 DI

2.1.40 HT_MpduDensity
Description: Minimum separation of MPDUs in an A-MPDU
Value:
E

HT_MpduDensity=4
FO M

0~7
0: no restriction
1: 1/4 μs
2: 1/2 μs
3: 1 μs
4: 2 μs
R

5: 4 μs
6: 8 μs
7: 16 μs
MediaTek Confidential © 2012 MediaTek Inc. Page 18 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.41 HT_BW

N
Description: HT channel Bandwidth

US AL
Value:

EO
HT_BW=1

0: 20 MHz

om TI
1: 40 MHz

y.c N
2.1.42 HT_BADecline
Description: Enable or disable decline Block Ack to peer

ra IDE
Value:
HT_BADecline=0

0: disable
1: enable
em F
og ON

2.1.43 HT_AutoBA
Description: Enable or disable auto build Block Ack section with peer
Value:
@ C

HT_AutoBA=1

0: disable
01 K

1: enable
02 TE

2.1.44 HT_AMSDU
Description: Enable or disable AMSDU section
50 A

Value:
HT_AMSDU=0
29 DI

0: disable
1: enable
E

2.1.45 HT_BAWinSize
FO M

Description: Block Ack window size


Value:
HT_BAWinSize=64
R

1~64

MediaTek Confidential © 2012 MediaTek Inc. Page 19 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.46 HT_GI
Description: HT Guard interval support
Value:

N
HT_GI=1

US AL
EO
0: Long guard interval
1: short guard interval

om TI
2.1.47 HT_MCS

y.c N
Description: WLAN Modulation and Coding Scheme (MCS)
Value:

ra IDE
HT_MCS=33

0 ~15, 32: Fix MCS rate for HT rate.


33: Auto Rate Adaption, recommended
em F
2.1.48 HT_MIMOPSMode
og ON

Description: 802.11n SM power save mode


Value:
HT_MIMOPSMode=3
@ C

0: Static SM Power Save Mode


2: Reserved
01 K

1: Dynamic SM Power Save Mode


3: SM enabled
(not fully support yet)
02 TE

2.1.49 HT_DisallowTKIP
Description: Enable or disable 11N rate with 11N AP when cipher is TKIP or WEP
50 A

Value:
HT_DisallowTKIP=1
29 DI

0: disable
1: enable
E
FO M

2.1.50 HT_STBC
Description: Enable or disable HT STBC support
Value:
HT_STBC=0
R

0: disable
1: enable

MediaTek Confidential © 2012 MediaTek Inc. Page 20 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.51 IEEE80211H

N
Description: Enable or disable IEEE 802.11h function. Spectrum management.

US AL
This field can only be enabled in A band.

EO
Value:
IEEE80211H=0

om TI
0: disable
1: enable

y.c N
2.1.52 WirelessEvent

ra IDE
Description: Enable or disable driver to send Linux Wireless event support.
Value:
WirelessEvent=0

0: disable
em F
1: enable
og ON

2.1.53 CarrierDetect
Description: Enable or disable carrier detection
@ C

Value:
CarrierDetect=0
01 K

0: disable
1: enable
02 TE

2.1.54 AntDiversity
50 A

Description: Enable or disable antenna diversity (only 1x1 support, please confirm HW first)
Value:
29 DI

AntDiversity=0

0: disable
E

1: enable
FO M

2.1.55 BeaconLostTime
Description: Becon lost time = 4 seconds then disconnect with AP.
Value:
BeaconLostTime=4
R

1~60

MediaTek Confidential © 2012 MediaTek Inc. Page 21 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
2.1.56 PSP_XLINK_MODE
Description: Enable or disable XLINK mode
Value:

N
PSP_XLINK_MODE=0

US AL
EO
0: disable
1: enable

om TI
2.1.57 WscManufacturer
Description: WPS manufacturer string

y.c N
Value:
WscManufacturer=

ra IDE
Less than 64 characters

2.1.58 WscModelName
em F
Description: WPS Mode name string
og ON

Value:
WscModelName=

Less than 32 characters


@ C

2.1.59 WscDeviceName
01 K

Description: WPS Device name string


Value:
02 TE

WscDeviceName=

Less than 32 characters


50 A
29 DI

2.1.60 WscModelNumber
Description: WPS Device model number string
Value:
E

WscModelNumber=
FO M

Less than 32 characters

2.1.61 WscSerialNumber
Description: WPS serial number string
R

Value:
WscSerialNumber=

MediaTek Confidential © 2012 MediaTek Inc. Page 22 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Less than 32 characters

N
2.1.62 RadioOn

US AL
EO
Description: Enable or disable RF
Value:
RadioOn=1

om TI
0: disable
1: enable

y.c N
ra IDE
2.1.63 Wsc4digitPinCode
Description: WPS 4 digit pin code string
Value:
Wsc4digitPinCode=0
em F
4 digit
og ON
@ C
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 23 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
3 Wi-Fi STA driver iwpriv command

N
Syntax is iwpriv ra0 set [parameters]=[Value]

US AL
EO
Note: Execute one iwpriv/set command at a time.

om TI
3.1 Debug
Description: config WLAN driver Debug level.

y.c N
Value:
iwpriv ra0 set Debug=3

ra IDE
0~5
0: Debug Off
1: Debug Error
2: Debug Warning
em F
3: Debug Trace
4: Debug Info
og ON

5: Debug Loud

3.2 DriverVersion
Description: Check driver version by iwpriv command. (Need to enable debug mode)
@ C

Value:
iwpriv ra0 set DriverVersion=0
01 K

Any value
02 TE

3.3 CountryRegion
50 A

Description: Set Country Region


Value:
29 DI

iwpriv ra0 set CountryRegion=1

Region Channels
E

0 1-11

1 1-13
FO M

2 10-11

3 10-13

4 14

5 1-14
R

6 3-9

7 5-13

MediaTek Confidential © 2012 MediaTek Inc. Page 24 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
31 1-14

32 1-11 active scan, 12 and 13 passive scan

33 1-14 all active scan, 14 b mode only

N
US AL
EO
3.4 CountryRegionABand
Description: Set Country Region for 5G Hz WLAN regulation
Value:

om TI
iwpriv ra0 set CountryRegionABand=7

y.c N
Region Channels
0 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165

ra IDE
1 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140

2 36, 40, 44, 48, 52, 56, 60, 64

3 52, 56, 60, 64, 149, 153, 157, 161

4 149, 153, 157, 161, 165


em F
5 149, 153, 157, 161

6 36, 40, 44, 48


og ON

7 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165

8 52, 56, 60, 64

9 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
@ C

10 36, 40, 44, 48, 149, 153, 157, 161, 165

11 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
01 K

3.5 SSID
02 TE

Description: Set AP SSID


Value:
iwpriv ra0 set SSID=11n-AP
50 A

0~z, 1~32 ASCII characters


29 DI

3.6 WirelessMode
E

Description: Set WLAN mode


Value:
FO M

iwpriv ra0 set WirelessMode=5

0: legacy 11b/g mixed


1: legacy 11B only
2: legacy 11A only
R

3: legacy 11a/b/g mixed


4: legacy 11G only
5: 11ABGN mixed
6: 11N only
MediaTek Confidential © 2012 MediaTek Inc. Page 25 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7: 11GN mixed
8: 11AN mixed
9: 11BGN mixed
10: 11AGN mixed

N
11: 11N only in 5G band only
14: 11A/AN/AC mixed 5G band only (Only 11AC chipset support)

US AL
EO
3.7 TxBurst

om TI
Description: Enable or disable Tx Burst
Value:
iwpriv ra0 set TxBurst=1

y.c N
0: disable

ra IDE
1: enable

3.8 TxPreamble
Description: Enable or disable Tx Preamle
Value:
em F
iwpriv ra0 set TxPreamble=0
og ON

0: disable
1: enable
@ C

3.9 TxPower
Description: Set Transmit Power by percentage
01 K

Value:
iwpriv ra0 set TxPower=100
02 TE

0~100
50 A

3.10 Channel
29 DI

Description: Set WLAN Channel


Value:
iwpriv ra0 set Channel=6
E

Please follow 2.4G or 5G band regulation on WLAN radio channel.


FO M

3.11 BGProtection
Description: Enable or disable 11B, 11G protection
R

Value:
iwpriv ra0 set BGProtection=0

MediaTek Confidential © 2012 MediaTek Inc. Page 26 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
0: disable
1: enable

N
3.12 RTSThreshold

US AL
EO
Description: Set RTS Threshold
Value:
iwpriv ra0 set RTSThreshold=2347

om TI
1~2347

y.c N
3.13 FragThreshold

ra IDE
Description: Set Fragment threshold
Value:
iwpriv ra0 set FragThreshold=2346
em F
256~2346
og ON

3.14 HtBw
Description: Set HT WLAN Bandwidth
Value:
@ C

iwpriv ra0 set HtBw=1


01 K

0: 20 MHz
1: 40MHz
02 TE

3.15 HtMcs
Description: Set WLAN Modulation and Coding Scheme (MCS)
50 A

Value:
iwpriv ra0 set HtMcs=33
29 DI

0 ~15, 32: Fix MCS rate for HT rate.


33: Auto Rate Adaption, recommended
E
FO M

3.16 HtGi
Description: Set WLAN Guard interval support
Value:
iwpriv ra0 set HtGi=1
R

0: long guard interval


1: short guard interval

MediaTek Confidential © 2012 MediaTek Inc. Page 27 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
3.17 HtOpMode
Description: HT operation Mode

N
Value:
iwpriv ra0 set HtOpMode=0

US AL
EO
0: HT mixed mode
1: HT Greenfield mode

om TI
3.18 HtStbc

y.c N
Description: Enable or disable HT STBC
Value:

ra IDE
iwpriv ra0 set HtStbc=1

0: disable
1: enable
em F
3.19 HtExtcha
og ON

Description: To locate the 40MHz channel in combination with the control


Value:
iwpriv ra0 set HtExtcha=0
@ C

0: below
1: Above
01 K

3.20 HtMpduDensity
02 TE

Description: Minimum separation of MPDUs in an A-MPDU


Value:
iwpriv ra0 set HtMpduDensity=4
50 A

0~7
0: no restriction
29 DI

1: 1/4 μs
2: 1/2 μs
3: 1 μs
4: 2 μs
E

5: 4 μs
6: 8 μs
FO M

7: 16 μs

3.21 HtBaWinSize
Description: Block Ack window size
R

Value:
iwpriv ra0 set HtBaWinSize=64

MediaTek Confidential © 2012 MediaTek Inc. Page 28 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
1~64

N
3.22 HtRdg

US AL
EO
Description: Enable or disable HT Reverse Direction Grant
Value:
iwpriv ra0 set HtRdg=1

om TI
0: disable
1: enable

y.c N
ra IDE
3.23 HtAmsdu
Description: Enable or disable AMSDU section
Value:
Iwpriv ra0 set HtAmsdu=0
em F
0: disable
og ON

1: enable

3.24 HtAutoBa
@ C

Description: Enable or disable auto build Block Ack section with peer
Value:
01 K

iwpriv ra0 set HtAutoBa=1

0: disable
02 TE

1: enable
50 A

3.25 HtBaDecline
Description: Enable or disable decline Block Ack to peer
29 DI

Value:
iwpriv ra0 set HtBaDecline=0
E

0: disable
1: enable
FO M

3.26 HtProtect
Description: Enable or disable HT protect
R

Value:
iwpriv ra0 set HtProtect=0

MediaTek Confidential © 2012 MediaTek Inc. Page 29 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
0: disable
1: enable

N
3.27 HtMimoPs

US AL
EO
Description: Enable or disable HT MIMO Power saving mode
Value:
iwpriv ra0 set HtMimoPs=0

om TI
0: disable
1: enable

y.c N
ra IDE
3.28 HtDisallowTKIP
Description: Enable or disable 11N rate with 11N AP when cipher is TKIP or WEP
Value:
iwpriv ra0 set HtDisallowTKIP=0
em F
0: disable
og ON

1: enable

3.29 HtBssCoex
@ C

Description: Enable or disable HT BSS coexistence


Value:
01 K

iwpriv ra0 set HtBssCoex=0

0: disable
02 TE

1: enable
50 A

3.30 PktAggregate
Description: Enable or disable 11B/G packet aggregation
29 DI

Value:
iwpriv ra0 set PktAggregate=1
E

0: disable
1: enable
FO M

3.31 WmmCapable
Description: Enable or disable WMM support
R

Value:
iwpriv ra0 set WmmCapable=1

MediaTek Confidential © 2012 MediaTek Inc. Page 30 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
0: disable
1: enable

N
3.32 IEEE80211H

US AL
EO
Description: Enable or disable IEEE 802.11h function. Spectrum management.
This field can only be enabled in A band.
Value:

om TI
iwpriv ra0 set IEEE80211H=0

0: disable

y.c N
1: enable

ra IDE
3.33 NetworkType
Description: Network type
Value:
em F
iwpriv ra0 set NetworkType=Infra
og ON

Infra: infrastructure mode


Adhoc: adhoc mode

3.34 AuthMode
@ C

Description: WLAN security Authentication mode


Value:
01 K

iwpriv ra0 set AuthMode=OPEN


02 TE

OPEN For open system


SHARED For shared key system
WEPAUTO Auto switch between OPEN and SHARED
WPAPSK For WPA pre-shared key (Infra)
WPA2PSK For WPA2 pre-shared key (Infra)
50 A

WPANONE For WPA pre-shared key (Adhoc)


WPA For enterprise mode (Need wpa_supplicant)
29 DI

WPA2 For enterprise mode (Need wpa_supplicant)

3.35 EncrypType
E

Description: WLAN security Encryption type


FO M

Value:
iwpriv ra0 set EncrypType=NONE

NONE For AuthMode=OPEN


WEP For AuthMode=OPEN or AuthMode=SHARED
TKIP For AuthMode=WPAPSK or WPA2PSK
R

AES For AuthMode=WPAPSK or WPA2PSK

MediaTek Confidential © 2012 MediaTek Inc. Page 31 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
3.36 DefaultKeyID
Description: Default key ID

N
Value:
iwpriv ra0 set DefaultKeyID=1

US AL
EO
1~4

om TI
3.37 Key1
Description: Key 1 string

y.c N
Value:
iwpriv ra0 set Key1=aaaaa

ra IDE
10 or 26 characters
5 or 13 characters

3.38 Key2
em F
Description: Key 2 string
og ON

Value:
iwpriv ra0 set Key2=aaaaa

10 or 26 characters
@ C

5 or 13 characters
01 K

3.39 Key3
Description: Key 3 string
02 TE

Value:
iwpriv ra0 set Key3=aaaaa
50 A

10 or 26 characters
5 or 13 characters
29 DI

3.40 Key4
E

Description: Key 4 string


Value:
FO M

iwpriv ra0 set Key4=aaaaa

10 or 26 characters
5 or 13 characters
R

3.41 WPAPSK
Description: WLAN Security string for (TKIP/AES)
MediaTek Confidential © 2012 MediaTek Inc. Page 32 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Value:
iwpriv ra0 set WPAPSK=12345678

N
8~63 ASCII
Or

US AL
64 HEX characters

EO
3.42 ResetCounter

om TI
Description: reset WLAN statistic counter
Value:
iwpriv ra0 set ResetCounter=1

y.c N
1

3.43
ra IDE
PSMode
Description: WLAN Power Saving mode
em F
Value:
iwpriv ra0 set PSMode=CAM
og ON

CAM Constantly Awake Mode


Max_PSP Max Power Saving
Fast_PSP Fast Power Saving
Legacy_PSP Legacy Power Saving
@ C

3.44 FixedTXMode
01 K

Description: Fixed Transmit mode


02 TE

Value:
iwpriv ra0 set FixedTxMode=ofdm

CCK/cck
50 A

OFDM/ofdm
HT/ht
29 DI

3.45 BeaconLostTime
E

Description: Becon lost time = 4 seconds then disconnect with AP.


Value:
FO M

iwpriv ra0 set BeaconLostTime=4

1~60
R

3.46 AutoRoaming
Description: Enable or disable auto roaming

MediaTek Confidential © 2012 MediaTek Inc. Page 33 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Value
iwpriv ra0 set AutoRoaming=0

N
0: disable
1: enable

US AL
EO
3.47 SiteSurvey

om TI
Description: Scan with specific SSID after link up
Value:
iwpriv ra0 set SiteSurvey=XXX

y.c N
0~z, 1~32 ACSII characters

ra IDE
3.48 AutoReconnect
Description: Enable or disable auto reconnect
em F
Value:
iwpriv ra0 set AutoReconnect=0
og ON

0: disable
1: enable
@ C

3.49 AdhocN
01 K

Description: Enable or disable Adhoc to support 11N rate


Value:
iwpriv ra0 set AdhocN=1
02 TE

0: disable
1: enable
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 34 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
4 iwpriv ra0 usage

N
This section describes parameters set using iwpriv. Please refer to the Readme section for more

US AL
general data.

EO
A detailed explanation of each parameter for iwpriv is shown subsequently. Refer to the Readme
before using this section.

iwpriv ra0 [parameters]

om TI
4.1 connStatus

y.c N
Description: Show WLAN connection status

ra IDE
Value:
iwpriv ra0 connStatus

4.2 driverVer
em F
Description: Show WLAN driver version
og ON

Value:
iwpriv ra0 driverVer

4.3 bainfo
@ C

Description: Show Block Ack information


Value:
01 K

iwpriv ra0 bainfo


02 TE

4.4 rxbulk
Description: Show STA current rxbluk information
50 A

Value:
iwpriv ra0 rxbulk
29 DI

4.5 txbulk
E

Description: Show STA current txbluk information


FO M

Value:
iwpriv ra0 txbulk

4.6 radio_off
R

Description: Turn off Radio


Value:

MediaTek Confidential © 2012 MediaTek Inc. Page 35 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
iwpriv ra0 radio_off

N
4.7 radio_on

US AL
Description: Turn on Radio

EO
Value:
iwpriv ra0 radio_on

om TI
4.8 get_site_survey

y.c N
Description: get site survey result
Value:

ra IDE
iwpriv ra0 get_site_survey

4.9 stat
Description: Display WLAN static counter
em F
Value:
iwpriv ra0 stat
og ON

4.10 bbp (Debug only)


@ C

Description: Display/Write bbp content


Value:
//Display
01 K

iwpriv ra0 bbp offset


02 TE

//Write bbp
iwpriv ra0 bbp offset=value

offset = hex address


50 A

value= hex value


29 DI

4.11 mac (Debug only)


Description: Display/Write mac content
E

Value:
//Display
FO M

iwpriv ra0 mac offset

//Write mac
iwpriv ra0 mac offset=value
R

offset = hex address


value= hex value

MediaTek Confidential © 2012 MediaTek Inc. Page 36 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
4.12 rf (Debug only)
Description: Display/Write rf content

N
Value:
//Display

US AL
EO
iwpriv ra0 rf offset

//Write
iwpriv ra0 rf offset=value

om TI
offset = hex address
value= hex value

y.c N
ra IDE
4.13 e2p (Debug only)
Description: Display/Write EEPROM content
Value:
//Display
em F
iwpriv ra0 e2p offset
og ON

//Write EEPROM
iwpriv ra0 e2p offset=value

offset = hex address


@ C

value= hex value


01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 37 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
5 iwpriv ra0 show command

N
This section describes parameters set using iwpriv. Please refer to the Readme section for more

US AL
general data.

EO
Display parameter which has been currently configured in the WLAN driver.

iwpriv ra0 show [parameters]

om TI
[Parameters list]
SSID
WirelessMode

y.c N
TxBurst
TxPreamble

ra IDE
TxPower
Channel
BGProtection
RTSThreshold
FragThreshold
em F
HtBw
og ON

HtMcs
HtGi
HtOpMode
HtExtcha
HtMpduDensity
@ C

HtBaWinSize
HtRdg
01 K

HtAmsdu
HtAutoBa
CountryRegion
02 TE

CountryRegionABand
CountryCode
PktAggregate
50 A

WmmCapable
IEEE80211H
29 DI

NetworkType
WpsApBand
AuthMode
E

EncrypType
DefaultKeyID
FO M

Key1
Key2
Key3
Key4
WPAPSK
R

Example: show SSID

MediaTek Confidential © 2012 MediaTek Inc. Page 38 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
6 iwpriv examples

N
6.1 Infrastructure Security Mode

US AL
EO
WLAN infrastructure Security mode to connect with AP by iwpriv command.
Command sequence must be exact.

om TI
6.1.1 OPEN/NONE
Config STA to link with AP which is OPEN/NONE(Authentication/Encryption)
AP’s SSID string= XXXX

y.c N
iwpriv ra0 set NetworkType=Infra

ra IDE
iwpriv ra0 set AuthMode=OPEN
iwpriv ra0 set EncrypType=NONE
iwpriv ra0 set SSID=”XXXXX”

6.1.2 SHARED/WEP
em F
Config STA to link with AP which is SHARED/WEP(Authentication/Encryption)
AP’s SSID string= XXXX, WEP key=12345
og ON

iwpriv ra0 set NetworkType=Infra


iwpriv ra0 set AuthMode=SHARED
iwpriv ra0 set EncrypType=WEP
iwpriv ra0 set DefaultKeyID=1
iwpriv ra0 set Key1=”12345”
@ C

iwpriv ra0 set SSID=”XXXX”


01 K

6.1.3 WPAPSK/TKIP
02 TE

Config STA to link with AP which is WPAPSK/TKIP(Authentication/Encryption)


AP’s SSID string= XXXX, WPAPSK=12345678

iwpriv ra0 set NetworkType=Infra


50 A

iwpriv ra0 set AuthMode=WPAPSK


iwpriv ra0 set EncrypType=TKIP
iwpriv ra0 set SSID=”XXXX”
29 DI

iwpriv ra0 set WPAPSK=12345678


iwpriv ra0 set SSID="XXXX”
E

6.1.4 WPAPSK/AES
FO M

Config STA to link with AP which is WPAPSK/AES(Authentication/Encryption)


AP’s SSID string= XXXX, WPAPSK=12345678

iwpriv ra0 set NetworkType=Infra


iwpriv ra0 set AuthMode=WPAPSK
iwpriv ra0 set EncrypType=AES
R

iwpriv ra0 set SSID=”XXXX”


iwpriv ra0 set WPAPSK=12345678
iwpriv ra0 set SSID="XXXX”

MediaTek Confidential © 2012 MediaTek Inc. Page 39 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
6.1.5 WPA2PSK/TKIP
Config STA to link with AP which is WPA2PSK/TKIP(Authentication/Encryption)
AP’s SSID string= XXXX, WPAPSK=12345678

N
iwpriv ra0 set NetworkType=Infra

US AL
EO
iwpriv ra0 set AuthMode=WPA2PSK
iwpriv ra0 set EncrypType=TKIP
iwpriv ra0 set SSID=”XXXX”
iwpriv ra0 set WPAPSK=12345678
iwpriv ra0 set SSID="XXXX”

om TI
6.2 Ad-hoc mode

y.c N
WLAN adhoc Security mode to connect with Peer by iwpriv command.

ra IDE
Command sequence must be exact.

6.2.1 OPEN/NONE
Config STA to create/link as adhoc mode, which is OPEN/NONE(Authentication/Encryption)
SSID=XXXX
em F
iwpriv ra0 set NetworkType=Adhoc
og ON

iwpriv ra0 set AuthMode=OPEN


iwpriv ra0 set EncrypType=NONE
iwpriv ra0 set SSID=XXXX
@ C

6.2.2 WPANONE/TKIP
Config STA to create/link as adhoc mode, which is WPANONE/TKIP(Authentication/Encryption)
01 K

SSID=XXXX, WPAPSK=12345678

iwpriv ra0 set NetworkType=Adhoc


02 TE

iwpriv ra0 set AuthMode=WPANONE


iwpriv ra0 set EncrypType=TKIP
iwpriv ra0 set SSID="XXXX”
iwpriv ra0 set WPAPSK=12345678
50 A

iwpriv ra0 set SSID="XXXX"


29 DI

6.3 Get Site Survey result


//Issue a scan to the WLAN driver
E

iwlist ra0 sc
FO M

//display site survey result


iwpriv ra0 get_site_survey

6.4 Get WLAN Statistics


R

iwpriv ra0 stat

MediaTek Confidential © 2012 MediaTek Inc. Page 40 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
//Reset WLAN Statistic counter
iwpriv ra0 set ResetCounter=0

N
6.5 To Link with AP

US AL
iwpriv ra0 set SSID=”AP’s SSID” //Specific AP

EO
or

om TI
iwpriv ra0 set SSID=”” //Any SSID with OPEN/NONE security

y.c N
ra IDE
em F
og ON
@ C
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 41 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7 WPS Wi-Fi PROTECTED SETUP

N
Simple Config Architectural Overview

US AL
This section presents a high-level description of the Simple Config architecture. Much of the material

EO
is taken directly from the Simple Config specification.
Figure 1 depicts the major components and their interfaces as defined by Wi-Fi Simple Config Spec.
There are three logical components involved: the Registrar, the access point (AP), and the Enrollee.

om TI
The Enrollee is a device seeking to join a WLAN domain. Once an Enrollee obtains a valid
credential, it becomes a member.

y.c N
A Registrar is an entity with the authority to issue and revoke domain credentials. A registrar can
be integrated into an AP.

ra IDE
The AP can be either a WLAN AP or a wireless router.
em F
og ON

Registration initiation is ordinarily accomplished by a user action such as powering up the Enrollee
and, optionally, running a setup wizard on the Registrar (PC).
@ C

Note: The WLAN driver needs to set HAS_WSC=y in order to enable WPS functions.
01 K

7.1 WPS iwpriv command


02 TE

This section describes parameters set using iwpriv. Please refer to the Readme section for more
general data.

iwpriv ra0 [commands]=[Value]


50 A

Note: Wireless extension private handlers.


29 DI

7.1.1 wsc_conf_mode
E

Description: set WPS conf mode


Value:
FO M

iwpriv ra0 wsc_conf_mode 1

0: WPS Disabled
1: Enrollee
2: Registrar
R

MediaTek Confidential © 2012 MediaTek Inc. Page 42 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7.1.2 wsc_mode
Description: WPS mode, PBC or PIN
Value:

N
iwpriv ra0 wsc_mode 1

US AL
EO
1: PIN Mode
2: PBC Mode

om TI
7.1.3 wsc_pin
Description: set WPS pin code

y.c N
Value:
iwpriv ra0 wsc_pin xxxxxxxx

ra IDE
xxxxxxx = {00000000 ~ 99999999}

7.1.4 wsc_ssid
em F
Description: set WPS AP SSID
og ON

Value:
iwpriv ra0 wsc_ssid xxxxxxx

0~z, 1~32 ASCII characters


@ C

7.1.5 wsc_bssid
01 K

Description: set BSSID of WSC AP that STA wants to do WPS with


Value:
02 TE

iwpriv ra0 wsc_bssid xx:xx:xx:xx:xx:xx

xx:xx:xx:xx:xx:xx BSSID
50 A
29 DI

7.1.6 wsc_start
Description: Trigger WLAN driver to do WPS process
Value:
E

iwpriv ra0 wsc_start


FO M

7.1.7 wsc_stop
Description: Stop WLAN driver to do WPS process
Value:
iwpriv ra0 wsc_stop
R

MediaTek Confidential © 2012 MediaTek Inc. Page 43 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7.1.8 wsc_gen_pincode
Description: Generate new PIN code for WPS usage
Value:

N
iwpriv ra0 wsc_gen_pincode

US AL
EO
7.1.9 wsc_cred_count
Description: Set count of WPS credential, only support one credential for M8 in Registrar mode.
Value:

om TI
iwpriv ra0 wsc_cred_count 1

1~8

y.c N
ra IDE
7.1.10 wsc_cred_ssid
Description: Set SSID into credtentail[idx].
Value:
iwpriv ra0 wsc_cred_ssid “idx ssid_str”
em F
idx: 0 ~ 7
og ON

ssid_str: 0~z, 1~32 ascii characters

Example:
iwpriv ra0 wsc_cred_ssid "0 wps_ap1"
@ C

7.1.11 wsc_cred_auth
01 K

Description: Set AuthMode into credtentail[idx].


Value:
02 TE

iwpriv ra0 wsc_cred_auth “idx auth_str”


idx: 0 ~ 7
auth_str: OPEN, WPAPSK, WPA2PSK, SHARED, WPA, WPA2
50 A

Example:
iwpriv ra0 wsc_cred_auth "0 WPAPSK"
29 DI

7.1.12 wsc_cred_encr
E

Description: Set EncrypType into credtentail[idx].


Value:
FO M

iwpriv ra0 wsc_cred_encr “idx encr_str”

idx: 0 ~ 7
encr_str: NONE, WEP, TKIP, AES
R

Example:
iwpriv ra0 wsc_cred_encr "0 TKIP"

MediaTek Confidential © 2012 MediaTek Inc. Page 44 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7.1.13 wsc_cred_keyIdx
Description: Set Key Index into credtentail[idx].
Value:

N
iwpriv ra0 wsc_cred_keyid “idx key_index”

US AL
EO
idx: 0 ~ 7
key_index: 1 ~ 4

Example:

om TI
iwpriv ra0 wsc_cred_keyIdx "0 1"

y.c N
7.1.14 wsc_cred_key

ra IDE
Description: Set Key into credtentail[idx].
Value:
iwpriv ra0 wsc_cred_key “idx key”

idx: 0 ~ 7
key: ASCII string (wep_key_len(=5,13), passphrase_len(=8~63))
em F
OR
Hex string (wep_key_len(=10,26), passphrase_len(=64))
og ON

Example:
iwpriv ra0 wsc_cred_key "0 12345678" ;; Passphrase
iwpriv ra0 wsc_cred_key "0 abcd" ;; WEP Key
@ C

7.1.15 wsc_cred_mac
01 K

Description: Set AP's MAC into credtentail[idx].


Value:
02 TE

iwpriv ra0 wsc_cred_mac “idx mac_str”

idx: 0 ~ 7
mac_str: xx:xx:xx:xx:xx:xx
50 A

Example:
29 DI

iwpriv ra0 wsc_cred_mac "0 00:11:22:33:44:55"


E

7.1.16 wsc_conn_by_idx
FO M

Description: Connect AP by credential index.


Value:
iwpriv ra0 wsc_conn_by_idx 0

0~7
R

MediaTek Confidential © 2012 MediaTek Inc. Page 45 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7.1.17 wsc_auto_conn
Description: If the registration is successful, driver will re-connect to AP or not.
Value:

N
iwpriv ra0 wsc_auto_conn 1

US AL
EO
0: disabled, driver won't re-connect to AP with new configurations.
1: enabled, driver will re-connect to AP with new configurations.

om TI
7.1.18 wsc_ap_band
Description: Setting prefer band to do WPS with dual band WPS AP.

y.c N
Value:
iwpriv ra0 wsc_ap_band 2

ra IDE
0: Prefer 2.4G
1: Prefer 5G
2: Auto (default)
em F
7.1.19 Wsc4digitPinCode
og ON

Description: Generate WPS 4-digits PIN


Value:
iwpriv ra0 Wsc4digitPinCode 1
@ C

0: disable
1: enable
01 K

7.2 WPS STA as an Enrollee or Registrar


02 TE

7.2.1 Enrollee Mode

7.2.1.1 PIN mode


50 A

Running Scenarios (case 'a' and 'b')


29 DI

a. Adding an Enrollee to AP+Registrar (EAP)


[AP+Registrar]<----EAP--->[Enrollee Client]
E

b. Adding an Enrollee with external Registrar (UPnP/EAP)


[External Registrar]<----UPnP--->[AP_Proxy]<---EAP--->[Enrollee Client]
FO M

Note: 'EAP' indicates to use wireless medium and 'UPnP' indicates to use wired or wireless
medium.

(i) [Registrar] or [AP+Registrar]

Enter the Enrollee PinCode on the Registrar and start WPS on the Registrar.
R

Note: How to get the Enrollee PinCode? Use 'iwpriv ra0 stat' on the Enrollee.

(ii) [Linux WPS STA]


MediaTek Confidential © 2012 MediaTek Inc. Page 46 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
iwpriv ra0 wsc_conf_mode 1 ;; Enrollee
iwpriv ra0 wsc_mode 1 ;; PIN
iwpriv ra0 wsc_ssid "AP's SSID"

N
iwpriv ra0 wsc_start

US AL
EO
(iii) If the registration is successful, the Enrollee will be re-configured with the new
parameters, and will connect to the AP with these new parameters.

7.2.2 PBC mode

om TI
Running Scenarios (case 'a' only)

y.c N
a. Adding an Enrollee to AP+Registrar (EAP)
[AP+Registrar]<----EAP--->[Client]

ra IDE
(i) [AP+Registrar]

Start PBC on the Registrar.

(ii) [Linux WPS STA]


em F
iwpriv ra0 wsc_conf_mode 1 ;; Enrollee
iwpriv ra0 wsc_mode 2 ;; PBC
og ON

iwpriv ra0 wsc_start

(iii) If the registration is successful, the Enrollee will be re-configured with the new
parameters, and will connect to the AP with these new parameters.
@ C

7.3 Registrar Mode


01 K

7.3.1 PIN Mode


02 TE

Running Scenarios (case 'a' and 'b')

a. Configure the un-configured AP


[Unconfigured AP]<----EAP--->[Registrar]
50 A

b. Configure the configured AP


Configured AP]<----EAP--->[Registrar]
29 DI

(i) [AP]
Start PIN on the Enrollee WPS AP.

(ii) [Linux WPS STA]


E

iwpriv ra0 wsc_conf_mode 2 ;; Registrar


FO M

iwpriv ra0 wsc_mode 1 ;; PIN


iwpriv ra0 wsc_pin xxxxxxxx ;; AP's PIN Code
iwpriv ra0 wsc_ssid "AP's SSID"
iwpriv ra0 wsc_start

(iii) If the registration is successful;


R

In case 'a':
The Registrar will be re-configured with the new parameters, and will connect to the AP with
these new parameters;
MediaTek Confidential © 2012 MediaTek Inc. Page 47 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
In case 'b':
The Registrar will be re-configured with AP's configurations, and will connect to the AP with
these new parameters.

N
US AL
7.3.2 PBC Mode

EO
Running Scenarios (case 'a' and 'b')
a. Configure the un-configured AP
[Unconfigured AP]<----EAP--->[Registrar]

om TI
b. Configure the configured AP
Configured AP]<----EAP--->[Registrar]

y.c N
(i) [AP]

ra IDE
Start PBC on the Enrollee WPS AP.

(ii) [Linux WPS STA]

iwpriv ra0 wsc_conf_mode 2 ;; Registrar


iwpriv ra0 wsc_mode 2 ;; PBC
iwpriv ra0 wsc_start
em F
(iii) If the registration is successful;
og ON

In case 'a':
The Registrar will be re-configured with the new parameters, and will connect to the AP with
these new parameters;
@ C

In case 'b':
The Registrar will be re-configured with AP's configurations, and will connect to the AP with
these new parameters.
01 K
02 TE

7.4 WPS Command & OID Example

7.4.1 Iwpriv command without argument


50 A

iwpriv command:
29 DI

iwpriv ra0 wsc_start


iwpriv ra0 wsc_stop
iwpriv ra0 wsc_gen_pincode
E

OID:
FO M

Example:
memset(&lwreq, 0, sizeof(lwreq));
sprintf(lwreq.ifr_name, "ra0", 3);
iwreq.u.mode = WSC_STOP;
/* Perform the private ioctl */
if(ioctl(skfd, RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM, &lwreq) < 0)
R

{
fprintf(stderr, "Interface doesn't accept private ioctl...\n");

MediaTek Confidential © 2012 MediaTek Inc. Page 48 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
7.4.2 Iwpriv command with one INT argument
iwpriv command:

N
iwpriv ra0 wsc_cred_count 1

US AL
EO
iwpriv ra0 wsc_conn_by_idx 1
iwpriv ra0 wsc_auto_conn 1
iwpriv ra0 wsc_conf_mode 1
iwpriv ra0 wsc_mode 1
iwpriv ra0 wsc_pin 12345678

om TI
OID:

y.c N
Example:

ra IDE
memset(&lwreq, 0, sizeof(lwreq));
lwreq.u.data.length = 1;
cred_count = 1;
((int *) buffer)[i] = (int) cred_count;
offset = sizeof(int);
sprintf(lwreq.ifr_name, "ra0", 3);
lwreq.u.mode = WSC_CREDENTIAL_COUNT;
em F
memcpy(lwreq.u.name + offset, buffer, IFNAMSIZ - offset);
/* Perform the private ioctl */
og ON

if(ioctl(skfd, RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM, &lwreq) < 0)


{
fprintf(stderr, "Interface doesn't accept private ioctl...\n");
return -1;
}
@ C

7.4.3 Iwpriv command with string argument


01 K

iwpriv command:
02 TE

iwpriv ra0 wsc_ssid “0 xxxxx”


iwpriv ra0 wsc_cred_ssid “0 xxxxx”
iwpriv ra0 wsc_cred_auth “0 WPAPSK”
iwpriv ra0 wsc_cred_encr “0 TKIP”
50 A

iwpriv ra0 wsc_cred_keyIdx “0 1”


iwpriv ra0 wsc_cred_key “0 12345”
29 DI

iwpriv ra0 wsc_cred_mac “0 00:11:22:33:44:55”

OID:
E

Example:
FO M

memset(&lwreq, 0, sizeof(lwreq));
memset(buffer, 0, 2048);
sprintf(lwreq.ifr_name, "ra0", 3);
sprintf(buffer, "0 wps_ssid_1");
lwreq.u.data.length = strlen(buffer) + 1;
lwreq.u.data.pointer = (caddr_t) buffer;
R

lwreq.u.data.flags = WSC_CREDENTIAL_SSID;
/* Perform the private ioctl */
if(ioctl(skfd, RTPRIV_IOCTL_SET_WSC_PROFILE_STRING_ITEM, &lwreq) < 0)
{

MediaTek Confidential © 2012 MediaTek Inc. Page 49 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
fprintf(stderr, "Interface doesn't accept private ioctl...\n");
return -1;
}

N
7.5 WPS OID Sample Program

US AL
EO
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

om TI
#include <assert.h>
#include <netinet/in.h> /* for sockaddr_in */
#include <fcntl.h>
#include <time.h>
#include <sys/times.h>

y.c N
#include <unistd.h>
#include <sys/socket.h> /* for connect and socket*/
#include <sys/stat.h>

ra IDE
#include <err.h>
#include <errno.h>
#include <asm/types.h>
#include </usr/include/linux/wireless.h>
#include <sys/ioctl.h>

#define IFNAMSIZ 16
em F
#define RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM (SIOCIWFIRSTPRIV + 0x14)
#define RTPRIV_IOCTL_SET_WSC_PROFILE_STRING_ITEM (SIOCIWFIRSTPRIV + 0x16)
og ON

enum {
WSC_CREDENTIAL_COUNT = 1,
WSC_CREDENTIAL_SSID = 2,
WSC_CREDENTIAL_AUTH_MODE = 3,
WSC_CREDENTIAL_ENCR_TYPE = 4,
WSC_CREDENTIAL_KEY_INDEX = 5,
@ C

WSC_CREDENTIAL_KEY = 6,
WSC_CREDENTIAL_MAC = 7,
WSC_SET_DRIVER_CONNECT_BY_CREDENTIAL_IDX = 8,
WSC_SET_DRIVER_AUTO_CONNECT = 9,
01 K

WSC_SET_CONF_MODE = 10, // Enrollee or Registrar


WSC_SET_MODE = 11, // PIN or PBC
WSC_SET_PIN = 12,
02 TE

WSC_SET_SSID = 13,
WSC_START = 14,
WSC_STOP = 15,
WSC_GEN_PIN_CODE = 16,
};
50 A

int main()
{
struct iwreq lwreq;
29 DI

char buffer[2048] = {0};


int cred_count;
int offset = 0; /* Space for sub-ioctl index */
int skfd, i = 0; /* generic raw socket desc. */
E

skfd = socket(AF_INET, SOCK_DGRAM, 0);


if (skfd < 0)
return -1;
FO M

//////////// WSC_STOP ////////////


memset(&lwreq, 0, sizeof(lwreq));
sprintf(lwreq.ifr_name, "ra0", 3);
lwreq.u.mode = WSC_STOP;

/* Perform the private ioctl */


if(ioctl(skfd, RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM, &lwreq) < 0)
R

{
fprintf(stderr, "Interface doesn't accept private ioctl...\n");
return -1;
}
///////////////////////////////////
MediaTek Confidential © 2012 MediaTek Inc. Page 50 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
/////// WSC_CREDENTIAL_COUNT ///////
memset(&lwreq, 0, sizeof(lwreq));
lwreq.u.data.length = 1;
cred_count = 1;

N
((int *) buffer)[i] = (int) cred_count;
offset = sizeof(int);

US AL
EO
sprintf(lwreq.ifr_name, "ra0", 3);
lwreq.u.mode = WSC_CREDENTIAL_COUNT;
memcpy(lwreq.u.name + offset, buffer, IFNAMSIZ - offset);

/* Perform the private ioctl */


if(ioctl(skfd, RTPRIV_IOCTL_SET_WSC_PROFILE_U32_ITEM, &lwreq) < 0)

om TI
{
fprintf(stderr, "Interface doesn't accept private ioctl...\n");
return -1;
}

y.c N
///////////////////////////////////

/////// WSC_CREDENTIAL_SSID ///////

ra IDE
memset(&lwreq, 0, sizeof(lwreq));
memset(buffer, 0, 2048);
sprintf(lwreq.ifr_name, "ra0", 3);
sprintf(buffer, "0 wps_ssid_1");
lwreq.u.data.length = strlen(buffer) + 1;
lwreq.u.data.pointer = (caddr_t) buffer;
lwreq.u.data.flags = WSC_CREDENTIAL_SSID;
em F
/* Perform the private ioctl */
if(ioctl(skfd, RTPRIV_IOCTL_SET_WSC_PROFILE_STRING_ITEM, &lwreq) < 0)
{
og ON

fprintf(stderr, "Interface doesn't accept private ioctl...\n");


return -1;
}
///////////////////////////////////

close(skfd);
@ C

return 0;
}
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 51 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
8 Wi-Fi DIRECT (P2P)

N
Wifi direct feature makes direct connections to one another quickly and conveniently to do things like print,

US AL
EO
sync, and share content even when an access point or router is unavailable.

om TI
y.c N
ra IDE
em F
og ON
@ C
01 K

8.1 Wi-Fi DIRECT iwpriv Command


02 TE

P2P interface name: p2p0


Syntax is iwpriv p2p0 set [parameters]=[Value]
50 A

Note: Execute one iwpriv/set command at a time.


29 DI

8.1.1 P2pOpMode
Description: Set P2P Operation Mode
E

Value:
iwpriv p2p0 set P2pOpMode=1
FO M

0: Device mode
1: Autonomous GO
R

MediaTek Confidential © 2012 MediaTek Inc. Page 52 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
8.1.2 p2pEnable
Description: Enable or disable P2P
Value:

N
iwpriv p2p0 set p2pEnable=1

US AL
EO
0: disable
1: enable

om TI
8.1.3 p2pScan
Description: Start P2P scanning
Value:

y.c N
iwpriv p2p0 set p2pScan=1

ra IDE
0:disable
1:enable

8.1.4 p2pTable
em F
Description: Display p2p scan table in WLAN driver log.
og ON

Value:
iwpriv p2p0 set p2pTable=1

0: disable
@ C

1: enable
01 K

8.1.5 p2pGoInt
Description: set P2P GO intent value
02 TE

Value:
iwpriv p2p0 set p2pGoInt=0
50 A

0~15
29 DI

8.1.6 p2pDevName
Description: set p2p device name
E

Value:
iwpriv p2p0 set p2pDevName=Direct-P2P0
FO M

0~Z, less than 32 characters.

8.1.7 p2pWscMode
R

Description: Set WPS mode for P2P negotiate


Value:

MediaTek Confidential © 2012 MediaTek Inc. Page 53 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
iwpriv p2p0 set p2pWscMode=2

1: PIN

N
2: PBC

US AL
EO
8.1.8 p2pWscConf
Description: Set WPS conf method for P2P negotiate

om TI
Value:
iwpriv p2p0 set p2pWscConf=1

y.c N
1: Display
2: KeyPad

ra IDE
3: PBC

8.1.9 p2pLisCh
Description: Set P2P listen Channel
em F
Value:
iwpriv p2p0 set p2pLisCh=1
og ON

1,6,11
@ C

8.1.10 p2pOpCh
Description: Set P2P Operation Channel
01 K

Value:
Depending on country region setting.
02 TE

iwpriv p2p0 set p2pOpCh=1


50 A

8.1.11 p2pLink
Description: Set P2P device ID to do GO negotiation
29 DI

Value:
iwpriv p2p0 set p2pLink=1
E

0~29
FO M

8.1.12 p2pInv
Description: Select P2P device ID to Invite
Value:
R

iwpriv p2p0 set p2pInv=1

0~29

MediaTek Confidential © 2012 MediaTek Inc. Page 54 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
8.1.13 p2pProv

N
Description: Select P2P device ID to provision

US AL
Value:

EO
iwpriv p2p0 set p2pProv=1

0~29

om TI
8.1.14 p2pCfg

y.c N
Description: Dump out P2P configuration
Value:

ra IDE
iwpriv p2p0 set p2pCfg=1

1
em F
8.1.15 p2pStat
og ON

Description: Dump out P2P status


Value:
iwpriv p2p0 set p2pStat=1
@ C

1
01 K

8.1.16 p2pReset
Description: Reset P2P configuration
02 TE

Value:
iwpriv p2p0 set p2pReset=1
50 A

1
29 DI

8.1.17 p2pDefConfMthd
Description: Set default WPS Config Method to Provision
E

Value:
iwpriv p2p0 set p2pDefConfMthd=3
FO M

1: Display
2: KeyPad
3: PBC
R

8.1.18 p2pDevDisc
Description: Select P2P Device ID for discovery
MediaTek Confidential © 2012 MediaTek Inc. Page 55 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
Value:
iwpriv p2p0 set p2pDevDisc=1

N
0~29

US AL
EO
8.1.19 p2pLinkDown

om TI
Description: Disconnect P2P session and turn back to listen state
Value:
iwpriv p2p0 set p2pLinkDown=1

y.c N
1

ra IDE
8.2 P2P Example iwpriv command

8.2.1 Configure WLAN driver as Autonomous GO


em F
Enable Autonomous on channel 11 with WPA2PSK/AES key:12345678, SSID=aaapp
og ON

# interface init
ifconfig p2p0 down
ifconfig ra0 down
ifconfig ra0 up
iwpriv ra0 set Debug=3
@ C

ifconfig p2p0 up
01 K

# p2p init
iwpriv p2p0 set p2pLinkDown=1
02 TE

iwpriv p2p0 set p2pReset=1

iwpriv p2p0 set p2pOpCh=11


iwpriv p2p0 set P2pOpMode=1
50 A

iwpriv p2p0 set SSID=aaapp


iwpriv p2p0 set AuthMode=WPA2PSK
29 DI

iwpriv p2p0 set EncrypType=AES


iwpriv p2p0 set WPAPSK=12345678
iwpriv p2p0 set SSID=aaapp
E

#set p2p ip address


FO M

ifconfig p2p0 10.10.10.6

8.2.2 Configure WLAN driver as Autonomous GO start WPS PBC


# interface init
R

ifconfig p2p0 down


ifconfig ra0 down
ifconfig ra0 up
MediaTek Confidential © 2012 MediaTek Inc. Page 56 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
iwpriv ra0 set Debug=3
ifconfig p2p0 up

N
# p2p init
iwpriv p2p0 set p2pLinkDown=1

US AL
EO
iwpriv p2p0 set p2pReset=1

# p2p PBC Go WPS


iwpriv p2p0 set p2pWscMode=2

om TI
iwpriv p2p0 set p2pWscConf=3
iwpriv p2p0 set p2pGoInt=15

y.c N
# p2p scan and link
iwpriv p2p0 set p2pScan=1

ra IDE
sleep 25
iwpriv p2p0 set p2pLink=0

# set p2p ip
ifconfig p2p0 10.10.10.6
em F
og ON

8.2.3 Configure WLAN driver as autonomous GO start WPS PIN-Display


# interface init
ifconfig p2p0 down
@ C

ifconfig ra0 down


ifconfig ra0 up
iwpriv ra0 set Debug=3
01 K

ifconfig p2p0 up
02 TE

# p2p init
iwpriv p2p0 set p2pLinkDown=1
iwpriv p2p0 set p2pReset=1
50 A

# p2p display WPS


iwpriv p2p0 set p2pWscConf=1
29 DI

iwpriv p2p0 set p2pGoInt=0


iwpriv p2p0 set p2pScan=1
E

# set p2p ip
ifconfig p2p0 10.10.10.222
FO M

8.2.4 Configure WLAN driver as autonomous GO start WPS PIN-KeyPad

# interface init
R

ifconfig p2p0 down


ifconfig ra0 down

MediaTek Confidential © 2012 MediaTek Inc. Page 57 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
ifconfig ra0 up
iwpriv ra0 set Debug=3
ifconfig p2p0 up

N
# p2p init

US AL
EO
iwpriv p2p0 set p2pLinkDown=1
iwpriv p2p0 set p2pReset=1

# p2p keypad WPS

om TI
iwpriv p2p0 set p2pWscConf=2
iwpriv p2p0 set p2pGoInt=15
iwpriv p2p0 set p2pEnterPIN=32240979 #Read enrollee PIN code

y.c N
# p2p scan and link

ra IDE
iwpriv p2p0 set p2pScan=1
sleep 25
iwpriv p2p0 set p2pLink=0

# set p2p ip
em F
ifconfig p2p0 10.10.10.6
og ON

8.2.5 Configure WLAN driver as P2P device start WPS PIN-Display


@ C

# interface init
ifconfig p2p0 down
ifconfig ra0 down
01 K

ifconfig ra0 up
iwpriv ra0 set Debug=3
02 TE

ifconfig p2p0 up

# p2p init
iwpriv p2p0 set p2pLinkDown=1
50 A

iwpriv p2p0 set p2pReset=1


29 DI

# p2p keypad WPS


iwpriv p2p0 set p2pWscConf=2
iwpriv p2p0 set p2pGoInt=15
E

iwpriv p2p0 set p2pScan=1


FO M

# waiting....Win7 (GO)
# Check Win7 PIN code and Set PIN
iwpriv p2p0 set p2pEnterPIN=32240979
R

8.2.6 Configure WLAN driver as P2P device start WPS PBC


# interface init

MediaTek Confidential © 2012 MediaTek Inc. Page 58 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
ifconfig p2p0 down
ifconfig ra0 down
ifconfig ra0 up

N
iwpriv ra0 set Debug=3
ifconfig p2p0 up

US AL
EO
# p2p init
iwpriv p2p0 set p2pLinkDown=1
iwpriv p2p0 set p2pReset=1

om TI
# p2p PBC dev WPS
iwpriv p2p0 set p2pWscMode=2

y.c N
iwpriv p2p0 set p2pWscConf=3
iwpriv p2p0 set p2pGoInt=0

ra IDE
iwpriv p2p0 set p2pScan=1

# set p2p ip
ifconfig p2p0 10.10.10.22
em F
og ON
@ C
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 59 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
9 OID programming

N
Please refer to WLAN driver source code include/oid.h for OID data structure.

US AL
EO
9.1 OID Set Data

om TI
Command and IOCTL Function
Set Data

y.c N
Function Type Command IOCTL
RTPRIV_IOCTL_SET Iwpriv ra0 set sprintf(name, "ra0");
SSID=RT3572AP strcpy(data, "SSID=RT3572AP”);

ra IDE
strcpy(wrq.ifr_name, name);
wrq.u.data.length = strlen(data);
wrq.u.data.pointer = data;
wrq.u.data.flags = 0;
ioctl(socket_id, RTPRIV_IOCTL_SET, &wrq);
em F
9.2 OID Get Data
og ON

Command and IOCTL Function


Get Data
Function Type Command IOCTL
@ C

RTPRIV_IOCTL_STATISTICS Iwpriv ra0 stat sprintf(name, "ra0");


strcpy(data, "stat”);
strcpy(wrq.ifr_name, name);
wrq.u.data.length = strlen(data);
01 K

wrq.u.data.pointer = data;
wrq.u.data.flags = 0;
ioctl(socket_id, RTPRIV_IOCTL_STATISTICS,
&wrq);
02 TE

RTPRIV_IOCTL_GSITESURVEY Iwpriv ra0 sprintf(name, "ra0");


get_site_survey strcpy(data, "get_site_survey”);
strcpy(wrq.ifr_name, name);
wrq.u.data.length = strlen(data);
wrq.u.data.pointer = data;
50 A

wrq.u.data.flags = 0;
ioctl(socket_id,
RTPRIV_IOCTL_GSITESURVEY, &wrq);
29 DI

9.3 OID set Raw Data with flags


E

IOCTL Function
FO M

Set Raw Data by I/O Control Interface with Flags


Function Type IOCTL
RT_OID_802_11_COUNTRY_REGION sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(UCHAR));
wrq.u.data.length = sizeof(UCHAR);
R

wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_COUNTRY_REGION;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_BSSID_LIST_SCAN sprintf(name, "ra0");

MediaTek Confidential © 2012 MediaTek Inc. Page 60 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
strcpy(wrq.ifr_name, name);
wrq.u.data.length = 0;
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_BSSID_LIST_SCAN;

N
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_SSID sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);

US AL
EO
memset(data, 0, sizeof(NDIS_802_11_SSID));
wrq.u.data.length = sizeof(NDIS_802_11_SSID);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_SSID;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

om TI
OID_802_11_BSSID sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_MAC_ADDRESS));
wrq.u.data.length = sizeof(NDIS_802_11_MAC_ADDRESS);
wrq.u.data.pointer = data;

y.c N
wrq.u.data.flags = OID_802_11_BSSID;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_RADIO sprintf(name, "ra0");

ra IDE
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(BOOLEAN));
wrq.u.data.length = sizeof(BOOLEAN);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_RADIO;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_PHY_MODE sprintf(name, "ra0");
em F
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RT_802_11_PHY_MODE));
wrq.u.data.length = sizeof(RT_802_11_PHY_MODE);
og ON

wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_PHY_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_STA_CONFIG sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RT_802_11_STA_CONFIG));
@ C

wrq.u.data.length = sizeof(RT_802_11_STA_CONFIG);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_STA_CONFIG;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
01 K

OID_802_11_DESIRED_RATES sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_RATES));
02 TE

wrq.u.data.length = sizeof(NDIS_802_11_RATES);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_DESIRED_RATES;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_PREAMBLE sprintf(name, "ra0");
50 A

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RT_802_11_PREAMBLE));
wrq.u.data.length = sizeof(RT_802_11_PREAMBLE);
29 DI

wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_PREAMBLE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_WEP_STATUS printf(name, "ra0");
strcpy(wrq.ifr_name, name);
E

memset(data, 0, sizeof(NDIS_802_11_WEP_STATUS));
wrq.u.data.length = sizeof(NDIS_802_11_WEP_STATUS);
wrq.u.data.pointer = data;
FO M

wrq.u.data.flags = OID_802_11_WEP_STATUS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_AUTHENTICATION_MODE printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0,
sizeof(NDIS_802_11_AUTHENTICATION_MODE));
wrq.u.data.length =
R

sizeof(NDIS_802_11_AUTHENTICATION_MODE);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_AUTHENTICATION_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

MediaTek Confidential © 2012 MediaTek Inc. Page 61 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
OID_802_11_INFRASTRUCTURE_MODE printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0,
sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE));

N
wrq.u.data.length =
sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE);
wrq.u.data.pointer = data;

US AL
wrq.u.data.flags = OID_802_11_INFRASTRUCTURE_MODE;

EO
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_REMOVE_WEP printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_KEY_INDEX));
wrq.u.data.length = sizeof(NDIS_802_11_KEY_INDEX);

om TI
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_REMOVE_WEP;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_RESET_COUNTERS printf(name, "ra0");

y.c N
strcpy(wrq.ifr_name, name);
wrq.u.data.length = 0;
wrq.u.data.pointer = data;

ra IDE
wrq.u.data.flags = RT_OID_802_11_RESET_COUNTERS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_RTS_THRESHOLD printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_RTS_THRESHOLD));
wrq.u.data.length = sizeof(NDIS_802_11_RTS_THRESHOLD);
wrq.u.data.pointer = data;
em F
wrq.u.data.flags = OID_802_11_RTS_THRESHOLD;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_FRAGMENTATION_THRESHOLD printf(name, "ra0");
og ON

strcpy(wrq.ifr_name, name);
memset(data, 0,
sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD));
wrq.u.data.length =
sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD);
wrq.u.data.pointer = data;
@ C

wrq.u.data.flags =
OID_802_11_FRAGMENTATION_THRESHOLD;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_POWER_MODE printf(name, "ra0");
01 K

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_POWER_MODE));
wrq.u.data.length = sizeof(NDIS_802_11_POWER_MODE);
02 TE

wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_POWER_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_TX_POWER_LEVEL printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_TX_POWER_LEVEL));
50 A

wrq.u.data.length = sizeof(NDIS_802_11_TX_POWER_LEVEL);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_TX_POWER_LEVEL;
29 DI

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


RT_OID_802_11_TX_POWER_LEVEL_1 printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
E

wrq.u.data.length = sizeof(ULONG);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_TX_POWER_LEVEL_1;
FO M

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


OID_802_11_NETWORK_TYPE_IN_USE printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_NETWORK_TYPE));
wrq.u.data.length = / sizeof(NDIS_802_11_NETWORK_TYPE);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_NETWORK_TYPE_IN_USE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
R

OID_802_11_RX_ANTENNA_SELECTED printf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_ANTENNA));

MediaTek Confidential © 2012 MediaTek Inc. Page 62 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
wrq.u.data.length = sizeof(NDIS_802_11_ANTENNA);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_RX_ANTENNA_SELECTED;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

N
OID_802_11_TX_ANTENNA_SELECTED printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_ANTENNA));

US AL
EO
wrq.u.data.length = sizeof(NDIS_802_11_ANTENNA);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_TX_ANTENNA_SELECTED;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_ADD_WPA printf(name, "ra0");

om TI
strcpy(wrq.ifr_name, name);
memset(data, 0, 32);
wrq.u.data.length = 32;
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_ADD_WPA;

y.c N
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_REMOVE_KEY printf(name, "ra0");
strcpy(wrq.ifr_name, name);

ra IDE
memset(data, 0, sizeof(NDIS_802_11_REMOVE_KEY));
wrq.u.data.length = sizeof(NDIS_802_11_REMOVE_KEY);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_REMOVE_KEY;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_ADD_KEY printf(name, "ra0");
strcpy(wrq.ifr_name, name);
em F
memset(data, 0, keylength); //5,10,13,26
wrq.u.data.length = keylength L;
wrq.u.data.pointer = data;
og ON

wrq.u.data.flags = OID_802_11_ADD_KEY;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_SET_IEEE8021X printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(BOOLEAN));
wrq.u.data.length = sizeof(BOOLEAN);
@ C

wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_SET_IEEE8021X;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
01 K

OID_802_11_SET_IEEE8021X_REQUIRE_KEY printf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(BOOLEAN));
wrq.u.data.length = sizeof(BOOLEAN);
02 TE

wrq.u.data.pointer = data;
wrq.u.data.flags =
OID_802_11_SET_IEEE8021X_REQUIRE_KEY;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_ADD_WEP printf(name, "ra0");
50 A

strcpy(wrq.ifr_name, name);
memset(data, 0, keylength); //5,10,13,26
wrq.u.data.length = keylength;
29 DI

wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_RADIO;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_CONFIGURATION printf(name, "ra0");
strcpy(wrq.ifr_name, name);
E

memset(data, 0, sizeof(NDIS_802_11_CONFIGURATION));
wrq.u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
wrq.u.data.pointer = data;
FO M

wrq.u.data.flags = OID_802_11_CONFIGURATION;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_SET_COUNTERMEASURES printf(name, "ra0");
strcpy(wrq.ifr_name, name);
wrq.u.data.length = 0;
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_SET_COUNTERMEASURES;
R

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


OID_802_11_DISASSOCIATE printf(name, "ra0");
strcpy(wrq.ifr_name, name);
wrq.u.data.length = 0;

MediaTek Confidential © 2012 MediaTek Inc. Page 63 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_DISASSOCIATE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_PMKID printf(name, "ra0");

N
strcpy(wrq.ifr_name, name);
wrq.u.data.length = keylength; //follow your setting
wrq.u.data.pointer = data;

US AL
EO
wrq.u.data.flags = OID_802_11_PMKID;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_WPA_SUPPLICANT_SUPPORT printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(BOOLEAN));

om TI
wrq.u.data.length = sizeof(BOOLEAN);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_WPA_SUPPLICANT_SUPPORT;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

y.c N
RT_OID_WPA_SUPPLICANT_SUPPORT printf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);

ra IDE
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_WPA_SUPPLICANT_SUPPORT;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_SET_DEL_MAC_ENTRY sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0xdd, 6);
strcpy(wrq.ifr_name, name);
em F
wrq.u.data.length = 6;
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_SET_DEL_MAC_ENTRY;
og ON

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

RT_OID_802_11_SET_HT_PHYMODE | typedef struct {


OID_GET_SET_TOGGLE RT_802_11_PHY_MODE PhyMode;
UCHAR TransmitNo;
@ C

UCHAR HtMode; //HTMODE_GF or HTMODE_MM


UCHAR ExtOffset; //extension channel above or
below
UCHAR MCS;
01 K

UCHAR BW;
UCHAR STBC;
UCHAR SHORTGI;
UCHAR rsv;
02 TE

} OID_SET_HT_PHYMODE ;

RT_802_11_PHY_MODE tmp_ht_mode;
sprintf(wrq.ifr_name, "ra0");
wrq.u.data.pointer = (caddr_t) & tmp_ht_mode;
wrq.u.data.length = sizeof(RT_802_11_PHY_MODE);
50 A

wrq.u.data.flags = RT_OID_802_11_SET_HT_PHYMODE |
OID_GET_SET_TOGGLE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
29 DI

IOCTL Function
E

Set Raw Data by I/O Control Interface with Flags


Function Type IOCTL
FO M

RT_OID_802_11_SET_HT_PHYMODE | typedef struct {


OID_GET_SET_TOGGLE RT_802_11_PHY_MODE PhyMode;
UCHAR TransmitNo;
UCHAR HtMode; //HTMODE_GF or
HTMODE_MM
UCHAR ExtOffset; //extension channel above or
below
UCHAR MCS;
R

UCHAR BW;
UCHAR STBC;
UCHAR SHORTGI;
UCHAR rsv;

MediaTek Confidential © 2012 MediaTek Inc. Page 64 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
} OID_SET_HT_PHYMODE ;

RT_802_11_PHY_MODE tmp_ht_mode;
sprintf(wrq.ifr_name, "ra0");

N
wrq.u.data.pointer = (caddr_t) & tmp_ht_mode;
wrq.u.data.length = sizeof(RT_802_11_PHY_MODE);
wrq.u.data.flags = RT_OID_802_11_SET_HT_PHYMODE |

US AL
OID_GET_SET_TOGGLE;

EO
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

9.4 OID Get Raw Data with Flags

om TI
IOCTL Function

y.c N
Get Raw Data by I/O Control Interface with Flags
Function Type IOCTL

ra IDE
RT_OID_DEVICE_NAME sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, 255);
wrq.u.data.length = 255;
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_DEVICE_NAME;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
em F
RT_OID_VERSION_INFO sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RT_VERSION_INFO));
og ON

wrq.u.data.length = sizeof(RT_VERSION_INFO);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_VERSION_INFO;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_BSSID_LIST sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
@ C

memset(data, 0, BssLen);
wrq.u.data.length = BssLen;
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_BSSID_LIST;
01 K

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


OID_802_3_CURRENT_ADDRESS sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
02 TE

memset(data, 0, sizeof(CurrentAddress));
wrq.u.data.length = sizeof(CurrentAddress);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_3_CURRENT_ADDRESS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_GEN_MEDIA_CONNECT_STATUS sprintf(name, "ra0");
50 A

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_MEDIA_STATE));
wrq.u.data.length = sizeof(NDIS_MEDIA_STATE);
29 DI

wrq.u.data.pointer = data;
wrq.u.data.flags = OID_GEN_MEDIA_CONNECT_STATUS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_BSSID sprintf(name, "ra0");
E

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_MAC_ADDRESS));
wrq.u.data.length = sizeof(NDIS_802_11_MAC_ADDRESS);
FO M

wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_BSSID;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_SSID sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_SSID));
wrq.u.data.length = sizeof(NDIS_802_11_SSID);
wrq.u.data.pointer = data;
R

wrq.u.data.flags = OID_802_11_SSID;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_QUERY_LINK_STATUS sprintf(name, "ra0");

MediaTek Confidential © 2012 MediaTek Inc. Page 65 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RT_802_11_LINK_STATUS));
wrq.u.data.length = sizeof(RT_802_11_LINK_STATUS);
wrq.u.data.pointer = data;

N
wrq.u.data.flags = RT_OID_802_11_QUERY_LINK_STATUS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_CONFIGURATION sprintf(name, "ra0");

US AL
EO
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(NDIS_802_11_CONFIGURATION));
wrq.u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_CONFIGURATION;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

om TI
OID_802_11_RSSI_TRIGGER sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ulInfo));
wrq.u.data.length = sizeof(ulInfo);

y.c N
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_RSSI_TRIGGER;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

ra IDE
RT_OID_802_11_RSSI sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ulInfo));
wrq.u.data.length = sizeof(ulInfo);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_RSSI;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
em F
RT_OID_802_11_RSSI_1 sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ulInfo));
og ON

wrq.u.data.length = sizeof(ulInfo);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_RSSI_1;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_RSSI_2 sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
@ C

memset(data, 0, sizeof(ulInfo));
wrq.u.data.length = sizeof(ulInfo);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_RSSI_2;
01 K

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


OID_802_11_STATISTICS sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
02 TE

memset(data, 0, sizeof(NDIS_802_11_STATISTICS));
wrq.u.data.length = sizeof(NDIS_802_11_STATISTICS);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_STATISTICS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
50 A

OID_GEN_RCV_OK sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ulInfo));
29 DI

wrq.u.data.length = sizeof(ulInfo);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_GEN_RCV_OK;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_GEN_RCV_NO_BUFFER sprintf(name, "ra0");
E

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ulInfo));
wrq.u.data.length = sizeof(ulInfo);
FO M

wrq.u.data.pointer = data;
wrq.u.data.flags = OID_GEN_RCV_NO_BUFFER;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_PHY_MODE typedef enum _RT_802_11_PHY_MODE {
PHY_11BG_MIXED = 0,
PHY_11B,
PHY_11A,
R

PHY_11ABG_MIXED,
PHY_11G,
PHY_11ABGN_MIXED, // both band 5
PHY_11N, // 6

MediaTek Confidential © 2012 MediaTek Inc. Page 66 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
PHY_11GN_MIXED, // 2.4G band 7
PHY_11AN_MIXED, // 5G band 8
PHY_11BGN_MIXED, // if check 802.11b. 9
PHY_11AGN_MIXED, // if check 802.11b. 10

N
} RT_802_11_PHY_MODE

sprintf(name, "ra0");

US AL
strcpy(wrq.ifr_name, name);

EO
memset(data, 0, sizeof(ulInfo));
wrq.u.data.length = sizeof(ulInfo);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_PHY_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

om TI
RT_OID_802_11_STA_CONFIG sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RT_802_11_STA_CONFIG));
wrq.u.data.length = sizeof(RT_802_11_STA_CONFIG);

y.c N
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_STA_CONFIG;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

ra IDE
OID_802_11_RTS_THRESHOLD sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RtsThresh));
wrq.u.data.length = sizeof(RtsThresh);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_RTS_THRESHOLD;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
em F
OID_802_11_FRAGMENTATION_THRESHOLD sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(FragThresh));
og ON

wrq.u.data.length = sizeof(FragThresh);
wrq.u.data.pointer = data;
wrq.u.data.flags =
OID_802_11_FRAGMENTATION_THRESHOLD;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_POWER_MODE sprintf(name, "ra0");
@ C

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(PowerMode));
wrq.u.data.length = sizeof(PowerMode);
wrq.u.data.pointer = data;
01 K

wrq.u.data.flags = OID_802_11_POWER_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_802_11_RADIO sprintf(name, "ra0");
02 TE

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(RadioState));
wrq.u.data.length = sizeof(RadioState);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_RADIO;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
50 A

OID_802_11_INFRASTRUCTURE_MODE sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(BssType));
29 DI

wrq.u.data.length = sizeof(BssType);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_INFRASTRUCTURE_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
E

RT_OID_802_11_PREAMBLE sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(PreamType));
FO M

wrq.u.data.length = sizeof(PreamType);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_PREAMBLE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_AUTHENTICATION_MODE sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(AuthMode));
wrq.u.data.length = sizeof(AuthMode);
R

wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_AUTHENTICATION_MODE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

MediaTek Confidential © 2012 MediaTek Inc. Page 67 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
OID_802_11_WEP_STATUS sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(WepStatus));
wrq.u.data.length = sizeof(WepStatus);

N
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_WEP_STATUS;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

US AL
EO
OID_802_11_TX_POWER_LEVEL sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_TX_POWER_LEVEL;

om TI
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_TX_POWER_LEVEL_1 sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));

y.c N
wrq.u.data.length = sizeof(ULONG);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_TX_POWER_LEVEL_1;

ra IDE
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_NETWORK_TYPES_SUPPORTED sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, 16);
wrq.u.data.length = 16;
wrq.u.data.pointer = data;
wrq.u.data.flags =
em F
OID_802_11_NETWORK_TYPES_SUPPORTED;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
OID_802_11_NETWORK_TYPE_IN_USE sprintf(name, "ra0");
og ON

strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_802_11_NETWORK_TYPE_IN_USE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
@ C

RT_OID_802_11_QUERY_EEPROM_VERSION sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);
01 K

wrq.u.data.pointer = data;
wrq.u.data.flags =
RT_OID_802_11_QUERY_EEPROM_VERSION;
02 TE

ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


RT_OID_802_11_QUERY_FIRMWARE_VERSION sprintf(name, "ra0");
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);
wrq.u.data.pointer = data;
50 A

wrq.u.data.flags =
RT_OID_802_11_QUERY_FIRMWARE_VERSION;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
29 DI

RT_OID_802_11_QUERY_NOISE_LEVEL sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(UCHAR));
wrq.u.data.length = sizeof(UCHAR);
E

wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_QUERY_NOISE_LEVEL;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
FO M

RT_OID_802_11_EXTRA_INFO sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_EXTRA_INFO;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
R

RT_OID_802_11_QUERY_PIDVID sprintf(name, "ra0");


strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(ULONG));
wrq.u.data.length = sizeof(ULONG);

MediaTek Confidential © 2012 MediaTek Inc. Page 68 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_802_11_QUERY_PIDVID;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
RT_OID_WE_VERSION_COMPILED sprintf(name, "ra0");

N
strcpy(wrq.ifr_name, name);
memset(data, 0, sizeof(UINT));
wrq.u.data.length = sizeof(UINT);

US AL
EO
wrq.u.data.pointer = data;
wrq.u.data.flags = RT_OID_WE_VERSION_COMPILED;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

RT_OID_802_11_QUERY_LAST_TX_RATE HTTRANSMIT_SETTING tmpHT;

om TI
sprintf(wrq.ifr_name, "ra0");
wrq.u.data.pointer = (caddr_t) & tmpHT;
wrq.u.data.flags = RT_OID_802_11_QUERY_LAST_TX_RATE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);

y.c N
RT_OID_802_11_QUERY_LAST_RX_RATE HTTRANSMIT_SETTING tmpHT;
sprintf(wrq.ifr_name, "ra0");
wrq.u.data.pointer = (caddr_t) & tmpHT;

ra IDE
wrq.u.data.flags = RT_OID_802_11_QUERY_LAST_RX_RATE;
ioctl(socket_id, RT_PRIV_IOCTL, &wrq);
SHOW_CONN_STATUS u_char buffer[IW_PRIV_SIZE_MASK];
sprintf(wrq.ifr_name, "ra0");
wrq.u.data.pointer = (caddr_t) buffer;
wrq.u.data.flags = SHOW_CONN_STATUS;
ioctl(socket_id, RTPRIV_IOCTL_SHOW, &wrq);
em F
og ON
@ C
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 69 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
10 IOCTL Sample Code

N
10.1 Check connection status

US AL
EO
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>

om TI
#include <sys/ioctl.h>
#include <unistd.h> /* for close */
#include <linux/wireless.h>
//=============================================================================

y.c N
#if WIRELESS_EXT <= 11
#ifndef SIOCDEVPRIVATE

ra IDE
#define SIOCDEVPRIVATE 0x8BE0
#endif
#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
#endif
//SET/GET CONVENTION :
// * ------------------
em F
// * Simplistic summary :
// * o even numbered ioctls are SET, restricted to root, and should not
og ON
// * return arguments (get_args = 0).
// * o odd numbered ioctls are GET, authorised to anybody, and should
// * not expect any arguments (set_args = 0).
//
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E)
//---------------------------------------------------------
@ C

// IEEE 802.11 OIDs


#define OID_GEN_MEDIA_CONNECT_STATUS 0x060B
//---------------------------------------------------------
01 K

#ifndef TRUE
#define TRUE 1
#endif
02 TE

#ifndef FALSE
#define FALSE 0
#endif
50 A

#define PACKED __attribute__ ((packed))


typedef unsigned int NDIS_MEDIA_STATE;
#define NdisMediaStateConnected 1
29 DI

#define NdisMediaStateDisconnected 0
//=============================================================================
int main( int argc, char ** argv )
{
E

#define DATA_BUFFER_SIZE 8192


char name[25];
FO M

int socket_id;
struct iwreq wrq;
int ret = 1, cmd = 0;
char *base;//, *base1;
char *data;
// open socket based on address family: AF_NET ----------------------------
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
R

if(socket_id < 0)
{
printf("\nrtuser::error::Open socket error!\n\n");

MediaTek Confidential © 2012 MediaTek Inc. Page 70 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
return -1;
}
data = malloc(DATA_BUFFER_SIZE);
if (data == NULL)

N
{
printf("unable to alloc data buffer, size (%d)\n", DATA_BUFFER_SIZE);

US AL
EO
return -1;
}
// set interface name as "ra0" --------------------------------------------
sprintf(name, "ra0");
memset(data, 0, DATA_BUFFER_SIZE);

om TI
//
//example of ioctl function ==========================================
//
base = argv[1];

y.c N
//base1 = argv[2];
if(argc != 2)

ra IDE
goto rtuser_exit;
if(strstr(base, "OID_GEN_MEDIA_CONNECT_STATUS"))
cmd = OID_GEN_MEDIA_CONNECT_STATUS;
switch(cmd)
{
em F
case OID_GEN_MEDIA_CONNECT_STATUS:
{
// Get media connect status
og ON

printf("\nrtuser::set OID_GEN_MEDIA_CONNECT_STATUS \n\n");


strcpy(wrq.ifr_name, name);
wrq.u.data.length = sizeof(NDIS_MEDIA_STATE);;
wrq.u.data.pointer = data;
wrq.u.data.flags = OID_GEN_MEDIA_CONNECT_STATUS;
@ C

ret = ioctl(socket_id, RT_PRIV_IOCTL, &wrq);


if(ret != 0)
{
01 K

printf("\nrtuser::error::media connect status\n\n");


goto rtuser_exit;
}
02 TE

printf("Media connect status=%u\n\n", (NDIS_MEDIA_STATE)(*data));


if ( (NDIS_MEDIA_STATE)(*data) == NdisMediaStateConnected )
printf("NdisMediaStateConnected\n");
else
printf("NdisMediaStateDisconnected");
50 A

}
break;
29 DI

default:
printf("\nUnsupported OID type\n");
break;
}
E

rtuser_exit:
if(socket_id >= 0)
FO M

close(socket_id);
if (data != NULL)
free(data);
if(ret)
return ret;
else
return 0;
R

}// endof main()

MediaTek Confidential © 2012 MediaTek Inc. Page 71 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
10.2 Polling WPS status
#include <stdio.h>
#include <stdlib.h>

N
#include <string.h>
#include <netinet/in.h> /* for sockaddr_in */

US AL
EO
#include <fcntl.h>
#include <time.h>
#include <sys/times.h>
#include <unistd.h>
#include <sys/socket.h>

om TI
#include <sys/stat.h>
#include <err.h>
#include <errno.h>

y.c N
#include <asm/types.h>

#define IFNAMSIZ 16

ra IDE
#include </usr/include/linux/wireless.h>
#include <sys/ioctl.h>

#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x01) // copy from raconfig.h


#define RT_OID_WSC_QUERY_STATUS 0x0751 // copy from webui src
typedef int WSC_STATE;
em F
#define DBGPRINT printf
WSC_STATE rt_oid_get_wsc_status(char *ifname, int skfd){
og ON

struct iwreq wrq;


int data;
memset(&wrq, 0, sizeof(wrq));
strcpy(wrq.ifr_ifrn.ifrn_name, ifname);
wrq.u.data.length = sizeof(int);
@ C

wrq.u.data.pointer = &data;
wrq.u.data.flags = RT_OID_WSC_QUERY_STATUS ;
ioctl(skfd, RT_PRIV_IOCTL ,&wrq);
DBGPRINT("wsc query status = %d \n", data);
01 K

return data;
}
02 TE

int main(int argc, char *argv[])


{
unsigned num_sec = 0;
int skfd;
50 A

skfd = socket(AF_INET, SOCK_DGRAM, 0);


if (skfd < 0)
29 DI

return -1;
if (argc < 2)
{
printf("Usage: %s <# secs to poll wps status> \n", argv[0]);
E

return 1;
}
FO M

num_sec = atoi(argv[1]);
while (num_sec-- > 0)
{
rt_oid_get_wsc_status("ra0", skfd);
sleep(1);
}
return 0;
R

MediaTek Confidential © 2012 MediaTek Inc. Page 72 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
10.3 Site survey
#include <stdio.h>
#include <string.h>

N
#include <errno.h>
#include <sys/socket.h>

US AL
EO
#include <sys/ioctl.h>
#include <unistd.h> /* for close */
#include <linux/wireless.h>

#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E)

om TI
#define OID_GET_SET_TOGGLE 0x8000
#define OID_802_11_BSSID_LIST_SCAN (0x0508 | OID_GET_SET_TOGGLE)
#define OID_802_11_BSSID_LIST 0x0609

y.c N
#define PACKED __attribute__ ((packed))

//security

ra IDE
#define WPS_OUI_TYPE 0x04F25000
#define WPS_PDID 0x1210
#define WPA_OUI_TYPE 0x01F25000
#define WPA_OUI 0x00F25000
#define WPA2_OUI 0x00AC0F00
#define CISCO_OUI 0x00964000
em F
//===============
og ON

#define NDIS_802_11_LENGTH_SSID 32
#define NDIS_802_11_LENGTH_RATES_EX 16
#define NDIS_802_11_LENGTH_RATES 8

typedef long NDIS_802_11_RSSI; // in dBm


@ C

typedef unsigned char NDIS_802_11_MAC_ADDRESS[6];


typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; // Set of 16 data rates
typedef unsigned char NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; // Set of 8 data rates
01 K

typedef struct PACKED _NDIS_802_11_FIXED_IEs


{
unsigned char Timestamp[8];
02 TE

unsigned short BeaconInterval;


unsigned short Capabilities;
} NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
50 A

typedef struct _NDIS_802_11_VARIABLE_IEs


{
unsigned char ElementID;
29 DI

unsigned char Length; // Number of bytes in data field


unsigned char data[1];
} NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
E

typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE


{
FO M

Ndis802_11IBSS,
Ndis802_11Infrastructure,
Ndis802_11AutoUnknown,
Ndis802_11Monitor,
Ndis802_11InfrastructureMax // Not a real value, defined as upper bound
} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
R

typedef struct _NDIS_802_11_CONFIGURATION_FH


{
unsigned long Length; // Length of structure

MediaTek Confidential © 2012 MediaTek Inc. Page 73 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
unsigned long HopPattern; // As defined by 802.11, MSB set
unsigned long HopSet; // to one if non-802.11
unsigned long DwellTime; // units are Kusec
} NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;

N
typedef struct _NDIS_802_11_CONFIGURATION

US AL
EO
{
unsigned long Length; // Length of structure
unsigned long BeaconPeriod; // units are Kusec
unsigned long ATIMWindow; // units are Kusec
unsigned long DSConfig; // Frequency, units are kHz

om TI
NDIS_802_11_CONFIGURATION_FH FHConfig;
} NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;

y.c N
typedef enum _NDIS_802_11_NETWORK_TYPE
{

ra IDE
Ndis802_11FH,
Ndis802_11DS,
Ndis802_11OFDM5,
Ndis802_11OFDM5_N,
Ndis802_11OFDM24,
Ndis802_11OFDM24_N,
em F
Ndis802_11Automode,
Ndis802_11NetworkTypeMax // not a real type, defined as an upper bound
} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
og ON

typedef struct PACKED


{
unsigned int SsidLength; // length of SSID field below, in bytes;
// this can be zero.
@ C

unsigned char Ssid[NDIS_802_11_LENGTH_SSID]; // SSID information field


} NDIS_802_11_SSID, *PNDIS_802_11_SSID;
01 K

typedef struct PACKED


{
02 TE

unsigned long Length; // Length of this structure


NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
unsigned char Reserved[2];
NDIS_802_11_SSID Ssid; // SSID
unsigned int Privacy; // WEP encryption requirement
50 A

NDIS_802_11_RSSI Rssi; // receive signal


NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
29 DI

NDIS_802_11_CONFIGURATION Configuration;
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
NDIS_802_11_RATES_EX SupportedRates;
unsigned long IELength;
E

unsigned char IEs[1];


} NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
FO M

typedef struct PACKED _NDIS_WLAN_BSSID


{
unsigned long Length; // Length of this structure
NDIS_802_11_MAC_ADDRESS MacAddress; // BSSID
unsigned char Reserved[2];
NDIS_802_11_SSID Ssid; // SSID
R

unsigned long Privacy; // WEP encryption requirement


NDIS_802_11_RSSI Rssi; // receive signal strength in dBm
NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;

MediaTek Confidential © 2012 MediaTek Inc. Page 74 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
NDIS_802_11_CONFIGURATION Configuration;
NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
NDIS_802_11_RATES SupportedRates;
} NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;

N
typedef struct PACKED

US AL
EO
{
unsigned int NumberOfItems; // in list below, at least 1
NDIS_WLAN_BSSID_EX Bssid[1];
} NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
//===============

om TI
void checkSecurity(PNDIS_WLAN_BSSID_EX pBssid){

y.c N
// work with NDIS_WLAN_BSSID_EX

ra IDE
int bTKIP = 0;
int bAESWRAP = 0;
int bAESCCMP = 0;
int bWPA = 0;
int bWPAPSK = 0;
int bWPANONE = 0;
em F
int bWPA2 = 0;
int bWPA2PSK = 0;
int bWPA2NONE = 0;
og ON

int bCCKM = 0; // CCKM for Cisco

char strAuth[32] = "";


char strEncry[32] = "";
@ C

if ((pBssid->Length > sizeof(NDIS_WLAN_BSSID)) && (pBssid->IELength > sizeof(NDIS_802_11_FIXED_IEs))){


unsigned int lIELoc = 0;
PNDIS_802_11_FIXED_IEs pFixIE = (PNDIS_802_11_FIXED_IEs)pBssid->IEs;
01 K

PNDIS_802_11_VARIABLE_IEs pVarIE =
(PNDIS_802_11_VARIABLE_IEs)((char*)pFixIE + sizeof(NDIS_802_11_FIXED_IEs));
lIELoc += sizeof(NDIS_802_11_FIXED_IEs);
02 TE

while (pBssid->IELength > (lIELoc + sizeof(NDIS_802_11_VARIABLE_IEs)))


{
if ((pVarIE->ElementID == 221) && (pVarIE->Length >= 16))
{
50 A

//unsigned int* pOUI = (unsigned int*)((char*)pVarIE + 2);


unsigned int* pOUI = (unsigned int*)((char*)pVarIE->data);
29 DI

if(*pOUI != WPA_OUI_TYPE)
{
lIELoc += pVarIE->Length;
lIELoc += 2;
E

pVarIE =
(PNDIS_802_11_VARIABLE_IEs)((char*)pVarIE + pVarIE->Length + 2);
FO M

if(pVarIE->Length <= 0)
break;
continue;
}
unsigned int* plGroupKey;
unsigned short* pdPairKeyCount;
R

unsigned int* plPairwiseKey=NULL;


unsigned int* plAuthenKey=NULL;
unsigned short* pdAuthenKeyCount;

MediaTek Confidential © 2012 MediaTek Inc. Page 75 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
plGroupKey = (unsigned int*)((char*)pVarIE + 8);

unsigned int lGroupKey = *plGroupKey & 0x00ffffff;


if (lGroupKey == WPA_OUI)

N
{
lGroupKey = (*plGroupKey & 0xff000000) >> 0x18;

US AL
EO
if (lGroupKey == 2)
bTKIP = 1;
else if (lGroupKey == 3)
bAESWRAP = 1;
else if (lGroupKey == 4)

om TI
bAESCCMP = 1;
}
else
{

y.c N
lIELoc += pVarIE->Length;
lIELoc += 2;

ra IDE
pVarIE =
(PNDIS_802_11_VARIABLE_IEs)((char*)pVarIE + pVarIE->Length + 2);

if(pVarIE->Length <= 0)
break;
em F
continue;
}
og ON

pdPairKeyCount = (unsigned short*)((char*)plGroupKey + 4);


plPairwiseKey = (unsigned int*) ((char*)pdPairKeyCount + 2);
unsigned short k = 0;
for( k = 0; k < *pdPairKeyCount; k++)
{
@ C

unsigned int lPairKey = *plPairwiseKey & 0x00ffffff;


if(lPairKey == WPA_OUI )//|| (lPairKey & 0xffffff00) ==
WPA_OUI_1)
01 K

{
lPairKey = (*plPairwiseKey & 0xff000000) >>
0x18;
02 TE

if(lPairKey == 2){
bTKIP = 1;
}
else if(lPairKey == 3){
bAESWRAP = 1;
50 A

}
else if(lPairKey == 4){
29 DI

bAESCCMP = 1;
}
}
else
E

break;
FO M

++plPairwiseKey;
}

pdAuthenKeyCount = (unsigned short*)((char*)pdPairKeyCount +


2 + 4 * (*pdPairKeyCount));
plAuthenKey = (unsigned int*)((char*)pdAuthenKeyCount + 2);
for(k = 0; k < *pdAuthenKeyCount; k++)
R

{
unsigned int lAuthenKey = *plAuthenKey & 0x00ffffff;
if(lAuthenKey == CISCO_OUI)

MediaTek Confidential © 2012 MediaTek Inc. Page 76 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
{
bCCKM = 1; // CCKM for Cisco
}
else if (lAuthenKey == WPA_OUI)

N
{
lAuthenKey = (*plAuthenKey & 0xff000000)

US AL
EO
>> 0x18;

if(lAuthenKey == 1){
bWPA = 1;
}

om TI
else if(lAuthenKey == 0 || lAuthenKey == 2)
{
if(pBssid->InfrastructureMode){
bWPAPSK = 1;

y.c N
}
else

ra IDE
bWPANONE = 1;
}
}

++plAuthenKey;
}
em F
}
else if(pVarIE->ElementID == 48 && pVarIE->Length >= 12)
{
og ON

unsigned int* plGroupKey;


unsigned int* plPairwiseKey;
unsigned short* pdPairKeyCount;
unsigned int* plAuthenKey;
unsigned short* pdAuthenKeyCount;
@ C

plGroupKey = (unsigned int*)((char*)pVarIE + 4);

unsigned int lGroupKey = *plGroupKey & 0x00ffffff;


01 K

if(lGroupKey == WPA2_OUI)
{
lGroupKey = (*plGroupKey & 0xff000000) >> 0x18;
02 TE

if(lGroupKey == 2){
bTKIP = 1;
}
else if(lGroupKey == 3){
bAESWRAP = 1;
50 A

}
else if(lGroupKey == 4){
29 DI

bAESCCMP = 1;
}
}
else
E

{
lIELoc += pVarIE->Length;
FO M

lIELoc += 2;
pVarIE =
(PNDIS_802_11_VARIABLE_IEs)((char*)pVarIE + pVarIE->Length + 2);
if(pVarIE->Length <= 0)
break;

continue;
R

pdPairKeyCount = (unsigned short*)((char*)plGroupKey + 4);

MediaTek Confidential © 2012 MediaTek Inc. Page 77 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
plPairwiseKey = (unsigned int*)((char*)pdPairKeyCount + 2);
unsigned short k = 0;
for( k = 0; k < *pdPairKeyCount; k++)
{

N
unsigned int lPairKey = *plPairwiseKey & 0x00ffffff;
if(lPairKey == WPA2_OUI)

US AL
EO
{
lPairKey = (*plPairwiseKey & 0xff000000) >>
0x18;
if(lPairKey == 2){
bTKIP = 1;

om TI
}
else if(lPairKey == 3){
bAESWRAP = 1;
}

y.c N
else if(lPairKey == 4){
bAESCCMP = 1;

ra IDE
}
}
else
break;

++plPairwiseKey;
em F
}

pdAuthenKeyCount = (unsigned short*)((char*)pdPairKeyCount +


og ON

2 + 4 * *pdPairKeyCount);
plAuthenKey = (unsigned int*)((char*)pdAuthenKeyCount + 2);

for(k = 0; k < *pdAuthenKeyCount; k++)


{
@ C

unsigned int lAuthenKey = *plAuthenKey & 0x00ffffff;


if(lAuthenKey == CISCO_OUI)
{
01 K

bCCKM = 1; // CCKM for Cisco


}
else if (lAuthenKey == WPA2_OUI)
02 TE

{
lAuthenKey = (*plAuthenKey & 0xff000000)
>> 0x18;
if(lAuthenKey == 1)
bWPA2 = 1;
50 A

else if(lAuthenKey == 0 || lAuthenKey == 2)


{
29 DI

if(pBssid->InfrastructureMode)
bWPA2PSK = 1;
else
bWPA2NONE = 1;
E

}
}
FO M

++plAuthenKey;
}
}

lIELoc += pVarIE->Length;
lIELoc += 2;
R

pVarIE = (PNDIS_802_11_VARIABLE_IEs)((char*)pVarIE + pVarIE->Length


+ 2);
if(pVarIE->Length <= 0)

MediaTek Confidential © 2012 MediaTek Inc. Page 78 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
break;
}
}
//print security

N
//if(bCCKM)
//printf("CCKM; ");

US AL
EO
if (bWPA)
strcat(strAuth, "WPA");
if (bWPAPSK)
strcat(strAuth, "WPAPSK");
if (bWPANONE)

om TI
strcat(strAuth, "WPA-NONE");
if (bWPA2)
strcat(strAuth, "WPA2");
if (bWPA2PSK)

y.c N
strcat(strAuth, "WPA2PSK");
if (bWPA2NONE)

ra IDE
strcat(strAuth, "WPA2-NONE");

//if (strlen(strAuth) > 0)


//{
//strncpy((char *)tmpAuth, strAuth, strlen(strAuth) - 2);
//strcpy(strAuth, (char *)tmpAuth);
em F
//printf("Unknown 01");
//}
//else
og ON

//{
//printf("Unknown 02");
//}

if(bTKIP)
@ C

strcat(strEncry, "TKIP");
if(bAESWRAP || bAESCCMP)
strcat(strEncry, "AES");
01 K

//if(strlen(strEncry) > 0)
02 TE

//{
//strncpy((char *)tmpEncry, strEncry, strlen(strEncry) - 2);
//strcpy(strEncry, (char *)tmpEncry);
//printf("Unknown 03");
//}
50 A

//else
//{
29 DI

if (pBssid->Privacy)
{
if(strlen(strEncry) < 2)
{
E

printf("WEP");
}
FO M

else
{
printf("%s/%s", strAuth,strEncry);
}
}
else
{
R

printf("NONE");
}
//}

MediaTek Confidential © 2012 MediaTek Inc. Page 79 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
}

N
int main(int argc, char** argv)
{

US AL
EO
int i, socket_id;
struct iwreq wrq, wrq1;
int ret;
unsigned int bufLen = 1024*100;
PNDIS_802_11_BSSID_LIST_EX pBssidList;

om TI
PNDIS_WLAN_BSSID_EX pBssid;
PNDIS_802_11_FIXED_IEs pFixIE;
PNDIS_802_11_VARIABLE_IEs pVarIE;

y.c N
socket_id = socket(AF_INET,SOCK_DGRAM,0);
if(socket_id<0)

ra IDE
{
printf("\n Open socket error!\n");
goto error_exit;
}

//Scanning
em F
strcpy(wrq1.ifr_name, "ra0");
wrq1.u.data.flags = OID_802_11_BSSID_LIST_SCAN;
ret = ioctl(socket_id,RT_PRIV_IOCTL,&wrq1);
og ON

if(ret != 0)
{
printf("\n Scan fail %d\n", ret);
goto error_exit;
}
@ C

//Get List
pBssidList = (PNDIS_802_11_BSSID_LIST_EX)malloc(bufLen); //64k
01 K

memset(pBssidList, 0x00, bufLen);

strcpy(wrq.ifr_name, "ra0");
02 TE

wrq.u.data.length = bufLen;
wrq.u.data.pointer = pBssidList;
wrq.u.data.flags = OID_802_11_BSSID_LIST;
ret = ioctl(socket_id,RT_PRIV_IOCTL,&wrq);
do{
50 A

ret = ioctl(socket_id,RT_PRIV_IOCTL,&wrq);
printf("Scanning...\n");
29 DI

if(ret == EAGAIN)
printf("EAGAIN...\n");
else if(ret == E2BIG)
printf("E2BIG...\n");
E

else
sleep(1);
FO M

}while(ret == -1);

printf("\n=======GET BSSID LIST========\n");


pBssid = (PNDIS_WLAN_BSSID_EX)(pBssidList->Bssid);
for (i = 0; i < pBssidList->NumberOfItems; i++){
if(pBssid->Ssid.SsidLength == 0)
printf("%d: %-33s\t",i+1, " ");
R

else{
printf("%d: %-33s\t", i+1, pBssid->Ssid.Ssid);
}

MediaTek Confidential © 2012 MediaTek Inc. Page 80 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
printf("MAC:%02x:%02x:%02x:%02x:%02x:%02x\t",
pBssid->MacAddress[0],
pBssid->MacAddress[1],
pBssid->MacAddress[2],

N
pBssid->MacAddress[3],
pBssid->MacAddress[4],

US AL
EO
pBssid->MacAddress[5]);
printf("Rssi:%d\t",pBssid->Rssi);
//Networktype
if(pBssid->InfrastructureMode == 0)
printf("Ad-hoc\t");

om TI
else
printf("Infra\t",pBssid->Rssi);

//wirelessMode

y.c N
if(pBssid->NetworkTypeInUse == 1)
printf("11b\t");

ra IDE
else if(pBssid->NetworkTypeInUse == 3)
printf("11bg\t", pBssid->NetworkTypeInUse);
else if(pBssid->NetworkTypeInUse == 6)
printf("11bgn\t", pBssid->NetworkTypeInUse);
else
printf("unknown\t", pBssid->NetworkTypeInUse);
em F
//Security
pFixIE = (PNDIS_802_11_FIXED_IEs)pBssid->IEs;
pVarIE = (PNDIS_802_11_VARIABLE_IEs)((char*)pFixIE + sizeof(NDIS_802_11_FIXED_IEs));
og ON

checkSecurity(pBssid);

printf("\n");
//move forward
pBssid = (PNDIS_WLAN_BSSID_EX)((char *)pBssid + pBssid->Length);
@ C

error_exit:
01 K

if(socket_id>=0)
close(socket_id);
return 1;
02 TE

}
50 A

10.4 Display Rate and BW


29 DI

HTTRANSMIT_SETTING HTSetting;
Double Rate;
double b_mode[] ={1, 2, 5.5, 11};
E

float g_Rate[] = { 6,9,12,18,24,36,48,54};


switch(HTSetting.field.MODE)
{
FO M

case 0:
if (HTSetting.field.MCS >=0 && HTSetting.field.MCS<=3)
Rate = b_mode[HTSetting.field.MCS];
else if (HTSetting.field.MCS >=8 && HTSetting.field.MCS<=11)
Rate = b_mode[HTSetting.field.MCS-8];
else
Rate = 0;
break;
R

case 1:
if ((HTSetting.field.MCS >= 0) && (HTSetting.field.MCS < 8))
Rate = g_Rate[HTSetting.field.MCS];
else
Rate = 0;
MediaTek Confidential © 2012 MediaTek Inc. Page 81 of 82
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT


LY
break;
case 2:
case 3:
if (0 == bGetHTTxRateByBW_GI_MCS(HTSetting.field.BW, HTSetting.field.ShortGI,
HTSetting.field.MCS,

N
&Rate))
Rate = 0;

US AL
break;

EO
default:
Rate = 0;
break;
}

char bGetHTTxRateByBW_GI_MCS(int nBW, int nGI, int nMCS, double* dRate)

om TI
{
double HTTxRate20_800[16]={6.5, 13.0, 19.5, 26.0, 39.0, 52.0, 58.5, 65.0, 13.0, 26.0, 39.0, 52.0, 78.0, 104.0,
117.0, 130.0};
double HTTxRate20_400[16]={7.2, 14.4, 21.7, 28.9, 43.3, 57.8, 65.0, 72.2, 14.444, 28.889, 43.333, 57.778,

y.c N
86.667, 115.556, 130.000, 144.444};
double HTTxRate40_800[18]={13.5, 27.0, 40.5, 54.0, 81.0, 108.0, 121.5, 135.0, 27.0, 54.0, 81.0, 108.0,
162.0, 216.0, 243.0, 270.0, 6.0, 39.0};

ra IDE
double HTTxRate40_400[18]={15.0, 30.0, 45.0, 60.0, 90.0, 120.0, 135.0, 150.0, 30.0, 60.0, 90.0, 120.0,
180.0, 240.0, 270.0, 300.0, 6.7, 43.3};

// no TxRate for (BW = 20, GI = 400, MCS = 32) & (BW = 20, GI = 400, MCS = 32)
if (((nBW == BW_20) && (nGI == GI_400) && (nMCS == 32)) ||
((nBW == BW_20) && (nGI == GI_800) && (nMCS == 32)))
return 0; //false
em F
if( nBW == BW_20 && nGI == GI_800)
*dRate = HTTxRate20_800[nMCS];
else if( nBW == BW_20 && nGI == GI_400)
og ON

*dRate = HTTxRate20_400[nMCS];
else if( nBW == BW_40 && nGI == GI_800)
*dRate = HTTxRate40_800[nMCS];
else if( nBW == BW_40 && nGI == GI_400)
*dRate = HTTxRate40_400[nMCS];
else
@ C

return 0; //false

return 1; //true
}
01 K
02 TE
50 A
29 DI
E
FO M
R

MediaTek Confidential © 2012 MediaTek Inc. Page 82 of 82


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

loginid=29500201@ogemray.com,time=2013-02-01 15:49:06,ip=116.30.210.112,doctitle=MTK_Wi-Fi_STA_Software_Programming_Guide_v1.1.pdf,company=Shenzhen Ogemray Technology Co. Ltd. 深圳市奧金瑞科技有限公司_RLT

You might also like