3

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?

KatieK
3131 gold badge2 silver badges11 bronze badges
asked May 7, 2014 at 8:48

1 Answer 1

2

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);
 }
.......
}
KatieK
3131 gold badge2 silver badges11 bronze badges
answered May 7, 2014 at 15:38
1
  • 1
    that'll work but you have to declare i outside of the loop() because the way it is now, it'll always be 0. Commented May 7, 2014 at 22:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.