Hello all,
I've just purchased EtherCard option for my Arduino Uno and it works just great.
What I need to do is passing several variables to the server (php script) using GET method.
At the moment I use this test code to generate random V1 values and pass it each minute to push_data.php
Coul You please help me out with another related thing...
I post this to server i get my_callback full of info that I dont need. But some info would be good to display on my OLED screen.
The function my_callback is there:
// called when the client request is complete
static void my_callback(byte status, word off, word len) {
Ethernet::buffer[off+300] = 0;
Serial.write((const char*) Ethernet::buffer + off);
}
And result is this:
HTTP/1.1 200 OK
Date: Wed, 10 Oct 2012 13:28:13 GMT
Server: Apache
Connection: close
Content-Type: text/html
All in need is just system messages with time after "#".
How can I trim the result to remove everything else.
The data that you are Serial.write()ing is stored in a buffer - Ethernet::buffer.
Use strtok() to get a pointer to the string up to the first # (hint - the delimiter argument will be "#"). Then, call strtok() again, with a different delimiter string ("\0"), to get the rest of the data (the "DEVOK, 16:28:13 #STSET, 16:28:13 #DASET, 16:28:13" part).
Copy that data to another buffer, and you can use strtok() again on that buffer to get just the parts you want.
The second token would be "DEVOK, 16:28:13 #STSET, 16:28:13 #DASET, 16:28:13". If you want to extract just the 1st time from that, you need to make a copy of it. Calling strtok() with a pointer to internal data stored by the strtok() function is not a good idea. The internal data will be destroyed as soon as strtok() detects that the input argument is not NULL, rendering the pointer useless.