esp32 openharmony5.0.2 wifi连接失败
-
介绍问题现象和发生的背景
(1)参考拓维信息的 niobeu4 开发板,在 esp32 上移植了 openharmony5.0.2,编译烧录测试简单程序,系统正常运行,串口正常输出。
(2)测试 wifi 功能,按照 openharmony wifi sta 功能 api 开发 wifi 程序,结果发现只能连接上没有密码的热点,无法连接有密码的热点。
(3)使用 esp-idf 原生的 api 开发 wifi(系统环境是 openharmony,只更换 api),结果也是只能连接没有密码的热点,无法连接带密码的热点。(4)直接烧录esp官方wifi例程,wifi功能一切正常。 - 相关的代码
int WifiConnect(void)
{
WifiScanInfo *info = NULL;
unsigned int size = WIFI_SCAN_HOTSPOT_LIMIT;
static struct netif *g_lwip_netif = NULL;
WifiDeviceConfig select_ap_config = {0};
int result;
osDelay(OD_DELAY_200);
printf("<--System Init-->\r\n");
WiFiInit();
printf(" Wifi Init succeed! \r\n");
if (EnableWifi() != WIFI_SUCCESS) {
printf("EnableWifi failed, wifi_error = %d\n", wifi_error);
return -1;
}
printf(" EnableWifi succeed! \r\n");
if (IsWifiActive() == 0) {
printf("Wifi station is not actived.\n");
return -1;
}
printf(" Wifi station is actived! \r\n");
info = malloc(sizeof(WifiScanInfo) * WIFI_SCAN_HOTSPOT_LIMIT);
if (info == NULL) {
printf("faild to create wifiscanInfo.\n");
return -1;
}
printf(" Wifi Scan start! \r\n");
do {
ssid_count = 0;
g_staScanSuccess = 0;
Scan();
WaitScanResult();
wifi_error = GetScanInfoList(info, &size);
} while (g_staScanSuccess != 1);
printf(" Wifi Scan end! \r\n");//连接指定的WiFi热点
strcpy(select_ap_config.ssid, SELECT_WIFI_SSID);
strcpy(select_ap_config.preSharedKey, SELECT_WIFI_PASSWORD);
printf("[%s][%s] \r\n", select_ap_config.ssid, select_ap_config.preSharedKey);
select_ap_config.securityType = WIFI_SEC_TYPE_PSK;if (AddDeviceConfig(&select_ap_config, &result) == WIFI_SUCCESS)
{
int ret = ConnectTo(result);
printf("\r\n ConnectTo: %d \r\n", ret);
if ( ret == WIFI_SUCCESS && WaitConnectResult() == 1)
{
printf("WiFi connect succeed!\r\n");
}else
{
printf("WiFi connect failed!\r\n");
}
}for(;;)
{
osDelay(100);
}
} -
运行结果、错误截图
连接有密码的热点(连接失败),串口输出如下内容:
[15:24:26.438]收←◆WaitScanResult:wait success[3]s
Wifi Scan end!
[BearPi][0987654321]
************ ready add
****************** AddDeviceConfig: 0
Error WifiLite.ConnectTo.************ [BearPi] [0987654321][15:24:27.062]收←◆ drop it
E (3249) wifi:AP has neither DSSS parameter nor HT Information, drop it
E (6029) wifi:AP has neither DSSS parameter nor HT Information, drop it
E (6119) wifi:AP has neither DSSS parameter nor HT Information, drop it
E (6129) wifi:AP has neither DS
[15:24:27.661]收←◆SS parameter nor HT Information, drop it
I (6629) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
I (6629) wifi:state: init -> auth (b0)
I (6629) wifi:state: auth -> assoc (0)
E (6639) wifi:Set status to INIT
I (6639) wifi:state: assoc -> initconnect wifi_error, please check password, state:0, try connect again[15:24:28.481]收←◆ (2d00)
I (6639) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
E (7449) wifi:AP has neither DSSS parameter nor H
[15:24:28.583]收←◆T Information, drop it
E (7459) wifi:AP has neither DSSS parameter nor HT Information, drop it
E (7549) wifi:AP has neither DSSS
[15:24:28.939]收←◆Error WifiLite.ConnectTo. ******************************* esp_wifi_connect successConnectTo: 0
[15:24:29.730]收←◆connect wifi_error, please check password, state:0, try connect again
parameter nor HT Information, drop it
I (8699) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (8699) wifi:state: init -> auth (b0)
I (8709) wifi:state: auth -> assoc (0)
E (8719) wifi:Set status to INIT
I (8719) wifi:state: assoc -> init connect wifi_error, please check password, state:0, try connect again
- 点赞
- 收藏
- 关注作者
评论(0)