The plan is to create a bigger project and to split the ESP8266 webserver-code over several modules (.h .c files). The main problem is that the ESP8266WebServer server is not declared in the index.h and index.c files.
What I've been trying to do:
Content main.c
#include <ESP8266WiFi.h>
#include "ESP8266WebServer.h"
#include "index.h"
ESP8266WebServer server(80);
const char* ssid = "test";
const char* password = "12345678";
void setup()
{
WiFi.softAP(ssid, password);
server.on("/", handleRoot(server)); // <-- use of deleted function 'esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::ESP8266WebServerTemplate(const esp8266webserver::ESP8266WebServerTemplate<WiFiServer>&)'
server.begin();
}
void loop()
{
server1.handleClient();
}
Content index.h:
void handleRoot(ESP8266WebServer server);
const char htmlIndex[] PROGMEM = R"=====(
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
)=====";
Content index.c:
#include "webpages/index.h"
void handleRoot(ESP8266WebServer server)
{
Serial.println("GET /");
server.send(200, "text/html", htmlIndex);
}
How can I use the ESP8266WebServer server created in the main.c in index.c?