如何修复 ESP8266 PlatformIO error: WIFI_STA was not declared in this scope
问题:
编译 PlatformIO 固件时,你看到类似这样的错误消息
example-4.txt
src/main.cpp:49:10: error: 'class WiFiClass' has no member named 'mode'
49 | WiFi.mode(WIFI_STA);
| ^~~~
src/main.cpp:49:15: error: 'WIFI_STA' was not declared in this scope
49 | WiFi.mode(WIFI_STA);
| ^~~~~~~~解决方案
你包含了 WiFi.h 而不是正确的 ESP8266WiFi.h。这会导致多个问题,如 WiFi.begin() 上的重启,即使它正确编译。
替换
example-3.cpp
为
example-2.cpp
在源代码中的所有位置,并且不支持
example-1.txt
有关更多详细信息,请参见我们之前关于如何修复 PlatformIO ESP8266 WiFi.h: No Such File or Directory的文章
Check out similar posts by category:
Electronics, ESP8266/ESP32, PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow