I'm trying to tweet the combination of dynamic data (currently figured out), but also the input that a user would enter into a form field. I'm having a hard time figuring out POST and GET stuff, and although I watch the stuff scroll by in the console, I don't see the stuff I've entered and submitted on the form field from the Web Server (Well Structured). I'm sure I'm just way in over my head, but I don't see where that data goes, and am not sure how to 'parse' something out of it. Could someone point me in the right direction on how to get this data from a fold field and store it as a variable for later use, etc?
and although I watch the stuff scroll by in the console, I don't see the stuff I've entered and submitted on the form field from the Web Server
I've read your post several times, and I don't see your code. So, we're even.
I tried to paste the code but it said it was too long. So I uploaded a text file of it to my ftp.
Your readHTTPRequest() function has some serious flaws. You test that there is at least one character to read from the client, and then proceed to read as many as you want. That doesn't work.
The carriage return would really make your code more readable.
What does the page source look like when the form arrives at the browser? What does your serial output look like?
GET compare: GET /
Grepped page: 1
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Vary: Accept-Encoding
Date: Sun, 16 Dec 2012 16:35:52 GMT
Server: Google Frontend
OKOK.
GET compare: GET /
POST compare: POST /
GET compare: GET /page2
POST compare: POST /page2
GET compare: GET /page3
POST compare: POST /page3
GET compare: GET /page4
POST compare: POST /page4
GET compare: GET /login
POST compare: POST /login
Grepped page: 5
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Vary: Accept-Encoding
Date: Sun, 16 Dec 2012 16:36:04 GMT
Server: Google Frontend
OKOK.
The proper ratio of answers to questions is 1 to 1.
<html>
<head>
<title>Arduino Web Server Demo</title>
<link rel='stylesheet' href='http://www.provolveentertainment.com/filebin/bootstrap.css'>
</head>
<body>
<div class="container">
<h1>Arduino Web Server Demo</h1>
<table width="500">
<tr>
<td align="center"><a href="/">Index</a></td>
<td align="center"><a href="page2">Page 2</a></td>
<td align="center"><a href="page3">Page 3</a></td>
<td align="center"><a href="page4">Page 4</a></td>
</tr>
</table>
<h2>Index</h2><hr />
<p>Arduino is a pretty incredible thing. It's an open-source electronics prototyping platform that allows for the rapid development of hardware and software together. It's helping to fuel the Maker Movement - if you've ever been interested in inventing or problem solving, you'd be hard-pressed to find a more active, intelligent, or robust community as the people who work with Arduino. Stay awhile.</p>
<form action="/login" method="POST"><input type="text" name="prova" style="height:auto; margin:10px"><input type="submit" value="Submit" class="btn btn-primary"></form>
</body></html><p class="text-info">analog input 0 is 387
</p>
if (client.connected() && client.available()) { // read a row
buffer[0] = client.read();
buffer[1] = client.read();
bufindex = 2;
// read the first line to determinate the request page
while (buffer[bufindex-2] != '\r' && buffer[bufindex-1] != '\n') { // read full row and save it in buffer
c = client.read();
if (bufindex<STRING_BUFFER_SIZE) buffer[bufindex] = c;
bufindex++;
}
If there is at least one character from the server in the buffer, read all three. Don't print c and don't print buffer, and don't NULL terminate buffer. OK, I'll bite. Why?
It's a basic proof of concept that I'm putting together. It's honestly not 'for' anything in particular, I just have a few projects coming up that I plan to use a Web Server for, and when I tossed this on my Uno+Ethernet...
http://playground.arduino.cc/Code/WebServer
I saw there was a neat little form field. So I thought - "Hey, it'd be kinda cool if I could gather form data, and then tweet the value of a sensor... all with one web button." That was about it. I created a problem for myself and found that I didn't know how to (start solving) solve it. After trying to make sense of the Web Server Sketch above, I realized I was in over my head and thought I'd send an SOS to the community since they've been massive help before. I'm kinda new to parsing data, regex, and other stuff that most people probably think are basic. Sorry.
An arduino can run both client and server code at the same time. Sounds like you want the server to evaluate data submitted via a form in a web page, and then have the arduino client pass that data to a tweet server. It also sounds like you want the arduino evaluating its inputs and also pass that data on to a tweet server. If this the case, have you worked on any of these particular parts?
and when I tossed this on my Uno+Ethernet...
Unfortunately, that is a pretty lousy example of reading client data.
Still, there is the possibility that it could work, under most circumstances. The way to determine what it is doing, and where it is going wrong, is to print what is actually read from the client.
Put:
Serial.print("c = ");
Serial.println(c);
after:
c = client.read();
In addition, the array needs to be kept NULL terminated. Add:
buffer[bufindex] = '\0';
after
bufindex++;
Then, to assure that the data is collected in the array correctly, put:
Serial.print("buffer = [");
Serial.print(buffer);
Serial.println("]");
after the end of the while loop.
Let us know what that prints to the serial monitor, and we can go from there.