完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
我是 ESP8266 世界的新手,所以请问是否没有足够的信息。
附上方块示意图。 一个网站有 3 个按钮。 1. 下载(从外部存储器下载 csv。STM 通过 UARt 将 csv 发送到 ESP8266。ESP8266 将其发送到计算机) 2.更新(通过 UART 将文件发送到 STM32,芯片将其存储在内存) 3.更改密码(打开一个窗口,我可以在其中更改服务器的密码) 一切都应该通过 ESP8266 自己的 Wifi 网络发送。 我使用 Arduino IDE 对 EPS8266 进行编程。 我该如何实现这样的事情? 我想实现 3 个功能,即完成这三点。 这是我到目前为止编写的代码。 代码:全选#include #include #include #include #include #include #include #include #include "mainpage.h" //Our HTML webpage contents //On board LED Connected to GPIO2 #define LED 2 const char *ssid = "MYESP8266"; const char *password = "123456789"; ESP8266WebServer server(80); void handleRoot() { Serial.println("You called root page"); String s = MAIN_page; //Read HTML contents server.send(200, "text/html", s); //Send web page } void handleDownload(){ // Download a CSV to the Website if (!SPIFFS.begin()) { Serial.println("SPIFFS failed to mount !rn"); } else { String str = ""; File f = SPIFFS.open(server.arg(0), "r"); if (!f) { Serial.println("Can't open SPIFFS file !rn"); } else { char buf[1024]; int siz = f.size(); while(siz > 0) { size_t len = std::min((int)(sizeof(buf) - 1), siz); f.read((uint8_t *)buf, len); buf[len] = 0; str += buf; siz -= sizeof(buf) - 1; } f.close(); server.send(200, "text/plain", str); } } } void handleUpdate() { //Upload a file to the ESP8266 that send it to the //STM32 Serial.println("Update page"); digitalWrite(LED,HIGH); //LED off server.send(200, "text/html", "Update"); //Shows Update } void handleChange_Password() { //Change password of the ESP8266 Serial.println("Change_Password page"); digitalWrite(LED,HIGH); //LED off server.send(200, "text/html", "Change"); //Shows Change } void setup(void){ Serial.begin(115200); SPIFFS.begin(); Serial.println(""); //Onboard LED port Direction output pinMode(LED,OUTPUT); //Power on LED state off digitalWrite(LED,HIGH); WiFi.mode(WIFI_AP); //Only Access point WiFi.softAP(ssid, password); //Start HOTspot removing password will disable security IPAddress myIP = WiFi.softAPIP(); //Get IP address Serial.print("HotSpt IP:"); Serial.println(myIP); server.on("/", handleRoot); //Which routine to handle at root //location. This is display page server.on("/Download", handleDownload); server.on("/Update", handleUpdate); server.on("/Change_Password", handleChange_Password); server.begin(); //Start server Serial.println("HTTP server started"); } void loop() { server.handleClient(); } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
945 浏览 0 评论
1672 浏览 0 评论
请问一下我想用ESP8685直接替换ESP8266而不用写程序,可以让ESP8685直接通过之前ESP8266的外挂的flash运行程序吗
1330 浏览 1 评论
1233 浏览 1 评论
5021 浏览 2 评论
为blufi_device设置自定义名称,但是无法修改,为什么?
1253浏览 4评论
请问ESP32-S2-WROOM怎么获得ESP32-S2外接FLASH的唯一序列号?
927浏览 3评论
2338浏览 3评论
ESP-IDF的VScode插件的build按钮点击会报错的原因?
2527浏览 3评论
ESP-Jumpstart例程中第5个工程:5_cloud连接报错是哪里的问题?
1052浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 06:09 , Processed in 1.752454 second(s), Total 68, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
426
