完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
我正在测试新的 NON_OS_DSK 2.2.0,它似乎在 WIFI 站连接方面有问题。以下代码在 2.1.0 中工作正常,但在 2.2.0 中 WIFI 继续连接。但从来没有。
struct station_config stconfig; /*if (!wifi_station_get_config(&stconfig)){ os_printf("unable to get STA Config n"); }*/ os_memset(&stconfig, 0x0, sizeof(stconfig)); os_memset(stconfig.ssid, 0, sizeof(stconfig.ssid)); stconfig.threshold.authmode = AUTH_WPA_WPA2_PSK; stconfig.threshold.rssi = 84; os_printf("connecting to %s with %s rssi %d auth %d n", sysCfg.wifi_ssid, wifi_dec_pass, stconfig.threshold.rssi, stconfig.threshold.authmode); os_memset(stconfig.password, 0, sizeof(stconfig.password)); os_sprintf(stconfig.ssid, "%s", (char *) sysCfg.wifi_ssid); os_memcpy(stconfig.password, wifi_dec_pass, os_strlen(wifi_dec_pass)); //wifi_set_opmode(STATION_MODE); if (iWifiMode == STATION_MODE){ wifi_set_opmode((wifi_get_opmode()|STATIONAP_MODE) & iWifiMode); }else { wifi_set_opmode((wifi_get_opmode()|STATIONAP_MODE) & sysCfg.wifi_mode); } if ((sensCfg.szHostName != NULL) && (strlen(sensCfg.szHostName) > 0)){ wifi_station_set_hostname(sensCfg.szHostName); } if (!wifi_station_set_config(&stconfig)) { WIFI_DEBUG("ESP8266 not set station config!rn"); } if (!dhcp || strcmp(dhcp, "dhcp") != 0) { wifi_get_ip_info(STATION_IF, &info); ip = (char *) sysCfg.net_ip; mask = (char *) sysCfg.net_mask; gw = (char *) sysCfg.net_gw; if (ip) info.ip.addr = ipaddr_addr(ip); if (mask) info.netmask.addr = ipaddr_addr(mask); if (gw) info.gw.addr = ipaddr_addr(gw); if (wifi_station_dhcpc_status() == 1) { wifi_station_dhcpc_stop(); } wifi_set_ip_info(STATION_IF, &info); } else { if (wifi_station_dhcpc_status() == 0) { wifi_station_dhcpc_start(); } } wifi_station_disconnect(); wifi_station_connect(); wifi_station_set_重新_policy(TRUE); wifi_station_set_auto_connect(TRUE); 这是输出。它连接的次数很少,下面的大部分时间都会发生 系统初始化... 12345678 sensingp@ssw0rd 管理 使用 12345678 RSSI 84 身份验证 4 连接到 IOTLab 模式:STA(60:01:94:26:5B:6A) 添加 if0 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt 堆 32680 WiFi连接... state: 5 -> 2 (7c0) rm 0 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt 堆 32680 WiFi连接... state: 5 -> 2 (7c0) rm 0 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt state: 5 -> 2 (7c0) rm 0 堆 32680 WiFi连接... 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt state: 5 -> 2 (7c0) rm 0 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt 堆 32680 WiFi连接... state: 5 -> 2 (7c0) rm 0 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt 堆 32680 WiFi连接... state: 5 -> 2 (7c0) rm 0 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 35 cnt 堆 32680 WiFi连接... state: 5 -> 2 (7c0) rm 0 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 32 cnt state: 5 -> 2 (7c0) rm 0 堆 32680 WiFi连接... 重新 state: 2 -> 0 (0) 扫描 state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) 加 0 援助 32 cnt 有人知道为什么吗? |
|
相关推荐
1个回答
|
|
|
首先,我们需要了解您在使用 ESP8266 NON_OS_SDK 2.2.0 时遇到的问题。从您提供的代码片段来看,您正在尝试配置 Wi-Fi 站(STA)并连接到一个 Wi-Fi 网络。在 2.1.0 版本中,这段代码可以正常工作,但在 2.2.0 版本中,Wi-Fi 连接似乎无法成功建立。
在解决这个问题之前,我们需要确保您已经正确地设置了 Wi-Fi 配置结构体 `station_config`。以下是一些建议和可能的解决方案: 1. 确保您的 Wi-Fi 配置是正确的。检查您的 `station_config` 结构体中的 SSID 和密码是否正确。例如: ```c struct station_config stconfig; os_memset(&stconfig, 0x0, sizeof(stconfig)); strcpy((char *)stconfig.ssid, "您的SSID"); strcpy((char *)stconfig.password, "您的密码"); ``` 2. 在设置 Wi-Fi 配置之前,确保 Wi-Fi 已经初始化。您可以使用以下代码初始化 Wi-Fi: ```c wifi_set_opmode(STATION_MODE); ``` 3. 在设置 Wi-Fi 配置后,使用 `wifi_station_set_config()` 函数将配置应用到 Wi-Fi 站: ```c wifi_station_set_config(&stconfig); ``` 4. 使用 `wifi_station_connect()` 函数尝试连接到 Wi-Fi 网络: ```c wifi_station_connect(); ``` 5. 您可以使用 `wifi_station_get_connect_status()` 函数检查 Wi-Fi 连接状态。例如: ```c sint8 status = wifi_station_get_connect_status(); if (status == STATION_GOT_IP) { os_printf("Wi-Fi connected and got IP addressn"); } else { os_printf("Wi-Fi connection failedn"); } ``` 6. 如果您仍然遇到问题,请检查您的硬件和电源供应,确保 ESP8266 模块没有损坏。 7. 另外,您可以尝试升级您的 ESP8266 模块的固件,以解决可能的已知问题。 8. 如果问题仍然存在,您可以考虑在 ESP8266 社区或论坛上寻求帮助,那里可能有其他开发者遇到过类似的问题,并提供了解决方案。 希望这些建议能帮助您解决在使用 ESP8266 NON_OS_SDK 2.2.0 时遇到的 Wi-Fi 连接问题。 |
|
|
|
|
只有小组成员才能发言,加入小组>>
944 浏览 0 评论
1671 浏览 0 评论
请问一下我想用ESP8685直接替换ESP8266而不用写程序,可以让ESP8685直接通过之前ESP8266的外挂的flash运行程序吗
1330 浏览 1 评论
1233 浏览 1 评论
5015 浏览 2 评论
为blufi_device设置自定义名称,但是无法修改,为什么?
1252浏览 4评论
请问ESP32-S2-WROOM怎么获得ESP32-S2外接FLASH的唯一序列号?
927浏览 3评论
2333浏览 3评论
ESP-IDF的VScode插件的build按钮点击会报错的原因?
2526浏览 3评论
ESP-Jumpstart例程中第5个工程:5_cloud连接报错是哪里的问题?
1051浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 23:44 , Processed in 0.603975 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
955
