Vielen Dank an @Madivad für die Inspiration zum AT-Befehl. Ich bin nicht sehr vertraut mit GSM und Arduino. Aber wie auch immer, das Folgende hat bei mir funktioniert.
Dank an @Madivad und Leute aus dem Arduino-Forum.
#include <GSM.h>
GSM gsmAccess(true);
int sizer = 200;
char myNumber[200];
int timeout = 5000; // in milli seconds
void setup()
{
Serial.begin(9600);
boolean notConnected = true;
Serial.println("Connecting to the GSM network");
while(notConnected){
if(gsmAccess.begin() == GSM_READY) // Note: I do not require PIN #
notConnected = false;
else {
Serial.println("Not connected, trying again");
delay(1000);
}
}
Serial.println("Connected");
theGSM3ShieldV1ModemCore.println("AT+CPBS=\"SM\"");
int start1 = millis();
while((millis() - start1) < timeout){
Serial.print(theGSM3ShieldV1ModemCore.theBuffer().read());
}
Serial.print("Set to look at SIM card storage");
// search for contact name "test"
theGSM3ShieldV1ModemCore.println("AT+CPBF=\"test\"");
start1 = 0;
start1 = millis();
while((millis() - start1) < timeout && !theGSM3ShieldV1ModemCore.theBuffer().extractSubstring(",\"", "\",", myNumber, sizer)){
Serial.print(theGSM3ShieldV1ModemCore.theBuffer().read());
}
Serial.print("Got contact number");
// print out the phone of "test"
Serial.println(myNumber);
}
void loop()
{
}