inline void WifiListWidget::Connect() { if (!EnsureConnected()) { ShowMessageBox(_T("Network failure"), _("Connect"), MB_OK); return; } const unsigned i = GetList().GetCursorIndex(); if (i >= networks.size()) return; const auto &info = networks[i]; if (info.id < 0) { const auto ssid = info.ssid; StaticString<256> caption; caption.Format(_("Passphrase of network '%s'"), ssid.c_str()); StaticString<32> passphrase; passphrase.clear(); if (info.security == OPEN_SECURITY) passphrase.clear(); else if (!TextEntryDialog(passphrase, caption, false)) return; if (!WifiConnect(info.security, wpa_supplicant, info.ssid, passphrase)) ShowMessageBox(_T("Network failure"), _("Connect"), MB_OK); } else { if (!wpa_supplicant.RemoveNetwork(info.id) || !wpa_supplicant.SaveConfig()) ShowMessageBox(_T("Error"), _("Remove"), MB_OK); } UpdateList(); }
void* DefaultWifiThread(void *pThreadArg) { int iExit = 0; int iRecv = 0; OTDRMSGQUEUE *pWifiMsg = NULL; pWifiMsg = GetWifiMsgQueue(); printf("enter thd\n"); if(pWifiMsg == NULL) { printf("error, pWifiMsg is NULL\n"); return NULL; } else { ClearOTDRMsgQueue(pWifiMsg); } while (!iExit) { iExit = GetExitFlag(); if (iExit == 1) { break; } iRecv = 0; ReadWifiMsgQueue(&iRecv); if(iRecv) { printf("wifiTHD Recv = %d\n", iRecv); switch(iRecv) { case ENUM_OPEN: WifiOpen(); break; case ENUM_SCAN: WifiScan(); break; case ENUM_SCAN_R: WifiScan_r(); break; case ENUM_CONNECT://victor WifiConnect(); break; default: break; } } else { MsecSleep(30); } } printf("exit thd\n"); return NULL; }