四博智联产品售后

标题: 设置Wifi热点 [打印本页]

作者: ycf    时间: 2015-12-28 18:06
标题: 设置Wifi热点
  1. /*
  2. 可以将您的espduino设置为wifi热点(Soft AP 模式)
  3. */
  4. #include <ESP8266WiFi.h>
  5. /* Create a WiFi access point and provide a web server on it. */
  6. #include <WiFiClient.h>
  7. #include <ESP8266WebServer.h>

  8. /* Set these to your desired credentials. */
  9. const char *ssid = "Charlie Testing AP";
  10. const char *password = "11111111";

  11. ESP8266WebServer server(80);

  12. /* Just a little test message.  Go to http://192.168.4.1 in a web browser
  13. * connected to this access point to see it.
  14. */
  15. void handleRoot() {
  16.   server.send(200, "text/html", "<h1>You are connected</h1>");
  17. }

  18. void setup() {
  19.   delay(1000);
  20.   Serial.begin(115200);
  21.   Serial.println();
  22.   Serial.print("Configuring access point...");
  23.   /* You can remove the password parameter if you want the AP to be open. */
  24.   WiFi.softAP(ssid, password);

  25.   IPAddress myIP = WiFi.softAPIP();
  26.   Serial.print("AP IP address: ");
  27.   Serial.println(myIP);
  28.   server.on("/", handleRoot);
  29.   server.begin();
  30.   Serial.println("HTTP server started");
  31. }

  32. void loop() {
  33.   server.handleClient();
  34. }
复制代码







欢迎光临 四博智联产品售后 (http://bbs.doit.am/) Powered by Discuz! X3.2