Go Down

Topic: Ethernet Server Questions (Read 74 times) previous topic - next topic

jogl8

I have a bunch of Uno's with ethernet cards collecting data.  The data is sent to a PC running a Python program that commits the data to an Sqlite3 database.

This works very well for me but there are a few glitches that I am working out.

For the arduino program I started with the WebServer example https://www.arduino.cc/en/Tutorial/WebServer and modified it to send back my data.

I removed the client.print's and added my data, before:

Code: [Select]
if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          break;
        }


After:

Code: [Select]
if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
         
          client.println("my data in string form");
         
          client.println("</html>");
          break;
        }


My question is, is the "standard http response header" that I removed something that should have left in?

If so what is the minimum header required?

Thanks.

PaulS

Quote
My question is, is the "standard http response header" that I removed something that should have left in?
That depends on whether the script on the server requires it. You have not defined what server you are communicating with, or which script you are running on the server.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy