I try to get a timeStamp from php page (http://www.honeyshare.cn/time.php) and use LinkIt ONE board which is Compatible with arduino as client.There is only one line code "echo time();" on php page.Then I get serial output like this
Connecting to AP
Connecting to WebSite
waiting HTTP response:
HTTP/1.1 200 OK
Date: Sun, 20 Dec 2015 09:17:26 GMT
Server: Apache
Vary: User-Agent,Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
7
1450605837
0
disconnected by server
1450605837 is what I want.7 above this line and 0 below this line is ghost char.If I would not use echo and only write 1450605837 in php file as string, 7 or 0 will not show in the serial output.
Here is LinkIt ONE board code
#include <LTask.h>
#include <LWiFi.h>
#include <LWiFiClient.h>
#define WIFI_AP "XXXX"
#define WIFI_PASSWORD "XXXXX"
#define WIFI_AUTH LWIFI_WPA // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.
#define SITE_URL "www.honeyshare.cn"
LWiFiClient c;
void setup()
{
LWiFi.begin();
Serial.begin(115200);
// keep retrying until connected to AP
Serial.println("Connecting to AP");
while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD)))
{
delay(1000);
}
// keep retrying until connected to website
Serial.println("Connecting to WebSite");
while (0 == c.connect(SITE_URL, 80))
{
Serial.println("Re-Connecting to WebSite");
delay(1000);
}
// send HTTP request, ends with 2 CR/LF
// Serial.println("send HTTP GET request");
c.println("GET /time.php HTTP/1.1");
c.println("Host: " SITE_URL);
c.println("Connection: close");
c.println();
// waiting for server response
Serial.println("waiting HTTP response:");
while (!c.available())
{
delay(100);
}
}
boolean disconnectedMsg = false;
void loop()
{
// Make sure we are connected, and dump the response content to Serial
while (c)
{
int v = c.read();
if (v != -1)
{
Serial.print((char)v);
}
else
{
Serial.println("no more content, disconnect");
c.stop();
while (1)
{
delay(1);
}
}
}
if (!disconnectedMsg)
{
Serial.println("disconnected by server");
disconnectedMsg = true;
}
delay(500);
}
Is there any idea about this problem? thx