I have been able to find a parse and I got help from Nikhil Joji.
#include <SoftwareSerial.h>
SoftwareSerial GSM(2, 3); // RX, TX
String d;
int i=0;
void setup()
{
Serial.begin(19200);
GSM.begin(19200);
GSM.println("AT \r");
delay(500);
GSM.println("AT+CMGF=1 \r");
delay(1000);
GSM.println("AT+CNMI=1,2,0,0 \r");
delay(2000);
}
void loop()
{
while ( !GSM.available() );
d = GSM.readString();
Serial.println(d);
delay(2000);
int indexOne = d.indexOf('"'); //position of "
Serial.print("IndexOne is "); //printing the position number
Serial.println(indexOne);
String sender_number = d.substring(indexOne,indexOne+16);
Serial.println("Sender number is "); //Printing
Serial.println(sender_number);
//int indexTwo = d.substring('","","');
String send_date = d.substring(indexOne+21,indexOne+41);
Serial.println("Send date is "); //Printing
Serial.println(send_date);
// int indexThree = d.indexOf('\n');
String msg = d.substring(indexOne+41,indexOne+250);
Serial.println("Message is "); //Printing
Serial.println(msg);
}
}
The out put is
AT
OK
AT+CMGF=1
OK
AT+CNMI=1,2,0,0
OK
IndexOne is -1
Sender number is
CMGF=1
OK
AT+CNMI=1,2,0,0
OK
Send date is
1
OK
AT+CNMI=1
Message is
,2,0,0
OK
+CMT: "+234703XXXXXXX","","17/10/15,20:52:32+04"
No wahala bro,i got ya..we neva even stat so i'm tryng to revise ahead of d time. Stil on ctrl bro!
IndexOne is 8
Sender number is
"+234703XXXXXXX"
Send date is
17/10/15,20:52:32+04
Message is
"
No wahala bro,i got ya..we neva even stat so i'm tryng to revise ahead of d time. Stil on ctrl bro!
I have been able to break it down into variables but I am having problem paring the variables to to a database using HTTP GET request.
I have tried using sendGSM("AT+HTTPPARA=\"URL\",\"kiopay.net/webservice/data.php?network_id=5&senderNo=234703XXXXXXX&recMsg=Hello+World&timeArrived=201710112134\"");
It works my data is passed to the database but I want to use the variables which I have gotten from the sms. when I used the variable names I get the identifier instead of the value.
Please your help will be highly appreciated..
Thannks .