void wl_set_key(char *key) { if (strlen(key) > KEY_LEN) key[KEY_LEN] = 0; InfKeySet(0, (unsigned char *)key, strlen(key)); }
/* * Station Mode * Set WIFI to station mode, link up with StaSsid and StaPass parameters. * flag: 0:used SysParam parameters, 1:used staSsid and StaPass parameters. * */ int DRV_WiFi_StaModeConnStart(char *StaSsid, char *StaPass, int flag) { IP_CFG IpParam; /* Start Wifi STA mode and connect to the AP with StaSsid and StaPass. * */ InfWiFiStop(); OSTimeDly(10); if (flag == 1) { InfLoadDefaultParam(); memset(&IpParam, 0, sizeof(IpParam)); IpParam.DhcpTryTimes = 0; IpParam.bDhcp = 1; InfIpSet(&IpParam); InfConTryTimesSet(5); InfNetModeSet(PARAM_NET_MODE_STA_BSS); InfEncModeSet(PARAM_ENC_MODE_AUTO); InfSsidSet((UINT8 *)StaSsid, strlen(StaSsid)); /* set ssid */ InfKeySet(0, (UINT8 *)StaPass, strlen(StaPass)); /* set pw */ log_info("Connecting to AP(%s,%s)...\n\n", StaSsid, StaPass); } else { InfNetModeSet(PARAM_NET_MODE_STA_BSS); InfConTryTimesSet(5); log_info("Start wifi connection.\n"); } InfWiFiStart(); OSTimeDly(10); wifi_sta_connect_ap_flag = 2; /* poll to get wifi status change */ while (wifi_sta_connect_ap_flag == 2) { OSTimeDly(10); } if (wifi_sta_connect_ap_flag == 1) { return 0; } else { return -1; } }