Store value in variable after HTTPREAD

Solution 1:

Start by acquiring a large A3 sheet of paper, find a red pen and write 1000 times

I will never use delay as a substitute for reading and parsing responses from a modem.

I will never use delay as a substitute for reading and parsing responses from a modem.

I will never use delay as a substitute for reading and parsing responses from a modem.

I will never use delay as a substitute for reading and parsing responses from a modem.

I will never use delay as a substitute for reading and parsing responses from a modem.

...

Then read this answer, following the instructions regarding V.250. And when you have properly digested all information from the answer (it probably takes some time to let all sink in), then follow the link to another answer in the comment below it (which contains information to capture response content).


Of course the first part was meant to be funny, but I am dead serious about the rest; you have some huge AT command knowledge "holes" you must fill. You will not be able to get any information out until you do. It should not be very difficult, but it will require some effort.

Solution 2:

First you should initialize a char array named a for storing the value and also declare a variable int flag=0;.

Then modify your toSerial() function as follows:

void toSerial() {
  while(gprsSerial.available()!=0) {
    if( gprsSerial.read() == '[' )
      flag=2;
    else if(flag == 2 && gprsSerial.read() == ':')
      while(gprsSerial.read() != '}') {
        a[i]= gprsSerial.read();
        i++;
      }
    else if(flag == 0)
      Serial.write(gprsSerial.read());
    else
      flag--;
  }
}