Thank you brother for the details. Actually I have a textfile in the server which contains (* followed by 1 or 2 words). The response form the server is
GET /current.txt HTTP/1.1
Host: www.yourdomain.com
User-Agent: Arduino
Accept: text/html
Connection: close
COMPLETE!
HTTP/1.1 200 OK
Date: Thu, 15 May 2014 17:02:05 GMT
Server: Apache mod_fcgid/2.3.10-dev
Last-Modified: Thu, 15 May 2014 16:40:23 GMT
ETag: "7f201d1-7-4f972f413c45a"
Accept-Ranges: bytes
Content-Length: 7
Content-Type: text/plain
Expires: Thu, 15 May 2014 17:06:25 GMT
Connection: close
*America
place = America
// Current.txt contains *London
GET /current.txt HTTP/1.1
Host: www.yourdomain.com
User-Agent: Arduino
Accept: text/html
Connection: close
COMPLETE!
HTTP/1.1 200 OK
Server: Apache mod_fcgid/2.3.10-dev
ETag: "7f201d1-7-4f972f413c45a"
Accept-Ranges: bytes
Content-Length: 7
Content-Type: text/plain
Age: 6
Date: Thu, 15 May 2014 17:02:05 GMT
Last-Modified: Thu, 15 May 2014 16:40:23 GMT
Expires: Thu, 15 May 2014 17:06:25 GMT
Connection: close
*America
place = America // // Here the current.txt contains London but still shows America
The code is given below :
Here in the code I am using z= '' as a delimiter to identify the important text coming after '' to be stored in to place string.
// libraries
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// APN data
#define GPRS_APN "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN "login" // replace with your GPRS login
#define GPRS_PASSWORD "password" // replace with your GPRS password
// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;
//Variables Declaration
char k[30];
char z = '*';
int s=0;
String place;
// URL, path & port (for example: arduino.cc)
char server[] = "manihattysemiconductors.com";
char path[] = "/currentlocation.txt";
int port = 80; // port 80 is the default for HTTP
void setup()
{
// initialize serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("SMS connected");
// connection state
boolean notConnected = true;
// After starting the modem with GSM.begin()
// attach the shield to the GPRS network with the APN, login and password
while(notConnected)
{
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GPRS connected...");
Serial.println(" Connecting to Server ");
}
void loop()
{
if (client.connect(server, port))
{
client.print("GET /current.txt");
Serial.print("GET /current.txt");
client.println(" HTTP/1.1");
Serial.println(" HTTP/1.1");
client.println("Host: www.yourdomain.com");
Serial.println("Host: www.yourdomain.com");
client.println("User-Agent: Arduino");
Serial.println("User-Agent: Arduino");
client.println("Accept: text/html");
Serial.println("Accept: text/html");
client.println("Connection: close");
Serial.println("Connection: close");
client.println();
Serial.println();
Serial.println("\nCOMPLETE!\n");
//client.stop();
}
else
{
Serial.println("connection failed");
Serial.println("\n FAILED!\n");
}
while (client.connected()) {
while(client.available()) {
char c = client.read();
Serial.print(c);
if (z==c)
{
s=1;
}
if(s == 1 && c!='*')
{
int i=0;
k[i] = c;
i=i+1;
// Serial.print(k);
}
place +=k;
}
}
Serial.print("place = ");
Serial.print(place);
client.stop();
}
Here the problem is, the place value should display London as it was updated in the server but it still shows America. Thanks in advance brother ...