Hi,
I need help to extract the mobile number from String. Mobile number store in SIM card with start and end mark like #0123456789# and AT command return is
+CPBF: 1,"#00123456789123#",255,"Arduino"
Now I want to get number only my sketch is below. and serial output is like :
+CPBF: 1,"#00XXXXXXXXXX#",255,"Aarduino"
Number is : AT+CPBF="Arduino"
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);//Configuring the serial pins by software
char c[66] ; //array for midi variables
String readString, substring;
int loc;
void setup()
{
//Serial connection.
Serial.begin(9600);
SIM900.begin(9600);
}
void loop() {
if (SIM900.available()>0) {
for (int i = 0; i < 63 ; i++)
{
c[i] = SIM900.read();
}
// Serial.println(c);
if (c == "#") {
Serial.println(readString); //prints string to serial port out
loc = readString.indexOf("#");
//Serial.println(loc);
substring = readString.substring(loc + 12);
Serial.print("Number is : ");
Serial.println(substring);
readString = ""; //clears variable for new input
substring = "";
}
else {
readString += c; //makes the string readString
}
SIM900.println("AT+CPBF=\"Arduino\"");
delay(1000);
Serial.print("Number is : ");
Serial.println(c);
}
}
// AT command return is : +CPBF: 1,"#00123456789123#",255,"Arduino"