2018-05-06 21:50:47 +02:00
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include <ESP8266WebServer.h>
|
|
|
|
#include <ESP8266NetBIOS.h>
|
|
|
|
|
|
|
|
const char* ssid = "............";
|
|
|
|
const char* password = "..............";
|
|
|
|
|
|
|
|
ESP8266WebServer wwwserver(80);
|
2018-05-06 21:52:40 +02:00
|
|
|
const char PAGE[] PROGMEM = "<!DOCTYPE HTML>\n<html>Hello world from ESP8266<p></html>"
|
2018-05-06 21:50:47 +02:00
|
|
|
|
|
|
|
static void handleRoot(void) {
|
|
|
|
|
2018-05-06 21:52:40 +02:00
|
|
|
wwwserver.send_P(200, F("text/html"), PAGE);
|
2018-05-06 21:50:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
|
|
|
// Connect to WiFi network
|
|
|
|
WiFi.mode(WIFI_STA);
|
|
|
|
WiFi.begin(ssid, password);
|
|
|
|
Serial.println("");
|
|
|
|
|
|
|
|
// Wait for connection
|
|
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
|
|
delay(500);
|
|
|
|
Serial.print(".");
|
|
|
|
}
|
|
|
|
Serial.println("");
|
|
|
|
Serial.print("Connected to ");
|
|
|
|
Serial.println(ssid);
|
|
|
|
Serial.print("IP address: ");
|
|
|
|
Serial.println(WiFi.localIP());
|
|
|
|
|
|
|
|
|
|
|
|
wwwserver.on("/", handleRoot);
|
|
|
|
wwwserver.begin();
|
|
|
|
|
|
|
|
NBNS.begin("ESP");
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
wwwserver.handleClient();
|
|
|
|
}
|