I am working on reading a text file from the server, using http://arduino.cc/en/Reference/GSMClientConnected. It gives me this code:
char path[]="/asciilogo.txt"
I want to store only the contents that are inside the text file to a variable (String). But client.read();
only reads a single character at a time. Also, it takes all the HTTP, GET, TIME parameters together.
How to store only the contents that are present in the text file to a string variable?
1 Answer 1
Here is what I found:
You need to have a special character like "*" (a delimiter), from which important data will flow through.
char z = '*';
int s=0;
void setup()
{
// usual initialization
}
void loop()
{
if (client.available())
{
char c = client.read();
// Serial.print(c);
if (z == c)
{
s=1;
}
if(s == 1)
{
int i=0;
k[i] = c;
i=i+1;
// Serial.print(k);
}
place +=k;
Serial.print(place);
}
.......
}
-
1that'll work but you have to declare
i
outside of theloop()
because the way it is now, it'll always be 0.sachleen– sachleen2014年05月07日 22:14:58 +00:00Commented May 7, 2014 at 22:14