How to comparison with Arduino console data ?

leiw:
Why {1,2,3,4,5} and it is 8 numbers.

that was just to give some idea what the response from one of the servers looked like, i.e. no trailing blank lines, etc
it is a set of integers enclosed in {} seperate by , which is then parsed to extract the data to control relays

My PHL script working find, so I dont know what happened on Arduino.

I just searched from Google, someone also have my problem, he just echo The Value test on PHP, not via MySQL, but displayed on Ardunio console included 4,5,0 numbers.

Thanks

leiw:
My PHL script working find, so I dont know what happened on Arduino.

you could test each line as it arrives, e.g.

  /*
   HTTP GET method from http://playground.arduino.cc/Code/WebClient

*/

// modifications to original
// 7/10/2017 update IP address and web page information
// 8/10/2017 replaced sprintf() with strcat() calls to build client data

#define SPRINTF       // comment out to use strcat() 

#include <SPI.h>
#include <Ethernet.h>

// this must be unique
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// change to your network settings
IPAddress ip(192,168,1,177);
IPAddress gateway(192, 168, 1, 254);
IPAddress subnet(255, 255, 255, 0);

// change to your server
IPAddress server(192,185,16,85);

//Change to your domain name for virtual servers
char serverName[] = "winlogin.marvelconnect.com";

// change to your server's port
int serverPort = 80;

EthernetClient client;

// set this to the number of milliseconds delay between GET requests
#define delayMillis 30000UL
unsigned long thisMillis = 0;
unsigned long lastMillis = delayMillis;

void setup() {
   Serial.begin(115200);
   // disable SD SPI
   pinMode(4,OUTPUT);
   digitalWrite(4,HIGH);

   // Start ethernet
   Serial.println(F("Starting ethernet..."));
   //Ethernet.begin(mac, ip, gateway, gateway, subnet);
   // If using dhcp, comment out the line above 
   // and uncomment the next 2 lines plus the Ethernet.maintain call in loop

   if(!Ethernet.begin(mac)) Serial.println(F("failed"));
   else Serial.print(F("IP "));
   Serial.println(Ethernet.localIP());
   delay(2000);
   Serial.println(F("Ready"));
}

void loop()
{
   Ethernet.maintain();   // If using dhcp to get an IP, uncomment line
   // send data every delayMillis 
   thisMillis = millis();
   if(thisMillis - lastMillis > delayMillis)
   {
      // GET the page
      if(!getPage(serverPort, serverName, "/getdata.php?uid=F070FAA4")) Serial.print(F("Fail "));
      else { Serial.print(F("Pass ")); lastMillis=millis(); }
   }   
}

char inChar;
char data[100]={0};   // << add these
int index=0;

// HTTP GET from page on server serverName using  ipBuf thisPort 
byte getPage(int thisPort, const char* serverName, const char *page)
{
  int inChar;
  char outBuf[128]="GET ";
  Serial.print(F("\n\nconnecting to "));
    Serial.println(serverName);
  // connect to server
  if(client.connect(serverName, thisPort) == 1)
  {
    Serial.println(F("connected"));
 #ifdef SPRINTF   
     // form HTTP GET and send it - replace sprint() with strcat()
     sprintf(outBuf,"GET %s HTTP/1.1",page);
     client.println(outBuf);
     Serial.println(outBuf);
     // form  server and send it
     sprintf(outBuf,"Host: %s",serverName);
     client.println(outBuf);
#else
    client.println(strcat(strcat(outBuf, page), " HTTP/1.1"));
    Serial.println(outBuf);
    outBuf[0]=0;
    client.println(strcat(strcat(outBuf, "Host: "), serverName));
 #endif
    Serial.println(outBuf);
    client.println(F("Connection: close\r\n"));
  } 
  else
  {
    Serial.println(F("failed"));
    return 0;
  }

  // connectLoop controls the hardware fail timeout
  int connectLoop = 0;
  while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      if(inChar < ' ')    // if end of line 
      {
       if(strcmp(data, "F070FAA4") == 0)
               Serial.println("   *****  UID comparison completed *****\n");
       //Serial.print(" index = "); Serial.println(index);
       index=0;
       }
      else data[index++]=inChar;  // add character to data[]

      data[index]=0;
      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();
  if(strcmp(data, "F070FAA4") == 0)
  {
    Serial.print("UID comparison completed\n");
  } else {
    Serial.print("UID comparison not completed\n");
  }

  return 1;
}

which gives

Starting ethernet...
IP 192.168.1.177
Ready


connecting to winlogin.marvelconnect.com
connected
GET /getdata.php?uid=F070FAA4 HTTP/1.1
Host: winlogin.marvelconnect.com
HTTP/1.1 200 OK
Server: nginx/1.12.2
Date: Thu, 01 Feb 2018 07:54:13 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: close

f
F070FAA4   *****  UID comparison completed *****









0


disconnecting.
UID comparison not completed
Pass

Hello horace,

You really high level for me :D, I am newbie of C++ :smiley:

I have tested remove 4 of "if(strcmp(data, "F070FAA4") == 0)" , it doesn't print ***** UID comparison completed *****, it work find.

And I think no need bottom lines:

if(strcmp(data, "F070FAA4") == 0)
{
Serial.print("UID comparison completed\n");
} else {
Serial.print("UID comparison not completed\n");
}

Because it does RFID application, now going to next step to think how to integrate above program to this RFID.

Big thanks~