一片冰心在玉壶

那时我们有梦,关于文学,关于爱情,关于穿越世界的旅行, 如今我们深夜饮酒,杯子碰到一起,都是梦破碎的声音. 交往都是初逢,爱情都在心里,往事都在梦中, 希望都带着注释,信仰都带着呻吟. 总有善意的光逃避现世的繁琐而寻找片刻的安宁, 也许,就是你凝视这里的眼睛

博客园 首页 联系 订阅 管理

资料不多。多是国外网站的。

百度搜基本出来的是这个网站https://www.dfrobot.com/blog-922.html

出来的代码是:

#include <WiFi.h>
#include <FS.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
 
const char* ssid = "yourNetworkName";
const char* password =  "yourNetworkPassword";
 
AsyncWebServer server(80);
 
void setup(){
  Serial.begin(115200);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println(WiFi.localIP());
 
  server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/html", "<p>This is HTML!</p>");
  });
 
  server.begin();
}
 
void loop(){
}

 

发愁:这个库在哪里?我怎么运行?于是我找到了这里:

https://github.com/me-no-dev/ESPAsyncWebServer

 

里面使用ESPAsyncWebServer的步骤

如下:

1   安装:PlatformIO IDE

这里有详细教材:https://blog.csdn.net/baimei4833953/article/details/78771611/

2 创建新的工程:"PlatformIO Home > New Project"

http://docs.platformio.org/en/latest/ide/vscode.html

 

3 修改配置文件

Add "ESP Async WebServer" to project using Project Configuration File platformio.ini and lib_deps option:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
# using the latest stable version
lib_deps = ESP Async WebServer
 
打開main.c
 
 
#include <WiFi.h>
#include <FS.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
 
const char *ssid = "MyESP32AP";
const char *password = "testpassword";
 
AsyncWebServer server(80);
 
void setup(){
  Serial.begin(115200);
 
  WiFi.softAP(ssid, password);
 
  Serial.println();
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
 
  server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/plain", "Hello World");
  });
 
  server.begin();
}
 
void loop(){}

 

编译运行下载,搞定。。。。

 
posted on 2018-06-27 16:13  Sankye  阅读(12604)  评论(1编辑  收藏  举报