Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By GregryCM
#28699 I see in GitHub that IGRR had a concern with the proposed changes. I do not know C++, so this may not be correct, but is this how to address the concern?

void ESP8266WebServer::send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) {
String header;
String Content = String(FPSTR(content_type));
_prepareHeader(header, code, Content.c_str(), contentLength);
sendContent(header);
sendContent_P(content, contentLength);
}

Thank You,
GregryCM
User avatar
By martinayotte
#28705
GregryCM wrote:I see in GitHub that IGRR had a concern with the proposed changes. I do not know C++, so this may not be correct, but is this how to address the concern?

IGRR suggested that I placed the temporary string in a separate line.
I've mentioned him that this line was a copy/paste from code of Makuna already present few lines above.
He admit that he missed that, but still suggest me to do the changes, so I will do them today, both in my code and Makuna's code.
Still, it doesn't prevent you to use current version since those lines are working since weeks/months.

EDIT : I've work on the issue, and it turns out to be a bit more complex than I thought.
It seems there was another bug in the original code. I've done a commit, but I'm not sure it will be the last.
User avatar
By woodwax
#28896 But the problem presist when I try to send data through client.println();
Here is my code:
Code: Select all#include <PgmSpace.h>
#include <ESP8266WiFi.h>

const char index_html[] PROGMEM = R"=====(
<!DOCTYPE HTML>
<html>
<head><title>ESP8266 Arduino Demo Page</title></head>
<body>ESP8266 power!<p><img src="logo.png"></body>
</html>
)=====";

const char* ssid = "wifi";
const char* password = "";
WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  server.begin();     // Start the server
}

void loop() {
  WiFiClient client = server.available();
  if (!client) {
   return;
  }
  while(!client.available()){
    delay(1);
  }
 client.println(index_html);
 delay(1000);
}

I get wdt error
Exception (3):