AT command to know own phone number
Asked Answered
Z

5

9

I have been working lately on AT commands testing. I had difficulties in finding the own number when the sim is not subscribed for SMS and voice calls(in some special cases where sim is used for lab experimenting). Is there any way to know own phone number using AT command. Say for airtel(india) the ussd code for own msisdn number is *121*9#. So if I dial ATD*121*9#, will I get the message displayed on AT command user interface. Or is there another way to know the own phone number? Help greatly appreciated.

Zilpah answered 22/9, 2014 at 8:41 Comment(0)
E
17

AT+CNUM returns the MSISDNs related to the subscriber.

But in many cases it will just return OK. This is because +CNUM command reads a special phone book storage area reserved for the SIM's own phone numbers. The service provider may or may not store the phone number for you.

If you want to read the MSISDN with the +CNUM command and it is not currently programmed, follow the procedure below (but please know that almost every other device has it's own set of rules for AT commands so it may vary from device to device, but the concept will be same):

at+cnum?

+CME ERROR: unknown

at+cpbs?                         - display the active phonebook storage

+CPBS: "SM",250,250

OK

at+cpbs=ON                       - select the active phonebook storage to MSISDN list

OK

at+cpbs?                         - display the active phonebook storage

+CPBS: "ON",0,3                  - MSISDN list is empty

OK

at+cpbw=,"+918723976327"         - enter your own MSISDN

OK

at+cpbs?                         - display the active phonebook storage

+CPBS: "ON",1,3                  - MSISDN list has one item

OK

at+cpbr=1                        - reading MSISDN list, position 1

+CPBR: 1,"+918723976327",145,""  - own MSISDN

OK

at+cnum

+CNUM: ,"+918723976327",145      - own MSISDN

Hope this helps!

Eaddy answered 28/6, 2017 at 8:39 Comment(7)
Great solution.Orientalism
AT+CPBS=? +CPBS: ("SM","DC","MC","ME","RC","EN")Molybdenite
there is no "ON"Molybdenite
@Zibri, please excuse me for any confusion, I would like to explain you that AT commands can many a times be very manufacturer specific, like in the modem I work, there are many newly implemented AT commands, even there responses can also be altered.Eaddy
So from my understanding this only helps you SET the CNUM yourself if you already know your own number before, right?Ozmo
@AmanBurman no confusion... I "talk" with modems since 1988 :D the weird thing is that if I inser the USIM in an android phone it says the number is 12345678901 but CNUM does not answer (just ok) and even the sim EF file looks empty... I wonder where does it get it.Molybdenite
@AmanBurman also AT+CRSM=176,28484,0,0, 15 returns ""Molybdenite
P
10

AT+CNUM should return your own phone number.

Peralta answered 22/9, 2014 at 8:49 Comment(1)
Then it has probably not been properly implemented as stated in the answer below. You can also try reading the phone book containing your phone number with AT+CPBS="ON" and AT+CPBR=1, bud as far as I know it is also optional.Peralta
C
5

If everything else fails, another option would be to try sending an SMS to yourself. In my case it worked flawlessly.

AT+CMGF=1
OK
AT+CMGS="my mobile number"
> This is a test.
>
+CMGS: 119

You should end the SMS message with CTRLZ.

Cannonry answered 16/5, 2017 at 16:23 Comment(3)
It is also worth noting, that CTRL+Z signal is 0x1A or decimal 26. It took me a while to find that one, because when sending it from Arduino or Terminal app it is impossible to just put "CTRL+Z" and hope it will send correct control byteWaltraudwaltz
But how are we supposed to know the "my mobile number"?Ozmo
@Ozmo Don't you know your mobile number? Well, if this is the case (or if you don't have a mobile) the above solution cannot help.Cannonry
U
2

Information from the standard AT command set, available from 3GPP

AT+CNUM returns the subscriber number - but implementation of this AT command is optional.

You can also use the AT commands for USSD transactions, e.g. +CUSD Section 7.15 of TS 27.007 and related commands, to get the subscriber number.

Unoccupied answered 22/9, 2014 at 9:1 Comment(0)
M
0

AT+CUSD=1

Set command allows control of the Unstructured Supplementary Service Data (USSD > 3GPP TS 22.090 ).
0 - disable the result code presentation in the DTA
1 - enable the result code presentation in the DTA
2 - cancel an ongoing USSD session (not applicable to read command

AT+CPBS="ON"

Set command selects phonebook memory storage , which will be used by other phonebook commands.
"ON" - SIM own numbers (MSISDNs) phonebook (+CPBF is not applicable for this storage).

AT+CPBR=1

Execution command returns phonebook entries in location number range .. from the current phonebook memory storage selected with +CPBS. If is omitted, only location is returned.

AT*101#

Reponse:
+CUSD: 2,"",15
+CUSD: 2,"05551234567",15

Modish answered 3/2, 2017 at 8:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.