My project is about getting contact number, so far I can shown number of contact is ringing in the serial monitor But my problem is that I can not extract number from +clip order , please help and tell me how can extract number and store that in the variable
#include <SoftwareSerial.h>
SoftwareSerial SIM808(10, 11);
#define GSMReset 5
char inData[50];
char inChar;
byte index = 0;
void setup() {
Serial.begin(9600); // for serial monitor
SIM808.begin(9600); // for GSM shield
gsmPower();
gsmConfig();
}
//*******************************************************************************************
void loop() {
}
//*******************************************************************************************
void gsmPower() {
Serial.println("Turning GSM ON");
digitalWrite(GSMReset, HIGH);
delay(10);
digitalWrite(GSMReset, LOW);
delay(100);
digitalWrite(GSMReset, HIGH);
delay(7000);
sendCommand("AT\n", 100);
Serial.println(" 'A' answer and 'R' reject ! ");
}
//*******************************************************************************************
void callprocess() {
if (SIM808.available())
{
delay(2000);
sendCommand("AT+CLIP=1 \r \n", 100);
//String code = "+CLIP:"09111111111",145,"",0,"",0,," ;
//int firstClosingBracket = code.indexOf('"');
//int secondOpeningBracket = firstClosingBracket + 1;
//int secondClosingBracket = code.indexOf('"', secondOpeningBracket);
//String number = code.substring(7, 18);
//Serial.println(number);
}
}
//*******************************************************************************************
void sendCommand(String cmd, int t)
{
SIM808.println(cmd);
delay(t);
readSerial();
}
//*******************************************************************************************
void readSerial() {
while (SIM808.available())
Serial.write(SIM808.read());
}
//*******************************************************************************************
void gsmConfig() {
while (1) {
char c = Serial.read();
if (c == 'A') {
sendCommand("\n ATA\r\n", 100);
Serial.println("\n call is accept !");
}
if (c == 'R') {
sendCommand("\n ATH\r\n", 100);
Serial.println("\n call is reject !");
}
callprocess();
}
}
//****************************************************************************************