diff --git a/cores/esp8266/FS.h b/cores/esp8266/FS.h index 55305e9688..5cb08851ff 100644 --- a/cores/esp8266/FS.h +++ b/cores/esp8266/FS.h @@ -79,6 +79,7 @@ class File : public Stream operator bool() const; const char* name() const; const char* fullName() const; // Includes path + const char* path() const { return fullName(); } // esp32 compat bool truncate(uint32_t size); bool isFile() const; @@ -225,6 +226,7 @@ class FS File open(const char* path, const char* mode); File open(const String& path, const char* mode); + File open(const String& path) { return open(path, "r"); } // esp32 compat bool exists(const char* path); bool exists(const String& path); diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h b/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h index 817d323cbf..00f2f26af3 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h @@ -479,21 +479,6 @@ void ESP8266WebServerTemplate::_prepareHeader(String& response, int _responseHeaders = ""; } -template -void ESP8266WebServerTemplate::send(int code, char* content_type, const String& content) { - return send(code, (const char*)content_type, content); -} - -template -void ESP8266WebServerTemplate::send(int code, const char* content_type, const String& content) { - return send(code, content_type, content.c_str(), content.length()); -} - -template -void ESP8266WebServerTemplate::send(int code, const String& content_type, const String& content) { - return send(code, (const char*)content_type.c_str(), content); -} - template void ESP8266WebServerTemplate::sendContent(const String& content) { StreamConstPtr ref(content.c_str(), content.length()); @@ -513,18 +498,6 @@ void ESP8266WebServerTemplate::send(int code, const char* content_ty return sendContent(stream, content_length); } -template -void ESP8266WebServerTemplate::send_P(int code, PGM_P content_type, PGM_P content) { - StreamConstPtr ref(content, strlen_P(content)); - return send(code, String(content_type).c_str(), &ref); -} - -template -void ESP8266WebServerTemplate::send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) { - StreamConstPtr ref(content, contentLength); - return send(code, String(content_type).c_str(), &ref); -} - template void ESP8266WebServerTemplate::sendContent(Stream* content, ssize_t content_length /* = 0*/) { if (_currentMethod == HTTP_HEAD) diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.h b/libraries/ESP8266WebServer/src/ESP8266WebServer.h index e0dba27a90..0ca61553ee 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.h +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.h @@ -155,25 +155,73 @@ class ESP8266WebServerTemplate // code - HTTP response code, can be 200 or 404 // content_type - HTTP content type, like "text/plain" or "image/png" // content - actual content body - void send(int code, const char* content_type = NULL, const String& content = emptyString); - void send(int code, char* content_type, const String& content); - void send(int code, const String& content_type, const String& content); - void send(int code, const char *content_type, const char *content) { + +#if 0 + + void send(int code) { send(code, nullptr, nullptr); } + + template + void send(int code, CT&& content_type, CD&& content) + { + String(std::forward(content_type)) content_type_forwarded; + StreamConstPtr(std::forward(content)) content_forwarded; + send(code, content_type_forwarded.c_str(), &content_forwarded); + } + + template + void send(int code, CT&& content_type, C&& content, size_t content_length) + { + String(std::forward(content_type)) content_type_forwarded; + StreamConstPtr(std::forward(content), content_length) content_forwarded; + send(code, content_type_forwarded.c_str(), &content_forwarded); + } + + template + void send(int code, CT&& content_type, Stream* stream, size_t content_length = 0) + { + String(std::forward(content_type)) content_type_forwarded; + send(code, content_type_forwarded.c_str(), stream, content_length); + } + +send_P + + +#else + + + void send(int code, const char* content_type = NULL, const String& content = emptyString) { + return send(code, content_type, content.c_str(), content.length()); + } + void send(int code, char* content_type, const String& content) { + return send(code, (const char*)content_type, content); + } + void send(int code, const String& content_type, const String& content) { + return send(code, (const char*)content_type.c_str(), content); + } + void send(int code, const char* content_type, const char* content) { send_P(code, content_type, content); } - void send(int code, const char *content_type, const char *content, size_t content_length) { + void send(int code, const char* content_type, const char* content, size_t content_length) { send_P(code, content_type, content, content_length); } - void send(int code, const char *content_type, const uint8_t *content, size_t content_length) { - send_P(code, content_type, (const char *)content, content_length); + void send(int code, const char* content_type, const uint8_t* content, size_t content_length) { + send_P(code, content_type, (const char* )content, content_length); } - void send_P(int code, PGM_P content_type, PGM_P content); - void send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength); - - void send(int code, const char* content_type, Stream* stream, size_t content_length = 0); void send(int code, const char* content_type, Stream& stream, size_t content_length = 0) { send(code, content_type, &stream, content_length); } + void send_P(int code, PGM_P content_type, PGM_P content) { + StreamConstPtr ref(content, strlen_P(content)); + return send(code, String(content_type).c_str(), &ref); + } + void send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) { + StreamConstPtr ref(content, contentLength); + return send(code, String(content_type).c_str(), &ref); + } + +#endif + + void send(int code, const char* content_type, Stream* stream, size_t content_length = 0); void setContentLength(const size_t contentLength); void sendHeader(const String& name, const String& value, bool first = false); diff --git a/libraries/ESP8266WiFi/src/WiFi.h b/libraries/ESP8266WiFi/src/WiFi.h deleted file mode 100644 index 379989252d..0000000000 --- a/libraries/ESP8266WiFi/src/WiFi.h +++ /dev/null @@ -1,2 +0,0 @@ - -#include "ESP8266WiFi.h" \ No newline at end of file diff --git a/libraries/WiFi/keywords.txt b/libraries/WiFi/keywords.txt new file mode 100644 index 0000000000..ad410807c8 --- /dev/null +++ b/libraries/WiFi/keywords.txt @@ -0,0 +1,16 @@ +####################################### +# Datatypes (KEYWORD1) +####################################### + +ESPmDNS KEYWORD1 +FFat KEYWORD1 +WebServer KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/libraries/WiFi/library.properties b/libraries/WiFi/library.properties new file mode 100644 index 0000000000..fc75427459 --- /dev/null +++ b/libraries/WiFi/library.properties @@ -0,0 +1,6 @@ +name=WiFi +version=1.0 +author=esp8266-arduino +maintainer=esp8266-arduino +sentence=convergence headers for esp32-Arduino compatibility +architectures=esp8266 diff --git a/libraries/WiFi/src/ESPmDNS.h b/libraries/WiFi/src/ESPmDNS.h new file mode 100644 index 0000000000..fdf99857f0 --- /dev/null +++ b/libraries/WiFi/src/ESPmDNS.h @@ -0,0 +1,6 @@ + +#pragma once + +#include + +using ESPmDNS = MDNSResponder; diff --git a/libraries/WiFi/src/FFat.h b/libraries/WiFi/src/FFat.h new file mode 100644 index 0000000000..c1618896d1 --- /dev/null +++ b/libraries/WiFi/src/FFat.h @@ -0,0 +1,6 @@ + +#pragma once + +#include + +#define FFat LittleFS diff --git a/libraries/WiFi/src/SPIFFS.h b/libraries/WiFi/src/SPIFFS.h new file mode 100644 index 0000000000..ead67e0b47 --- /dev/null +++ b/libraries/WiFi/src/SPIFFS.h @@ -0,0 +1,4 @@ + +#pragma once + +#include \ No newline at end of file diff --git a/libraries/WiFi/src/WebServer.h b/libraries/WiFi/src/WebServer.h new file mode 100644 index 0000000000..2ddf558e98 --- /dev/null +++ b/libraries/WiFi/src/WebServer.h @@ -0,0 +1,6 @@ + +#pragma once + +#include + +using WebServer = ESP8266WebServer; diff --git a/libraries/WiFi/src/WiFi.h b/libraries/WiFi/src/WiFi.h new file mode 100644 index 0000000000..4d9633d58b --- /dev/null +++ b/libraries/WiFi/src/WiFi.h @@ -0,0 +1,6 @@ + +#pragma once + +#include + +using WiFiClass = ESP8266WiFiClass;