コード例 #1
0
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;
}
コード例 #2
0
ファイル: Wifi.c プロジェクト: superqqgto/pos2.0
//选择WIFI打开模式, 是扫描周围的热点,还是手工输入SSID
int SelectWifiMode(void)
{
	int iRet = 0;
	uchar ucKey;

	while(1)
	{
		kbflush();
		ScrCls();
		PubDispString(_T("WIFI"), DISP_LINE_CENTER|0);
		ScrPrint(0, 1, 0, _T("1 - SEARCH NETWORK"));
		ScrPrint(0, 2, 0, _T("2 - MANUAL")); 

		ucKey = PubWaitKey(USER_OPER_TIMEOUT);

		if (ucKey == KEY1) 
		{
			iRet = ScanWifiAps();
			if (iRet) 
			{
				//add by wuc 2014.3.24
				if(WIFI_ERR_SCAN == iRet)
				{
					WifiClose();
					iRet = WifiOpen();
					if(iRet)
					{
						ScrClrBelow(1);
						ScrPrint(0, 2, 0, "OpenWifi err=%d", iRet); 
						PubWaitKey(5);
						break;
					}
				}
				continue;
			}
			break;
		}

		if (ucKey == KEY2) 
		{
			iRet = ManualWifiAps();
			if (iRet) 
			{
				continue;
			}
			break;
		}

		if (ucKey == KEYCANCEL || ucKey == NOKEY) 
		{
			return ucKey;
		}
	}

	return iRet;
}