1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - WM - include 3 File: nwm.h 4 5 Copyright 2007-2009 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2009-06-24#$ 14 $Rev: 10812 $ 15 $Author: sato_masaki $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef LIBRARIES_NWM_ARM9_NWM_H__ 19 #define LIBRARIES_NWM_ARM9_NWM_H__ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /*===========================================================================*/ 26 27 #include <twl.h> 28 #include <nitro/wm.h> 29 30 /*---------------------------------------------------------------------------* 31 Constant definitions 32 *---------------------------------------------------------------------------*/ 33 34 #define NWM_NUM_MAX_AP_AID 2007 // The maximum value possible for the AssociationID provided by the wireless router 35 36 #define NWM_SIZE_SSID 32 37 #define NWM_SIZE_MACADDR 6 38 #define NWM_SIZE_BSSID NWM_SIZE_MACADDR 39 40 #define NWM_SIZE_WEP_40BIT 5 41 #define NWM_SIZE_WEP_104BIT 13 42 #define NWM_SIZE_WEP_128BIT 16 43 44 #define NWM_SIZE_WEP 20 // For preserving WM (DS connection settings) compatibility 45 46 #define NWM_WEPMODE_OPEN WM_WEPMODE_NO 47 #define NWM_WEPMODE_40BIT WM_WEPMODE_40BIT 48 #define NWM_WEPMODE_104BIT WM_WEPMODE_104BIT 49 #define NWM_WEPMODE_128BIT WM_WEPMODE_128BIT 50 51 #define NWM_WPAMODE_WPA_TKIP (WM_WEPMODE_128BIT + 1) 52 #define NWM_WPAMODE_WPA2_TKIP (WM_WEPMODE_128BIT + 2) 53 #define NWM_WPAMODE_WPA_AES (WM_WEPMODE_128BIT + 3) 54 #define NWM_WPAMODE_WPA2_AES (WM_WEPMODE_128BIT + 4) 55 56 57 #define NWM_BSS_DESC_SIZE 64 // Size of the buffer transferred with the NWM_StartScan function to store parent information 58 #define NWM_BSS_DESC_SIZE_MAX 512 59 #define NWM_FRAME_SIZE_MAX 1522 // Maximum data frame size: 1500(MTU) + 22(802.3 header) 60 #define NWM_SCAN_NODE_MAX 32 // Maximum number of parent devices that can be found by a single Scan 61 #define NWM_SIZE_SCANBUF_MAX 65535 // Maximum buffer size 62 63 #define NWM_SYSTEM_BUF_SIZE (0x00003000) 64 65 // Bitmask for capability information 66 #define NWM_CAPABILITY_ESS_MASK 0x0001 67 #define NWM_CAPABILITY_ADHOC_MASK 0x0002 68 #define NWM_CAPABILITY_CP_POLLABLE_MASK 0x0004 69 #define NWM_CAPABILITY_CP_POLL_REQ_MASK 0x0008 70 #define NWM_CAPABILITY_PRIVACY_MASK 0x0010 71 #define NWM_CAPABILITY_SPREAMBLE_MASK 0x0020 72 #define NWM_CAPABILITY_PBCC_MASK 0x0040 73 #define NWM_CAPABILITY_CH_AGILITY_MASK 0x0800 74 #define NWM_CAPABILITY_SPECTRUM_MASK 0x0100 75 #define NWM_CAPABILITY_QOS_MASK 0x0200 76 #define NWM_CAPABILITY_SSLOTTIME_MASK 0x0400 77 #define NWM_CAPABILITY_APSD_MASK 0x0800 78 79 80 #define NWM_SCANTYPE_PASSIVE 0 81 #define NWM_SCANTYPE_ACTIVE 1 82 83 #define NWM_DEFAULT_PASSIVE_SCAN_PERIOD 105 /* Note that the default NWM values are larger than the default WM values */ 84 #define NWM_DEFAULT_ACTIVE_SCAN_PERIOD 30 /* Note that NWM uses different default values for active and passive scans */ 85 86 #define NWM_RATESET_1_0M 0x0001 87 #define NWM_RATESET_2_0M 0x0002 88 #define NWM_RATESET_5_5M 0x0004 89 #define NWM_RATESET_6_0M 0x0008 90 #define NWM_RATESET_9_0M 0x0010 91 #define NWM_RATESET_11_0M 0x0020 92 #define NWM_RATESET_12_0M 0x0040 93 #define NWM_RATESET_18_0M 0x0080 94 #define NWM_RATESET_24_0M 0x0100 95 #define NWM_RATESET_36_0M 0x0200 96 #define NWM_RATESET_48_0M 0x0400 97 #define NWM_RATESET_54_0M 0x0800 98 #define NWM_RATESET_11B_MASK ( NWM_RATESET_1_0M | NWM_RATESET_2_0M | NWM_RATESET_5_5M | NWM_RATESET_11_0M ) 99 #define NWM_RATESET_11G_MASK ( NWM_RATESET_1_0M | NWM_RATESET_2_0M | NWM_RATESET_5_5M | NWM_RATESET_11_0M \ 100 | NWM_RATESET_6_0M | NWM_RATESET_9_0M | NWM_RATESET_12_0M | NWM_RATESET_18_0M \ 101 | NWM_RATESET_24_0M | NWM_RATESET_36_0M | NWM_RATESET_48_0M | NWM_RATESET_54_0M ) 102 103 #define NWM_WPA_PSK_LENGTH 32 104 #define NWM_WPA_PASSPHRASE_LENGTH_MAX 64 105 106 107 /* Link levels */ 108 #define NWM_RSSI_INFRA_LINK_LEVEL_1 12 109 #define NWM_RSSI_INFRA_LINK_LEVEL_2 17 110 #define NWM_RSSI_INFRA_LINK_LEVEL_3 22 111 112 #define NWM_RSSI_ADHOC_LINK_LEVEL_1 12 /* [TODO] TBD */ 113 #define NWM_RSSI_ADHOC_LINK_LEVEL_2 17 /* [TODO] TBD */ 114 #define NWM_RSSI_ADHOC_LINK_LEVEL_3 22 /* [TODO] TBD */ 115 116 /*---------------------------------------------------------------------------* 117 Macro definitions 118 *---------------------------------------------------------------------------*/ 119 120 121 // ID for each API 122 typedef enum NWMApiid 123 { 124 NWM_APIID_INIT = 0, // NWM_Init() 125 NWM_APIID_RESET, // NWM_Reset() 126 NWM_APIID_END, // NWM_End() 127 128 NWM_APIID_LOAD_DEVICE, // NWM_LoadDevice() 129 NWM_APIID_UNLOAD_DEVICE, // NWM_UnloadDevice() 130 NWM_APIID_OPEN, // NWM_Open() 131 NWM_APIID_CLOSE, // NWM_Close() 132 133 NWM_APIID_START_SCAN, // NWM_StartScan() 134 NWM_APIID_CONNECT, // NWM_Connect() 135 NWM_APIID_DISCONNECT, // NWM_Disconnect() 136 NWM_APIID_SET_RECEIVING_BUF, // NWM_SetReceivingFrameBuffer() 137 NWM_APIID_SEND_FRAME, // NWM_SendFrame() 138 NWM_APIID_UNSET_RECEIVING_BUF, // NWM_UnsetReceivingFrameBuffer() 139 NWM_APIID_SET_WEPKEY, // NWM_SetWEPKey() 140 NWM_APIID_SET_PS_MODE, // NWM_SetPowerSaveMode() 141 142 NWM_APIID_SET_WPA_KEY, // 143 NWM_APIID_SET_WPA_PARAMS, // 144 145 NWM_APIID_CREATE_QOS, // 146 NWM_APIID_SET_WPA_PSK, // NWM_SetWPAPSK() 147 NWM_APIID_INSTALL_FIRMWARE, // NWMi_InstallFirmware() 148 NWM_APIID_ASYNC_KIND_MAX, // : Type of asynchronous process 149 150 NWM_APIID_INDICATION = 128, // : For indication callback 151 152 NWM_APIID_UNKNOWN = 255 // : Value returned from ARM7 at unknown command number 153 } 154 NWMApiid; 155 156 157 // API result codes 158 typedef enum NWMRetCode 159 { 160 NWM_RETCODE_SUCCESS = 0, 161 NWM_RETCODE_FAILED = 1, 162 NWM_RETCODE_OPERATING = 2, 163 NWM_RETCODE_ILLEGAL_STATE = 3, 164 NWM_RETCODE_NWM_DISABLE = 4, 165 NWM_RETCODE_INVALID_PARAM = 5, 166 NWM_RETCODE_FIFO_ERROR = 6, 167 NWM_RETCODE_FATAL_ERROR = 7, // Error that the software cannot handle 168 NWM_RETCODE_NETBUF_ERROR = 8, 169 NWM_RETCODE_WMI_ERROR = 9, 170 NWM_RETCODE_SDIO_ERROR = 10, 171 NWM_RETCODE_RECV_IND = 11, 172 NWM_RETCODE_INDICATION = 12, // Internal use only 173 174 NWM_RETCODE_MAX 175 } NWMRetCode; 176 177 // NWM state codes 178 typedef enum NWMState 179 { 180 NWM_STATE_NONE = 0x0000, 181 NWM_STATE_INITIALIZED = 0x0001, // INITIALIZED state 182 NWM_STATE_LOADED = 0x0002, // LOADED state 183 NWM_STATE_DISCONNECTED = 0x0003, // DISCONNECTED state 184 NWM_STATE_INFRA_CONNECTED = 0x0004, // CONNECTED STA (infrastructure) state 185 NWM_STATE_ADHOC_CONNECTED = 0x0005 // CONNECTED STA (ad hoc) state 186 } 187 NWMState; 188 189 typedef enum NWMReasonCode 190 { 191 NWM_REASON_API_SUCCESS = 0, 192 193 /* For infra mode */ 194 NWM_REASON_NO_NETWORK_AVAIL = 1, 195 NWM_REASON_LOST_LINK = 2, 196 NWM_REASON_DISCONNECT_CMD = 3, 197 NWM_REASON_BSS_DISCONNECTED = 4, 198 NWM_REASON_AUTH_FAILED = 5, 199 NWM_REASON_ASSOC_FAILED = 6, 200 NWM_REASON_NO_RESOURCES_AVAIL = 7, 201 NWM_REASON_CSERV_DISCONNECT = 8, 202 NWM_REASON_INVAILD_PROFILE = 9, 203 204 NWM_REASON_WEP_KEY_ERROR =10, 205 206 /* For WPA supplicant */ 207 NWM_REASON_WPA_KEY_ERROR =11, 208 NWM_REASON_TKIP_MIC_ERROR =12, 209 210 /* For Wireless QoS (802.11e) */ 211 NWM_REASON_NO_QOS_RESOURCES_AVAIL = 13, 212 213 NWM_REASON_UNKNOWN 214 215 } NWMReasonCode; 216 217 typedef enum NWMAuthMode 218 { 219 NWM_AUTHMODE_OPEN, /* DOT11 authentication */ 220 NWM_AUTHMODE_SHARED, /* DOT11 authentication */ 221 NWM_AUTHMODE_WPA_PSK_TKIP = NWM_WPAMODE_WPA_TKIP, /* Be careful to keep this from overlapping with WCM_WEPMODE_* */ 222 NWM_AUTHMODE_WPA2_PSK_TKIP = NWM_WPAMODE_WPA2_TKIP, 223 NWM_AUTHMODE_WPA_PSK_AES = NWM_WPAMODE_WPA_AES, 224 NWM_AUTHMODE_WPA2_PSK_AES = NWM_WPAMODE_WPA2_AES 225 } 226 NWMAuthMode, NWMauthMode; 227 228 229 // Element ID of Information Elements 230 typedef enum NWMElementID { 231 NWM_ELEMENTID_SSID = 0, 232 NWM_ELEMENTID_SUPPORTED_RATES = 1, 233 NWM_ELEMENTID_FH_PARAMETER_SET = 2, 234 NWM_ELEMENTID_DS_PARAMETER_SET = 3, 235 NWM_ELEMENTID_CF_PARAMETER_SET = 4, 236 NWM_ELEMENTID_TIM = 5, 237 NWM_ELEMENTID_IBSS_PARAMETER_SET = 6, 238 NWM_ELEMENTID_COUNTRY = 7, 239 NWM_ELEMENTID_HP_PARAMETERS = 8, 240 NWM_ELEMENTID_HP_TABLE = 9, 241 NWM_ELEMENTID_REQUEST = 10, 242 NWM_ELEMENTID_QBSS_LOAD = 11, 243 NWM_ELEMENTID_EDCA_PARAMETER_SET = 12, 244 NWM_ELEMENTID_TSPEC = 13, 245 NWM_ELEMENTID_TRAFFIC_CLASS = 14, 246 NWM_ELEMENTID_SCHEDULE = 15, 247 NWM_ELEMENTID_CHALLENGE_TEXT = 16, 248 249 NWM_ELEMENTID_POWER_CONSTRAINT = 32, 250 NWM_ELEMENTID_POWER_CAPABILITY = 33, 251 NWM_ELEMENTID_TPC_REQUEST = 34, 252 NWM_ELEMENTID_TPC_REPORT = 35, 253 NWM_ELEMENTID_SUPPORTED_CHANNELS = 36, 254 NWM_ELEMENTID_CH_SWITCH_ANNOUNCE = 37, 255 NWM_ELEMENTID_MEASURE_REQUEST = 38, 256 NWM_ELEMENTID_MEASURE_REPORT = 39, 257 NWM_ELEMENTID_QUIET = 40, 258 NWM_ELEMENTID_IBSS_DFS = 41, 259 NWM_ELEMENTID_ERP_INFORMATION = 42, 260 NWM_ELEMENTID_TS_DELAY = 43, 261 NWM_ELEMENTID_TCLASS_PROCESSING = 44, 262 NWM_ELEMENTID_HT_CAPABILITY = 45, 263 NWM_ELEMENTID_QOS_CAPABILITY = 46, 264 NWM_ELEMENTID_RSN = 48, 265 NWM_ELEMENTID_EX_SUPPORTED_RATES = 50, 266 NWM_ELEMENTID_HT_INFORMATION = 61, 267 268 NWM_ELEMENTID_VENDOR = 221, 269 NWM_ELEMENTID_NINTENDO = 221 270 } 271 NWMElementID; 272 273 typedef enum NWMPowerMode { 274 NWM_POWERMODE_ACTIVE, 275 NWM_POWERMODE_STANDARD, 276 NWM_POWERMODE_UAPSD 277 } NWMPowerMode; 278 279 typedef enum NWMAccessCategory { 280 NWM_AC_BE, /* Best effort */ 281 NWM_AC_BK, /* Background */ 282 NWM_AC_VI, /* Video */ 283 NWM_AC_VO, /* Voice */ 284 NWM_AC_NUM 285 } NWMAccessCategory; 286 287 typedef enum NWMNwType 288 { 289 NWM_NWTYPE_INFRA, 290 NWM_NWTYPE_ADHOC, 291 NWM_NWTYPE_WPS, 292 NWM_NWTYPE_NUM 293 } NWMNwType; 294 295 typedef enum NWMFramePort 296 { 297 NWM_PORT_IPV4_ARP, /* For TCP/IP */ 298 NWM_PORT_EAPOL, /* For WPA supplicant */ 299 NWM_PORT_OTHERS, 300 NWM_PORT_NUM 301 } NWMFramePort, NWMframePort; 302 303 typedef void (*NWMCallbackFunc) (void *arg); // Callback type for the NWM API 304 305 /*---------------------------------------------------------------------------* 306 Structure Definitions 307 *---------------------------------------------------------------------------*/ 308 309 typedef struct NWMBssDesc 310 { 311 u16 length; // 2 312 s16 rssi; // 4 313 u8 bssid[NWM_SIZE_BSSID]; // 10 314 u16 ssidLength; // 12 315 u8 ssid[NWM_SIZE_SSID]; // 44 316 u16 capaInfo; // 46 317 struct 318 { 319 u16 basic; // 48 320 u16 support; // 50 321 } 322 rateSet; 323 u16 beaconPeriod; // 52 324 u16 dtimPeriod; // 54 325 u16 channel; // 56 326 u16 cfpPeriod; // 58 327 u16 cfpMaxDuration; // 60 328 u16 reserved; // 62 just for compatibility with WM (must be 0) 329 u16 elementCount; // 64 330 u16 elements[1]; 331 } NWMBssDesc, NWMbssDesc; 332 333 334 typedef struct NWMInfoElements 335 { 336 u8 id; 337 u8 length; 338 u16 element[1]; 339 } 340 NWMInfoElements; 341 342 343 //--------------------------------------- 344 // NWM Scan parameter structure 345 typedef struct NWMScanParam 346 { 347 NWMBssDesc *scanBuf; // Buffer that stores parent information 348 u16 scanBufSize; // Size of scanBuf 349 u16 channelList; // List of channels (more than one can be specified) to scan 350 u16 channelDwellTime; // Per-channel scan time (in ms) 351 u16 scanType; // passive or active 352 u8 bssid[NWM_SIZE_BSSID]; // MAC address to scan for (all parent devices will be targeted if this is 0xff) 353 u16 ssidLength; // Length of the SSID to scan for (all nodes will be targeted if this is 0) 354 u8 ssid[NWM_SIZE_SSID]; // SSID to scan for 355 u16 rsv[6]; 356 } NWMScanParam, NWMscanParam; 357 358 // NWM Scan parameter structure 359 typedef struct NWMScanExParam 360 { 361 NWMBssDesc *scanBuf; // Buffer that stores parent information 362 u16 scanBufSize; // Size of scanBuf 363 u16 channelList; // List of channels (more than one can be specified) to scan 364 u16 channelDwellTime; // Per-channel scan time (in ms) 365 u16 scanType; // passive or active 366 u8 bssid[NWM_SIZE_BSSID]; // MAC address to scan for (all parent devices will be targeted if this is 0xff) 367 u16 ssidLength; // Length of the SSID to scan for (all nodes will be targeted if this is 0) 368 u8 ssid[NWM_SIZE_SSID]; // SSID to scan for 369 u16 ssidMatchLength; // Matching length of the SSID to scan for 370 u16 rsv[5]; 371 } NWMScanExParam, NWMscanExParam; 372 373 374 //--------------------------------------- 375 // NWM WPA parameter structure 376 377 typedef struct NWMWpaParam { 378 u16 auth; // NWMAuthMode (can use PSK only) 379 u8 psk[NWM_WPA_PSK_LENGTH]; 380 } NWMWpaParam; 381 382 // Buffer structure for receiving frames 383 typedef struct NWMRecvFrameHdr 384 { 385 u8 da[NWM_SIZE_MACADDR]; 386 u8 sa[NWM_SIZE_MACADDR]; 387 u8 pid[2]; 388 u8 frame[2]; 389 } NWMRecvFrameHdr; 390 391 //========================================================================================== 392 393 // Normal callback arguments 394 typedef struct NWMCallback 395 { 396 u16 apiid; 397 u16 retcode; 398 399 } NWMCallback; 400 401 // Callback arguments for the NWM_StartScan function 402 typedef struct NWMStartScanCallback 403 { 404 u16 apiid; 405 u16 retcode; 406 u32 channelList; // Scanned channel list, regardless of whether found 407 u8 reserved[2]; // Padding 408 u16 bssDescCount; // Number of parents that were found 409 u32 allBssDescSize; 410 NWMBssDesc *bssDesc[NWM_SCAN_NODE_MAX]; // Beginning address of the parent information 411 u16 linkLevel[NWM_SCAN_NODE_MAX]; // Reception signal strength 412 413 } NWMStartScanCallback, NWMstartScanCallback; 414 415 // Callback arguments for the NWM_Connect function 416 typedef struct NWMConnectCallback 417 { 418 u16 apiid; 419 u16 retcode; 420 u16 channel; 421 u8 bssid[NWM_SIZE_BSSID]; 422 s16 rssi; 423 u16 aid; // Only when CONNECTED. AID assigned to self 424 u16 reason; // reason when disconnecting. This is defined in NWMReasonCode 425 u16 listenInterval; 426 u8 networkType; 427 u8 beaconIeLen; 428 u8 assocReqLen; 429 u8 assocRespLen; 430 u8 assocInfo[2]; /* This field consists of beaconIe, assocReq, assocResp */ 431 } NWMConnectCallback, NWMconnectCallback; 432 433 // Callback arguments for the NWM_Disconnect function 434 typedef struct NWMDisconnectCallback 435 { 436 u16 apiid; 437 u16 retcode; 438 u16 reason; 439 u16 rsv; 440 } NWMDisconnectCallback, NWMdisconnectCallback; 441 442 // Callback arguments for the NWM_SendFrame function 443 typedef struct NWMSendFrameCallback 444 { 445 u16 apiid; 446 u16 retcode; 447 NWMCallbackFunc callback; 448 } NWMSendFrameCallback; 449 450 // Callback arguments for the NWM_SetReceivingFrameBuffer function 451 typedef struct NWMReceivingFrameCallback 452 { 453 u16 apiid; 454 u16 retcode; 455 u16 port; 456 s16 rssi; 457 u32 length; 458 NWMRecvFrameHdr *recvBuf; 459 460 } NWMReceivingFrameCallback; 461 462 463 /*=========================================================================== 464 NWM APIs 465 ===========================================================================*/ 466 467 /*---------------------------------------------------------------------------* 468 Name: NWM_Init 469 470 Description: Initializes the NWM library. 471 Synchronous function that initializes only ARM9. 472 473 Arguments: sysBuf: Pointer to the buffer allocated by the caller. 474 475 bufSize: Size of the buffer allocated by the caller 476 477 dmaNo: DMA number used by the NWM library 478 479 Returns: NWMRetCode: Returns the processing result. 480 *---------------------------------------------------------------------------*/ 481 NWMRetCode NWM_Init(void* sysBuf, u32 bufSize, u8 dmaNo); 482 483 /*---------------------------------------------------------------------------* 484 Name: NWM_Reset 485 486 Description: Restarts the TWL wireless driver and resets the TWL wireless module. 487 488 Arguments: callback: Callback function that is called when the asynchronous process completes 489 490 Returns: NWMRetCode: Returns the processing result. 491 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 492 493 *---------------------------------------------------------------------------*/ 494 NWMRetCode NWM_Reset(NWMCallbackFunc callback); 495 496 /*---------------------------------------------------------------------------* 497 Name: NWM_LoadDevice 498 499 Description: Starts the TWL wireless module. 500 There will be an internal state transition from NWM_STATE_INITIALIZED to NWM_STATE_LOADED. 501 502 503 Arguments: callback: Callback function that is called when the asynchronous process completes 504 505 Returns: NWMRetCode: Returns the processing result. 506 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 507 508 *---------------------------------------------------------------------------*/ 509 NWMRetCode NWM_LoadDevice(NWMCallbackFunc callback); 510 511 /*---------------------------------------------------------------------------* 512 Name: NWM_UnloadDevice 513 514 Description: Shuts down the TWL wireless module. 515 There will be an internal state transition from NWM_STATE_LOADED to NWM_STATE_INITIALIZED. 516 517 518 Arguments: callback: Callback function that is called when the asynchronous process completes 519 520 Returns: NWMRetCode: Returns the processing result. 521 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 522 523 *---------------------------------------------------------------------------*/ 524 NWMRetCode NWM_UnloadDevice(NWMCallbackFunc callback); 525 526 /*---------------------------------------------------------------------------* 527 Name: NWM_Open 528 529 Description: Allows use of TWL wireless functionality. 530 There will be an internal state transition from NWM_STATE_LOADED to NWM_STATE_DISCONNECTED. 531 532 533 Arguments: callback: Callback function that is called when the asynchronous process completes 534 535 Returns: NWMRetCode: Returns the processing result. 536 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 537 538 *---------------------------------------------------------------------------*/ 539 NWMRetCode NWM_Open(NWMCallbackFunc callback); 540 541 /*---------------------------------------------------------------------------* 542 Name: NWM_Close 543 544 Description: Disables TWL wireless functionality. 545 There will be an internal state transition from NWM_STATE_DISCONNECTED to NWM_STATE_LOADED. 546 547 548 Arguments: callback: Callback function that is called when the asynchronous process completes 549 550 Returns: NWMRetCode: Returns the processing result. 551 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 552 553 *---------------------------------------------------------------------------*/ 554 NWMRetCode NWM_Close(NWMCallbackFunc callback); 555 556 /*---------------------------------------------------------------------------* 557 Name: NWM_End 558 559 Description: Shuts down the NWM library. 560 This is a synchronous function that shuts down processing only on the ARM9. 561 562 Arguments: None. 563 564 Returns: NWMRetCode: Returns the processing result. 565 *---------------------------------------------------------------------------*/ 566 NWMRetCode NWM_End(void); 567 568 /*---------------------------------------------------------------------------* 569 Name: NWM_StartScan 570 571 Description: Starts scanning for an AP. 572 A single function call can get parent information for multiple devices. 573 There are no state transitions during or after a scan. 574 575 Arguments: callback: Callback function that is called when the asynchronous process completes. 576 Arguments will be returned as a NWMStartScanCallback structure. 577 param: Pointer to a structure that shows information on scan settings. 578 The ARM7 directly writes scan result information to param->scanBuf, so it must match the cache line. 579 580 See the NWMScanParam structure for individual parameters. 581 582 Returns: NWMRetCode: Returns the processing result. 583 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 584 585 *---------------------------------------------------------------------------*/ 586 NWMRetCode NWM_StartScan(NWMCallbackFunc callback, const NWMScanParam *param); 587 588 /*---------------------------------------------------------------------------* 589 Name: NWM_StartScanEx 590 591 Description: Starts scanning for an AP. 592 A single function call can get parent information for multiple devices. 593 There are no state transitions during or after a scan. 594 You can run a partial SSID match on the scan results. 595 596 Arguments: callback: Callback function that is called when the asynchronous process completes. 597 Arguments will be returned as a NWMStartScanCallback structure. 598 param: Pointer to a structure that shows information on scan settings. 599 The target SSID and the scan results from the wireless module are compared only for the length specified by ssidMatchLength and then only the relevant scan results are written out. 600 The ARM7 directly writes scan result information to param->scanBuf, so it must match the cache line. 601 602 603 604 See the NWMScanExParam structure for individual parameters. 605 606 Returns: NWMRetCode: Returns the processing result. 607 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 608 609 *---------------------------------------------------------------------------*/ 610 NWMRetCode NWM_StartScanEx(NWMCallbackFunc callback, const NWMScanExParam *param); 611 612 /*---------------------------------------------------------------------------* 613 Name: NWM_Connect 614 615 Description: Connects to an AP. This cannot connect to DS parent devices. 616 617 Arguments: callback: Callback function that is called when the asynchronous process completes. 618 Arguments will be returned as a NWMConnectCallback structure. 619 nwType: Takes the value defined by NWMNwType. 620 In general, use NWM_NWTYPE_INFRA. 621 pBdesc: Information on the AP to connect to. 622 Specifies the structure obtained with NWM_StartScan. 623 Instances of this structure are forcibly stored in the cache. 624 See the NWMBssDesc structure for individual parameters. 625 626 Returns: NWMRetCode: Returns the processing result. 627 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 628 629 *---------------------------------------------------------------------------*/ 630 NWMRetCode NWM_Connect(NWMCallbackFunc callback, u8 nwType, const NWMBssDesc *pBdesc); 631 632 /*---------------------------------------------------------------------------* 633 Name: NWM_Disconnect 634 635 Description: Disconnects from an access point. 636 637 Arguments: callback: Callback function that is called when the asynchronous process completes. 638 Arguments will be returned as a NWMDisconnectCallback structure. 639 640 Returns: NWMRetCode: Returns the processing result. 641 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 642 643 *---------------------------------------------------------------------------*/ 644 NWMRetCode NWM_Disconnect(NWMCallbackFunc callback); 645 646 /*---------------------------------------------------------------------------* 647 Name: NWM_SetWEPKey 648 649 Description: Configures the WEP encryption mode and key. 650 You must configure these before calling the NWM_Connect function. 651 652 Arguments: callback: Callback function that is called when the asynchronous process completes. 653 wepmode: NWM_WEPMODE_OPEN: No encryption feature 654 NWM_WEPMODE_40BIT: RC4 (40bit) encryption mode 655 NWM_WEPMODE_104BIT: RC4 (104bit) encryption mode 656 NWM_WEPMODE_128BIT: RC4 (128bit) encryption mode. 657 wepkeyid: Selects which of the 4 specified wepkeys to use for sending data. 658 Specify using 0-3. 659 wepkey: Pointer to the encryption key data (80 bytes). 660 Key data consists of 4 pieces of data, each 20 bytes long. 661 Of each 20 bytes, 662 5 bytes in 40-bit mode 663 13 bytes in 104-bit mode 664 16 bytes in 128-bit mode 665 are used. 666 The data entity is forcibly stored in cache. 667 authMode: Authentication mode when connecting. 668 NWM_AUTHMODE_OPEN: Open authentication 669 NWM_AUTHMODE_SHARED: Shared key authentication 670 671 Returns: NWMRetCode: Returns the processing result. 672 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 673 674 *---------------------------------------------------------------------------*/ 675 NWMRetCode NWM_SetWEPKey(NWMCallbackFunc callback, u16 wepmode, u16 wepkeyid, const u8 *wepkey, u16 authMode); 676 677 /*---------------------------------------------------------------------------* 678 Name: NWM_Passphrase2PSK 679 680 Description: Calculates the PSK from a WPA passphrase. Synchronous function. 681 682 Arguments: passphrase: Pointer to a buffer with the WPA passphrase. 683 This has a maximum size of 63 bytes. 684 ssid: Pointer to a buffer with the SSID of the access point to connect to 685 ssidlen: SSID size of the access point to connect to 686 psk: Pointer to the buffer that will store the calculated PSK. 687 This is fixed to 32 bytes. 688 689 Returns: None. 690 *---------------------------------------------------------------------------*/ 691 void NWM_Passphrase2PSK(const u8 passphrase[NWM_WPA_PASSPHRASE_LENGTH_MAX], const u8 *ssid, u8 ssidlen, u8 psk[NWM_WPA_PSK_LENGTH]); 692 693 /*---------------------------------------------------------------------------* 694 Name: NWM_SetWPAPSK 695 696 Description: Configures the WPA encryption mode and key. 697 You must configure these before calling the NWM_Connect function. 698 699 Arguments: callback: Callback function that is called when the asynchronous process completes 700 param: Pointer to a structure that shows information on WPA settings. 701 See the NWMWpaParam structure for individual parameters. 702 703 Returns: NWMRetCode: Returns the processing result. 704 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 705 706 *---------------------------------------------------------------------------*/ 707 NWMRetCode NWM_SetWPAPSK(NWMCallbackFunc callback, NWMWpaParam *param); 708 709 /*---------------------------------------------------------------------------* 710 Name: NWM_SetReceivingFrameBuffer 711 712 Description: Configures the receive buffer. 713 714 Arguments: callback: Callback function that is invoked when asynchronous processing finishes and when data is sent. 715 716 Arguments will be returned as a NWMReceivingFrameCallback structure. 717 This entails NWM_RETCODE_RECV_IND when sending data. 718 719 recvBuf: Pointer to the data receive buffer. 720 Pay attention to the cache because the ARM7 writes data out directly. 721 recvBufSize: Size of data receive buffer. The receive buffer count is an integer quotient of this size divided by 1536 (0x600) bytes. 722 (Anything below the decimal point will be rounded off.) 723 To avoid losing received data, allocate at least 3072 (0xC00) bytes. 724 protocol: Which protocol the receive buffer is for. 725 NWM_PORT_IPV4_ARP: IPv4 TCP/IP data and ARP data 726 (You should normally use this.) 727 NWM_PORT_EAPOL: EAPOL data (for WPS) 728 NWM_PORT_OTHERS: Other protocols 729 730 Returns: NWMRetCode: Returns the processing result. 731 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 732 733 *---------------------------------------------------------------------------*/ 734 NWMRetCode NWM_SetReceivingFrameBuffer(NWMCallbackFunc callback, u8* recvBuf, u16 recvBufSize, u16 protocol); 735 736 /*---------------------------------------------------------------------------* 737 Name: NWM_SendFrame 738 739 Description: Sets the data for the wireless module to send. 740 Note that this does not guarantee that the transmission has completed. 741 742 Arguments: callback: Callback function that is called when the asynchronous process completes. 743 Arguments will be returned as a NWMSendFrameCallback structure. 744 destAddr: Pointer to a buffer with the BSSID to send to 745 sendFrame: Pointer to the data to send. 746 Note that instances of the data to send are forced to be stored in the cache. 747 748 sendFrameSize: Size of the data to send 749 750 Returns: NWMRetCode: Returns the processing result. 751 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 752 753 *---------------------------------------------------------------------------*/ 754 NWMRetCode NWM_SendFrame(NWMCallbackFunc callback, const u8 *destAddr, 755 const u16 *sendFrame, u16 sendFrameSize); 756 757 /*---------------------------------------------------------------------------* 758 Name: NWM_UnsetReceivingFrameBuffer 759 760 Description: Releases the receive buffer. 761 762 Arguments: callback: The callback function that is invoked when asynchronous processing finishes and when data is sent 763 764 765 protocol: Which protocol the receive buffer is for. 766 NWM_PORT_IPV4_ARP: IPv4 TCP/IP data and ARP data 767 (You should normally use this.) 768 NWM_PORT_EAPOL: EAPOL data (for WPS) 769 NWM_PORT_OTHERS: Other protocols 770 771 Returns: NWMRetCode: Returns the processing result. 772 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 773 774 *---------------------------------------------------------------------------*/ 775 NWMRetCode NWM_UnsetReceivingFrameBuffer(NWMCallbackFunc callback, u16 protocol); 776 777 /*---------------------------------------------------------------------------* 778 Name: NWM_SetPowerSaveMode 779 780 Description: Changes the PowerSaveMode. 781 782 Arguments: callback: Callback function that is called when the asynchronous process completes 783 powerSave: Power-save mode. 784 NWM_POWERMODE_ACTIVE: Power-save mode off 785 NWM_POWERMODE_STANDARD: Standard 802.11 power-save mode 786 NWM_POWERMODE_UAPSD: Enhanced power-save mode established in 802.11e 787 (Unscheduled Automatic Power Save Delivery) 788 789 Returns: NWMRetCode: Returns the processing result. 790 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 791 792 *---------------------------------------------------------------------------*/ 793 NWMRetCode NWM_SetPowerSaveMode(NWMCallbackFunc callback, NWMPowerMode powerSave); 794 795 /*---------------------------------------------------------------------------* 796 Name: NWM_GetMacAddress 797 798 Description: Gets the MAC address for this device from the TWL wireless module. 799 Synchronous function. 800 801 Arguments: macAddr: Pointer to a buffer to store this device's MAC address 802 803 Returns: NWMRetCode: Returns the processing result. 804 *---------------------------------------------------------------------------*/ 805 NWMRetCode NWM_GetMacAddress(u8* macAddr); 806 807 /*---------------------------------------------------------------------------* 808 Name: NWM_GetBssDesc 809 810 Description: Gets BSS data from the buffer with scan results from NWM_StartScan. 811 Synchronous function. 812 813 Arguments: bssbuf: Pointer to the buffer with scan results 814 bsssize: Size of the buffer with scan results 815 index: Index to the BSS data to get 816 817 Returns: NWMBssDesc: Returns the BSS data at index. 818 Returns NULL if it could not be obtained. 819 *---------------------------------------------------------------------------*/ 820 NWMBssDesc* NWM_GetBssDesc(void* bssbuf, u32 bsssize, int index); 821 822 /*---------------------------------------------------------------------------* 823 Name: NWM_GetAllowedChannel 824 825 Description: Gets the channel that was permitted to use for the communication. Synchronous function. 826 Call this from a state after NWM_STATE_DISCONNECTED (after NWM_Open has completed). 827 828 Arguments: None. 829 830 Returns: u16: Returns the bit field of the permitted channel. 831 The least significant bit indicates channel 1, and the most significant bit indicates channel 16. 832 A channel can be used if its corresponding bit is set to 1 and is prohibited from being used if its corresponding bit is set to 0. 833 Typically, a value is returned with several of the bits corresponding to channels 1-13 set to 1. 834 When 0x0000 is returned, no channels can be used and wireless features are themselves prohibited. 835 Also, in case the function failed, such as when it is not yet initialized, 0x8000 is returned. 836 837 *---------------------------------------------------------------------------*/ 838 u16 NWM_GetAllowedChannel(void); 839 840 /*---------------------------------------------------------------------------* 841 Name: NWM_CalcLinkLevel 842 843 Description: Calculates the link level from the threshold value defined in nwm_common_private.h. 844 845 Arguments: s16: RSSI value sent with a notification from the Atheros driver 846 847 Returns: u16: The same link level as the WM library. 848 *---------------------------------------------------------------------------*/ 849 u16 NWM_CalcLinkLevel(s16 rssi); 850 851 /*---------------------------------------------------------------------------* 852 Name: NWM_GetDispersionScanPeriod 853 854 Description: Gets the time limit that should be set on searching for an AP or DS parent device as an STA. 855 856 Arguments: u16 scanType: Scan type, either NWM_SCANTYPE_PASSIVE or NWM_SCANTYPE_ACTIVE 857 858 Returns: u16: Search limit time that should be set (ms). 859 *---------------------------------------------------------------------------*/ 860 u16 NWM_GetDispersionScanPeriod(u16 scanType); 861 862 /*---------------------------------------------------------------------------* 863 Name: NWM_GetState 864 865 Description: Gets the NWM state. 866 867 Arguments: None. 868 869 Returns: u16: The NWM state. This is indicated by an NWMState enumerated type. 870 *---------------------------------------------------------------------------*/ 871 u16 NWM_GetState(void); 872 873 /*---------------------------------------------------------------------------* 874 Name: NWM_GetInfoElements 875 876 Description: Gets the specified information element (IE) from BSS data. 877 878 Arguments: bssDesc: BSS data to get 879 elementID: ElementID of an information element, established in 802.11 880 881 Returns: NWMInfoElements: Returns a pointer to the specified information element if it exists. 882 Returns NULL if it could not be obtained. 883 884 *---------------------------------------------------------------------------*/ 885 NWMInfoElements* NWM_GetInfoElements(NWMBssDesc *bssDesc, u8 elementID); 886 887 /*---------------------------------------------------------------------------* 888 Name: NWM_GetVenderInfoElements 889 890 Description: Gets the specified vendor information element (IE) from BSS data. 891 This is used to get information elements for WPA and so on. 892 893 Arguments: bssDesc: BSS data to get 894 elementID: ElementID of an information element, established in 802.11. 895 This must be specified as NWM_ELEMENTID_VENDOR. 896 ouiType: Array of the OUI (3 bytes) and Type (1 byte). 897 For WPA, this is 0x00 0x50 0xf2 0x01. 898 899 Returns: NWMInfoElements: Returns a pointer to the specified vendor information element if it exists. 900 Returns NULL if it could not be obtained. 901 902 *---------------------------------------------------------------------------*/ 903 NWMInfoElements* NWM_GetVenderInfoElements(NWMBssDesc *bssDesc, u8 elementID, const u8 ouiType[4]); 904 905 906 #ifdef __cplusplus 907 } /* extern "C" */ 908 #endif 909 910 #endif /* LIBRARIES_NWM_ARM9_NWM_H__ */ 911 912 /*---------------------------------------------------------------------------* 913 End of file 914 *---------------------------------------------------------------------------*/ 915