Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By danbicks
#26557 Hi,

I added your statement to the easy web config example posted here with the following mods:
server.client().print(( 200, "text/html", reinterpret_cast<const __FlashStringHelper *>(PAGE_NetworkConfiguration)) );

Now when I try to access page it just sits there spinning waiting, page is never refreshed. Any ideas why this method does not work in the easy web config example?

Cheers Dans
User avatar
By martinayotte
#26572
danbicks wrote:server.client().print(( 200, "text/html", reinterpret_cast<const __FlashStringHelper *>(PAGE_NetworkConfiguration)) );

@Dan, the print() method doesn't have the 3 arguments, so the above code just freeze your ESP since it try to print a string located at memory address 200. Change it with the above :
Code: Select allserver.client().print(reinterpret_cast<const __FlashStringHelper *>(PAGE_NetworkConfiguration) );
User avatar
By eldonb46
#26582
danbicks wrote:Hi,

I added your statement to the easy web config example posted here with the following mods:
server.client().print(( 200, "text/html", reinterpret_cast<const __FlashStringHelper *>(PAGE_NetworkConfiguration)) );

Now when I try to access page it just sits there spinning waiting, page is never refreshed. Any ideas why this method does not work in the easy web config example?

Cheers Dans



Dan,
Sorry, the "server.client().print()" function is not a direct replacement for "server.send()", the later automatically does the HTTP headers for you. I use something like the following for each new page:

Code: Select all   
// HTTP Header
server.client().print( "HTTP/1.1 200 OK" );
server.client().print( "Content-Type: text/html" );
server.client().print( ); // A Required Blank Line

// Normal HTML Page Text
server.client().print( "Some Text Stuff" );
.
.


I hope this helps.

Eldon - WA0UWH
User avatar
By DaniloFix
#26605 Great writeup - but just to compare. I'm sending a 152,7 KB page to my browser in 0,3 - 0,4 seconds. 120 KB is bootstrap CSS from a CDN so not directly from the ESP. So to be fair I removed that css from my page - 215 lines of code for the HTML and CSS. Now the size was down to approx 10 KB reported in Safari and a transfer speed of 0,15 - 0,2 seconds. Pretty fast IMO.

I cleared my cache after each run...

I'm writing the code to the ESP flash like this:

Code: Select all  String str = "";
  str += F("<!DOCTYPE html>");
  str += F("<html>");
  str += F("  <head>");
  str += F("    <title>Page title</title>");
  str += F("    <link rel='stylesheet' type='text/css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>");
  str += F("    <style>");
  str += F("    </style>");
  str += F("    <meta charset='utf-8' />");
  str += F("    <meta name='viewport' content='width=device-width, initial-scale=1'>");
  str += F("  </head>");
  str += F("  <body>");
  str += F("    <div class='container'><form method='post' enctype='multipart/form-data' accept-charset='UTF-8'>");
  str += F("      <div class='section'>");
  str += F("      </div>");
  str += F("    </form></div>");
  str += F("  </body>");
  str += F("</html>");
  WebServer.send(200, "text/html", str);


As you can see, I'm using the server.send variant, so it seems writing to flash also makes a considerable impact on load times. :-)