Newest update 1.8.13 broke HTTP_Req's

Was following up on an web server arduino that has been working okey. I needed to add watchdog to it as I was having issues after 2-3 weeks of it locking up and needing an manual reset. Thus why I wish to add watchdog. After grabbing the file for it, and uploading it I now get a list of the following errors:

D:\Info\Arduino\Projects\WEB_ExtronController\WEB_ExtronController_Complete_Rev03.2_Updated\WEB_ExtronController_Complete_Rev03.2_Updated.ino: In function 'void loop()':
D:\Info\Arduino\Projects\WEB_ExtronController\WEB_ExtronController_Complete_Rev03.2_Updated\WEB_ExtronController_Complete_Rev03.2_Updated.ino:181:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
           if (StrContains(HTTP_req, "GET / ")
                                             ^
D:\Info\Arduino\Projects\WEB_ExtronController\WEB_ExtronController_Complete_Rev03.2_Updated\WEB_ExtronController_Complete_Rev03.2_Updated.ino:182:52: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
           || StrContains(HTTP_req, "GET /index.htm")) {
                                                    ^
D:\Info\Arduino\Projects\WEB_ExtronController\WEB_ExtronController_Complete_Rev03.2_Updated\WEB_ExtronController_Complete_Rev03.2_Updated.ino:192:61: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
           else if (StrContains(HTTP_req, "GET /temperat.htm")) {
                                                             ^
D:\Info\Arduino\Projects\WEB_ExtronController\WEB_ExtronController_Complete_Rev03.2_Updated\WEB_ExtronController_Complete_Rev03.2_Updated.ino:230:55: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
           else if (StrContains(HTTP_req, "GET /output")) {
                                                       ^
D:\Info\Arduino\Projects\WEB_ExtronController\WEB_ExtronController_Complete_Rev03.2_Updated\WEB_ExtronController_Complete_Rev03.2_Updated.ino:253:42: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
             if (StrContains(HTTP_req, "?")) {

Yes these are just warnings. But they have now broken my program. Arduino is able to show my temperat.htm file on a web page, but that is only cause arduino is writing it. All the other ones, are pulling from the SDcard to open the existing html file and post it.

How can I correct this error? and go back to it working again?

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

#define REQ_BUF_SZ 24   // NO semi-colon needed. This number represents the number of character spaces allotted for the GET /output00.htm?v02 url.

byte mac[] = {
  0x90, 0xA2, 0xDA, 0x00, 0x9A, 0x59
};  // Arduino Extron Web Controller

IPAddress ip(10, 0, 0, 89);   // IP address, may need to change depending on network
EthernetServer server(80);       // create a server at port 80
File webFile;                    // handle to files on SD card
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer

#include <SoftwareSerial.h>
SoftwareSerial softwareSerial(2, 3);  //creation of soft serial port. [name of new port](TX-0 pin, RX-1 pin)

int extron_input = 0;
int extron_output = 0;
int questionmark_pos = 0;
#include <math.h>
double Thermister(int RawADC) {
  double Temp;
  Temp = log(((10240000 / RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp )) * Temp );
  Temp = Temp - 273.15;            // Convert Kelvin to Celcius
  // Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
  Temp = (Temp * 9.0) / 5.0 + 32.0;
  return Temp;
}
void setup()
{
  //wdt_disable();        // immediately disable watchdog timer so setup will not get interrupted
  // ========== ETHERNET PART ==========
  // disable Ethernet chip
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  Ethernet.begin(mac, ip);  // initialize Ethernet device
  server.begin();           // start to listen for clients

  Serial.begin(9600);       // for debugging
  softwareSerial.begin(9600);

  if (!SD.begin(4)) {
    return;    // init failed
  }

  if (!SD.exists("index.htm")) {
    return;  // can't find index file
  }
 
}


void loop()
{
  EthernetClient client = server.available();  // try to get client

  if (client) {  // got client?
    Serial.println("Ethernet Client");
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {   // client data available to read
        char c = client.read(); // read 1 byte (character) from client
        if (req_index < (REQ_BUF_SZ - 1)) {
          HTTP_req[req_index] = c;          // save HTTP request character
          req_index++;
        }

        if (c == '\n' && currentLineIsBlank) {

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();


          if (StrContains(HTTP_req, "GET / ") 
          || StrContains(HTTP_req, "GET /index.htm")) {
            Serial.println("I want index");
            webFile = SD.open("index.htm");        // open web page file
            Serial.println("opened indexy");
          }
          /* else if (StrContains(HTTP_req, "GET /page2.htm")) {
            webFile = SD.open("page2.htm");        // open web page file
            } */

          else if (StrContains(HTTP_req, "GET /temperat.htm")) {
            // webFile = SD.open("temperat.htm");        // open temperature sensors.
            client.print("<sensor>");
            client.print(float(Thermister(analogRead(0))));  // display Fahrenheit
            client.print(",");
            client.print(float(Thermister(analogRead(1))));
            client.print(",");
            client.print(float(Thermister(analogRead(2))));
            client.print(",");
            client.print(float(Thermister(analogRead(3))));
            client.print(",");
            client.print(float(Thermister(analogRead(4))));
            client.print(",");
            client.print(float(Thermister(analogRead(5))));
            client.println("</sensor>");
            client.println("<sockclose>");
          }
          else if (StrContains(HTTP_req, "GET /output")) {
            char webFileString[] = "output00.htm";  // Preps for 12 characters  (o u t p u t ? ? . h t m)
            webFileString[6] = HTTP_req[11]; // grabs the 11th position character from HTTP_req[GET /output01.htm HTTP/]
            webFileString[7] = HTTP_req[12]; // grabs the 12th position character from HTTP_req[GET /output01.htm HTTP/]
            webFile = SD.open(webFileString);        // open web page file with modified webFileString
            if (StrContains(HTTP_req, "?")) {
              
              extron_input_select();
            }
          }
          if (webFile) {
            while (webFile.available()) {
              client.write(webFile.read());
            }
            webFile.close();
          }
          // reset buffer index and all buffer elements to 0
          req_index = 0;
          StrClear(HTTP_req, REQ_BUF_SZ);
          break;
        }
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
         currentLineIsBlank = false;
        }
      } // end if (client.available())
    } // end while (client.connected())
    delay(1);      // give the web browser time to receive the data
    client.stop(); // close the connection
  } 

  if (Serial.available()) {           //if you are typing on Arduinos COM port, it will show up on the soft COM port.
    softwareSerial.write(Serial.read());
  }
  if (softwareSerial.available())         //if you are typing on your soft com port (ex: via Hyperterminal) it will write that on the Arduino USB-COM port
    Serial.write(softwareSerial.read());
}

void StrClear(char *str, char length)
{
  for (int i = 0; i < length; i++) {
    str[i] = 0;
  }
}
char StrContains(char *str, char *sfind)
{
 
  char found = 0;  // Creates a character count. which begins with 0
  char index = 0;  // Creates a character count. which begins with 0.
  char len;        // Counts the lenght.
  len = strlen(str); // Figures out how long the character string is by looking at the strlen(str) count

  if (strlen(sfind) > len) {
    return 0;
  }
  while (index < len) {
    if (str[index] == sfind[found]) {
      found++;
      if (strlen(sfind) == found) {
        questionmark_pos = (int) index; //Sets the int based on where the ? is found.
        return 1;
      }
    }
    else {
      found = 0;
    }
    index++;
  }
  return 0;
}

eqrunner:
But they have now broken my program.

What makes you think that?

Solved:
I have found an answer to my own problem. It is the library file for Ethernet 2.0.0 is broken. Rolling back to the Ethernet Library file 1.1.2 and everything is working fine again.

I am still getting the errors about converting a string to 'char*' but the code is back to working correctly, and now will correctly load the html pages from the sd card

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.