hello sir, i have success to send data to PC server via LAN with Arduino. and then i wanna make server will send data respon for all update info about status tank. and the problem is how to parse some data tank .
the respon:
connecting...connected
HTTP/1.1 200 OK
Date: Sat, 29 Jul 2017 18:59:33 GMT
Server: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.20
X-Powered-By: PHP/5.6.20
Content-Length: 279
Connection: close
Content-Type: text/html; charset=UTF-8
UPDATE Success!
Hasil T-01 :pa#2100$level#4*
Hasil T-02 :pa#122000$level#1408*
Hasil :pa#$level#*
Hasil :pa#$level#*
Hasil :pa#$level#*
Hasil :pa#$level#*
Hasil :pa#$level#*
Hasil :pa#$level#*
Done.
disconnecting.
Pass >>
this part of code.
thisMillis = millis();
if(thisMillis - lastMillis > delayMillis)
{
lastMillis = thisMillis;
Serial.println();
statT01=digitalRead(3); // status T-01 ON or OFF
if (statT01>0){
strcpy (numtt, tt[0]); //801 = T-01
}else {
strcpy (numtt, tt[1]);
}
int platref=0;
platref=digitalRead(4); //masukkan id platnomor
if (platref>0){
strcpy (numref, ref[0]); //1 = AB1234CD
}else {
strcpy (numref, ref[1]);
}
char refBuffer[8]; //refuler
char volBuffer[8];
// dtostrf(levelmm,3,1,levelBuffer);
vol = 600; //liter
dtostrf(vol,3,1,volBuffer); //vol,3,1,volBuffer);
sprintf(pageAdd,"/adisucipto/insert_top.php?ref=%s&req=%s&tt=%s",numref,volBuffer,numtt);
//http://localhost:8080/adisucipto/insert_dttop.php?ref=1&req=1000&tt=801
if(!getPage(server,serverPort,pageAdd)) Serial.print(F("Fail "));
else{
Serial.print(F("Pass "));}
delay(1000); //wait one second before sending new data
}
}
byte getPage(IPAddress ipBuf,int thisPort, char *page)
{
int inChar;
char outBuf[256];
Serial.print(F("connecting..."));
if(client.connect(ipBuf,thisPort))
{
Serial.println(F("connected"));
sprintf(outBuf,"GET %s HTTP/1.1",page);
client.println(outBuf);
sprintf(outBuf,"Host: %s",serverName);
client.println(outBuf);
client.println(F("Connection: close\r\n"));
//line = client.println(outBuf); //tambahan 17
}
else
{
Serial.println(F("failed"));
return 0;
}
// connectLoop controls the hardware fail timeout
int connectLoop = 0;
while(client.connected())
{
while(client.available())
{
Serial.write(inChar);
// set connectLoop to zero if a packet arrives
connectLoop = 0;
}
connectLoop++;
// if more than 10000 milliseconds since the last packet
if(connectLoop > 10000)
{
// then close the connection from this end.
Serial.println();
Serial.println(F("Timeout"));
client.stop();
}
// this is a delay for the connectLoop timing
delay(1);
}
Serial.println();
Serial.println(F("disconnecting."));
// close client end
client.stop();
return 1;
}
hope your help sir.thanks