GSM Library: how can i retrive my SIM card number (MSISDN) ?

Hi all,

I've already tried to search (google and here), but I didn't find; How can i retrive my SIM card number (MSISDN) ?
i'm using the GSM Shield.

Thanks

Try a variation of any of the following commands...

AT+CNUM
AT+CNUM=?
AT+CNUM?
CNUM=?

The precise command is specific to the make of the modem. The answer is normally returned with some extra characters that will need to stripped off.

NOTE - This command will return the value stored in a particular memory location on the SIM, it may not actually be the correct phone number - this relies on the person who set the value setting it right in the first place! The only 100% accurate way of getting the phone number is send a message from the modem and see what number it appears to have come from.

Hope this helps

Hi,
Thanks, but none of the following respond:

theGSM3ShieldV1ModemCore.println("AT+CNUM");
theGSM3ShieldV1ModemCore.println("AT+CNUM=?");
theGSM3ShieldV1ModemCore.println("AT+CNUM?");
theGSM3ShieldV1ModemCore.println("CNUM=?");

any other advice ?

with this:

#include <GSM.h>
GSM gsmAccess(true);
char myNumber[20];
int timeout = 5000; // 5 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+CNUM"); 
 
 int start = millis();    
  while((millis() - start) < timeout && !theGSM3ShieldV1ModemCore.theBuffer().extractSubstring("+CNUM: \"\",\"", "\"", myNumber, 20)){
  }
  Serial.print("My Telephone number: ");
  Serial.println(myNumber);
  
}

void loop()
{
}

I have this:

Connecting to the GSM network
AT%13%
0 25>AT%13%%13%%10%OK%13%%10%%13%%10%+CPIN: READY%13%%10%
AT+CGREG?%13%
25 56>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
56 87>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
87 118>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
118 21>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
21 52>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
52 69>AT+IFC=1,1%13%%13%%10%OK%13%%10%
AT+CMGF=1%13%
69 85>AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
85 101>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
101 112>ATE0%13%%13%%10%OK%13%%10%
AT+COLP=1%13%
112 118>%13%%10%OK%13%%10%
Connected
AT+CNUM%13%%10%My Telephone number:

Any help please ?

AT+CNUM%13%%10%My Telephone number:

If that is supposed to actually be your telephone number redacted, what do you need help with?

Hello,

my concern is that i am not able to get my phone number, it seems like the GSM shield do not respond to "AT+CNUM"; or may be "theGSM3ShieldV1ModemCore.theBuffer().extractSubstring("+CNUM: \"\",\"", "\"", myNumber, 20)"
is not the correct way to extract the response ? ;

I've already tried to search over google since 1 week, without succes.

it seems like the GSM shield do not respond to "AT+CNUM";

Really? You don't think that

AT+CNUM%13%%10%My Telephone number:

was the response to the AT+CNUM command? What do you suppose it was the response to?

or may be...is not the correct way to extract the response ?

I'd say that was a certainty.

theGSM3ShieldV1ModemCore.theBuffer()

returns a reference to a GSM3CircularBuffer. That class has a extractSubString() method. But, instead of using that, I'd suggest that you use retrieveBuffer() to get the whole buffer as a NULL terminated array of chars. Do, at first, nothing more than print that buffer.

Then, learn to use the string functions, like strtok(), strstr(), etc. to extract the parts of the string that you want.

 int start = millis();

The millis() function returns an unsigned long. Storing that in a signed int is wrong.

Thanks for the tips;
From the retrieveBuffer() i can see now, that the shield respond with an error

+CME ERROR: 3

And from what i've searched, the response means "Operation not allowed".
With "AT+CIMI" i can get the IMSI
I am going to search the reason of the error but at the meantime, if you have any other tips ?

Trying to achieve the same right now with an Uno and GSM Shield 2. Did you manage to get MSISDN, IMSI or ICCID?