/***************************************************************************** * FUNCTION: iwprivSetCb * * RETURNS: TRUE or FALSE * * PARAMS: None * * NOTES: Set the iwprivCb structure *****************************************************************************/ static BOOL iwprivSetCb(void) { tWFCPElements cprof; BOOL cpIdChanged = FALSE; if ( !iwprivCbInitialized ) // first time call of iwprivSetCb { memset(&iwprivCb, 0, sizeof(iwprivCb)); iwprivCbInitialized = TRUE; } if (!g_hibernate_state && !iwconfigSetCb() ) // first set iwconfigCb return FALSE; if ( iwprivCb.cpId != iwconfigCb.cpId) { iwprivCb.cpId = iwconfigCb.cpId; cpIdChanged = TRUE; } WF_CPGetElements(iwprivCb.cpId, &cprof); // set refreshable part of iwprivCb { memcpy((void*)iwprivCb.ssid, (const void*)cprof.ssid, cprof.ssidLength); iwprivCb.ssid[cprof.ssidLength] = '\0'; iwprivCb.wepDefaultKeyId = cprof.wepDefaultKeyId; } // set non-refreshable part of iwprivCb only when cpId has changed if (cpIdChanged) { iwprivCb.securityType = cprof.securityType; if (iwprivCb.securityType == WF_SECURITY_WPA_WITH_KEY || iwprivCb.securityType == WF_SECURITY_WPA2_WITH_KEY) { iwprivCb.securityType = WF_SECURITY_WPA_AUTO_WITH_KEY; } else if (iwprivCb.securityType == WF_SECURITY_WPA_WITH_PASS_PHRASE || iwprivCb.securityType == WF_SECURITY_WPA2_WITH_PASS_PHRASE) { iwprivCb.securityType = WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE; } iwprivCb.securityKeyLength = 0; } return TRUE; }
/***************************************************************************** * FUNCTION: iwprivSetCb * * RETURNS: true or false * * PARAMS: none * * NOTES: Set the iwprivCb structure *****************************************************************************/ static bool iwprivSetCb(void) { tWFCPElements cprof; bool cpIdChanged = false; if ( !iwprivCbInitialized ) // first time call of iwprivSetCb { memset(&iwprivCb, 0, sizeof(iwprivCb)); iwprivCbInitialized = true; } if (!WF_hibernate.state && !iwconfigSetCb() ) // first set iwconfigCb return false; if ( iwprivCb.cpId != iwconfigCb.cpId) { iwprivCb.cpId = iwconfigCb.cpId; cpIdChanged = true; } WF_CPGetElements(iwprivCb.cpId, &cprof); // set refreshable part of iwprivCb { memcpy((void*)iwprivCb.ssid, (const void*)cprof.ssid, cprof.ssidLength); iwprivCb.ssid[cprof.ssidLength] = '\0'; iwprivCb.wepDefaultKeyId = cprof.wepDefaultKeyId; } // set non-refreshable part of iwprivCb only when cpId has changed if (cpIdChanged) { iwprivCb.securityType = cprof.securityType; iwprivCb.securityKeyLength = 0; } return true; }
/******************************************************************************* Function: void do_iwconfig_cmd(void) Summary: Responds to the user invoking iwconfig command Description: Responds to the user invoking iwconfig command Precondition: MACInit must be called first. Parameters: None. Returns: None. Remarks: None. *****************************************************************************/ void do_iwconfig_cmd(void) { if (!WF_hibernate.state && !iwconfigSetCb() ) return; // if user only typed in iwconfig with no other parameters if (ARGC == 1u) { if (!WF_hibernate.state) iwconfigDisplayStatus(); else #if defined(STACK_USE_UART) WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode - command failed.", TRUE); #endif return; } if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "wakeup") == 0) ) { if (!WF_hibernate.wakeup_notice) { WF_hibernate.wakeup_notice = TRUE; } #if defined(STACK_USE_UART) WFConsolePrintRomStr("The Wi-Fi module is awake.", TRUE); #endif return; } if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "hibernate") == 0) ) { if (!WF_hibernate.state) { WF_hibernate.state = WF_HB_ENTER_SLEEP; WF_hibernate.wakeup_notice = FALSE; WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode.", TRUE); } else WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode.", TRUE); return; } if (WF_hibernate.state) { WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode - command failed.", TRUE); return; } if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "ssid") == 0) ) { if (!WF_hibernate.state && !iwconfigSetSsid()) return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "mode") == 0) ) { if (!WF_hibernate.state && !iwconfigSetMode()) return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "channel") == 0) ) { if (!WF_hibernate.state && !iwconfigSetChannel()) return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "power") == 0) ) { if (!WF_hibernate.state && !iwconfigSetPower()) return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "domain") == 0) ) { if (!WF_hibernate.state && !iwconfigSetDomain()) return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "rts") == 0) ) { if (!WF_hibernate.state && !iwconfigSetRTS()) return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "txrate") == 0) ) { // txrate is NOT available. Will always return FALSE if (!WF_hibernate.state && !iwconfigSetTxRate()) return; } #if defined ( EZ_CONFIG_SCAN ) && !defined(__18CXX) else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "scan") == 0)) { if (!WF_hibernate.state) { // WFInitScan(); WFConsolePrintRomStr("Scanning...", TRUE); if (WFStartScan() == WF_SUCCESS) { WFConsolePrintRomStr("Scan completed.", TRUE); } else { WFConsolePrintRomStr("Scan failed. Already in progress or not allowed", TRUE); } } else { WFConsolePrintRomStr("In hibernate mode - scan is not allowed.", TRUE); } return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "scanresults") == 0) ) { if (IS_SCAN_IN_PROGRESS(SCANCXT.scanState)) WFConsolePrintRomStr("Scann in process...please wait or try again later", TRUE); else if (SCANCXT.numScanResults > 0) { SCAN_SET_DISPLAY(SCANCXT.scanState); SCANCXT.displayIdx = 0; while (IS_SCAN_STATE_DISPLAY(SCANCXT.scanState)) { WFDisplayScanMgr(); } } else WFConsolePrintRomStr("No scan results to display.", TRUE); return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "starttest") == 0)) { test_flag = TRUE; test_count = 0; return; } else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "stoptest") == 0)) { test_flag = FALSE; return; } #endif /* EZ_CONFIG_SCAN */ else if( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "connect") == 0)) { iwconfigSetConnect(); return; } #ifdef STACK_USE_CERTIFICATE_DEBUG else if( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "macstats") == 0)) { iwconfigGetMacStats(); return; } #endif else { WFConsolePrintRomStr("Unknown parameter", TRUE); return; } }