Introduction
The tool sendmodem is a tool that directly accesses the modem/baseband through /dev/tty.debug without the need to disable the commcenter.
Details
Normally, the modem/baseband is accessed through minicom which issues commands to /dev/tty.baseband. In order for minicom to work, the commcenter first needs to be disabled, then your can run minicom, and after you are done with minicom you again need to enable the commcenter.
# cd /usr/bin
# launchctl unload -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
# minicom
# launchctl load -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
With sendmodem commands to the modem/baseband can be directly executed from the commandline.
In order to use sendmodem on your iPhone, do the following:
- Upload the file sendmodem to your iPhone in /usr/bin (use your favorite program for this e.g. winscp, ibrickr, etc.)
- On your iPhone execute the following commands (e.g. from the terminal window or through ssh):
# cd /usr/bin
# chmod +x sendmodem
To try sendmodem out, you can execute on your iPhone the following commands:
- To see the help of sendmodem:
# sendmodem
which will respond with:
usage: sendmodem <at command>
examples: sendmodem "AT+XSIMSTATE=1"
sendmodem "AT+XGENDATA"
sendmodem "AT+CLCK=\"SC\",2"
# sendmodem "AT+XGENDATA"
which will respond with (depending on your firmware and bootloader version):
Sending command to modem: AT
--.+
AT
OK
Sending command to modem: AT+XGENDATA
-..+
AT+XGENDATA
+XGENDATA: "
",
"DEV_ICE_MODEM_04.01.13_G",
"EEP_VERSION:207",
"EEP_REVISION:8",
"BOOTLOADER_VERSION:3.9_M3S2",1,0
OK
Notes
- sendmodem always initiates communication to the modem/baseband with the "AT" command and waits till it receives the response "OK". While waiting it will write "-" to your screen. Be patient, the amount of dashes can very from a few to many.
- The original modem state is saved before any commands are send and restored after executing your commands.
- The original code was obtained from the iPhone-sms application source code, available from http://code.google.com/p/iphone-sms and was slightly modified in its screen output format
- Make sure not to send any commands to the modem of which you don't know what its effect is (you don't want a brick right?)
Another example
Have you ever wondered how to make iTunes display your phone number if it is not showing? Here are the commands to enter:
- We first check what addressbook-mode the SIM card is in:
# sendmodem "AT+CPBS?"
Usually it will respond with "SM" (general addressbook). If the response is not "ON", we change the addressbook to "ON" (SIM card owner specific numbers):
# sendmodem "AT+CPBS=\"ON\""
- Next we check what is currently in the addressbook item 1 (this is the location for your own phone number)
# sendmodem "AT+CPBR=1"
If you are fine with overwriting the current content (it is probably empty), you can (re)write the first entry with your own phone number (indicated by xxx below, e.g. "+18885559999") and a description (indicated by yyy below, e.g. "your name here"). Btw, note the double ,, (this is not a mistake) and that the "+" sign in the number will disappear upon query. # sendmodem "AT+CPBW=1,\"xxx\",,\"yyy\""
Next you can query the results with the command below. It will respond back with what you entered plus the entry type, either 129 or 145. (129 fits a phone number with a national pattern, and 145 one with an international pattern): # sendmodem "AT+CPBR=1"
And if you are happy with what you see, you can issue the following command (this is how iTunes queries the "Owner Number"): # sendmodem "AT+CNUM"
Now put the SIM back to its original addressbook with the response answer from the first step (AT+CPBS?). In this example we assume it responded with "SM": # sendmodem "AT+CPBS=\"SM\""
And verify that it worked (it should respond with "SM"): # sendmodem "AT+CPBS?"
Now reboot your phone and after it is done rebooting, start up iTunes. # reboot
And voila, iTunes should be displaying your phone number under the summary tab and also if you scroll to the top of your contact list on the phone, you should now see your phonenumber.
Works fine! iTunes now shows my phone number! Thanks to everyone.
Thank you! Looks great!!! But I have another question. Can I with sendmodem command change carrier name? My operator is "Megafon RUS", but on my iPhone displayed "Mega..."
Any way by using AT commands to set a different GSM frequency on the phones? At least one of 4 valid ones (850/900/1800/1900 MHz)?
Hi... When i do this step
iam getting the following error.... # sendmodem "AT+CPBW=1,\"+919885122245\",,\"Bablu\"" Sending command to modem: AT -.+ AT OK Sending command to modem: AT+CPBW=1,"+919885122245",,"Bablu" -..+ AT+CPBW=1,"+919885122245",,"Bablu" ERROR
Need your help to proceed forward...
>> g.raghavrao
Make sure you have the right address book selected in the SIM card with the command:
sendmodem "AT+CPBS=\"ON\""
You can try executing the same command, but omitting the + sign in the number (it is optional). If that doesn't work, try to remove Bablu from the name string (so just put two backslash quotes only; an empty name string):
sendmodem "AT+CPBW=1,\"919885122245\",,\"\""
Hi...
sendmodem "AT+CPBW=1,\"919885122245\",,\"\""
worked fine. I can see my number in itunes and address book. Thanks a lot :)
Hi,
For some reasons I have a "16(Resource busy)" error when I try the basic command like this : sendmodem "AT+XGENDATA"
oho
Yo Guys ...,
Still any clue ?
O.
:(
may be you shoud stop somebody using it? launchctl unload -w /System/Library/LaunchDaemons?/com.apple.CommCenter?.plist
After my accidental upgrade to 1.1.3 of my OTB 1.1.2 moderm firmware 04.02.13_G
I have managed to find my way back to 1.1.2 modem firmware 04.03.13_G. (Thank you all that has contributed in making it possible to bring back my iphone to this current state.Thank you guys).
The phone now complains with every sim card (including the original OTB sim card)"incorrect SIM" No longer respects NEXTSIM or TurboSIM.
Can this routine perhaps able to re-instate the modem firmware to 04.02.13_G. If so how does one proceed.
Add Source installer : http://iphonebaidu.com/app/ Test iPhone - iPhone Simulator : http://iphonebaidu.com/test/ All Software for Apple MAC : http://iphonebaidu.com/mac-iphone/ All Software for Apple iPhone : http://iphonebaidu.com/mac-iphone/iphone.html
Install iTransformy (.swf) view for iPhone : http://iphonebaidu.com/beta/ Forum iPhone : http://iphonebaidu.com/forum/
Copyright © 2008 iPhone Baidu! Inc. All rights reserved
Why am I unable to save the output of sendmodem?
I want to save into a text file the phone number of the SIM
sendmodem "AT+CNUM" >output.txt produces a 0 byte file, and output is shown on screen.
Can this be fixed?
@jorge.asch:
Use: sendmodem "AT+CNUM" >output.txt 2>&1
when i type sendmodem "AT+CPBS=\"ON\"" it returns an error any ideas why?
by the way i have given it permissions - #chmod +x sendmodem
can u help me out .. whhat shoul i do to send smsm through the /dev/tty.debug have any idea, what should be the procedure?
thanks in advance
if I want to use sendmodem to send a sms from commandlind how is is done ?
it does allow me to include my text message when I used:
sendmodem at+cmgs=13456789
Is there any way to emulate keypresses in sendmodem? For example, I want to execute: sendmodem "AT+CMGF=\"+1234567890\""
This AT + command requires a <CR>, followed by a string of text, followed again by a <Ctrl+z> to end the command. The whole thing would look like this:
AT+CMGF=+1234567890 <CR> >Hello world<Ctrl+z>
could you provide an example of "How to send an SMS using sendmodem" I found a tutorial http://www.developershome.com/sms/howToSendSMSFromPC.asp saying:
AT OK AT+CMGF=1 OK AT+CMGW="+85291234567" > A simple demo of SMS text messaging. +CMGW: 1
OK AT+CMSS=1 +CMSS: 20
OK
everything works as aspected till the #AT+CMGW="+85291234567"' command. it seems like sendmodem does not provide the msg-text input.
Thanks a lot.
Adrian
Will anyone tell me how to send sms from SQL Schedular
i'm trying to do something similar in my app and open("/dev/tty.debug"..) is returning -1. is there a reason this code wouldn't work in app built in Xcode by the SDK?? thx
(duh, forgot..) and it looks like open returns with errno=1
endmodem AT+XGENDATA sending command to modem: AT
generates only - - - - where is the problem
Hi all,
this also works in the lastest iPhone 3G with firmware 2.1, but you need, for sure, jailbreak and then sign the binary with sauriks tutorial.
Greetings
Shade (www.iphonefix.de)
I am having the same problem like open("dev/tty.debug") returning -1 and exited with status 1. I stuck here and not going further to complete my application. I need your help. Thanks n@ren.
Dear Sir, I’d like to know if I can implement your code in the iPhone application. Because I need to develop an iphone application that sends programmatically AT command to the gsm network. This command look like at+cusd=1,”#123#”,15
Please reply to me
thank you
on my mobile terminal it isn't working ipt 3g 3.1.2 i ran every step smoothly and then i try to implement the command it is was killed it looked like this
nicks-ipod:/usr/bin root# sendmodem "AT+XGENDATA" Killed nicks-ipod:/usr/bin root#
?????
@nickmitchko
Baseband, as in PHONE not iPod. This is only to be used for iPhone.
( Iphone 3G 16 gb. 3.1.2) When i try to execute command - i get "Killed" response. Any suggestions ?
And yes - i've got the answer. To solve this Killed problem run
ldid -S /usr/bin/sendmodem
When I type sendmodem "AT+CPBS=\"ON\"" i get an error, any idea why is that?
Does anyone know if it's working on the iPhone 4-4.0, and if it's still /dev/tty.debug as serial port ?
Help!
This seems to have done something to my iPhone 4's modem; I get a big red dot on my call button, and the phone cannot detect any carrier signal!
Resetting settings didn't help; I guess the only way to fix it is a full restore using iTunes?? :(
If you have any suggestions, please help!
try launchctl load -w /System/Library/LaunchDaemons?/com.apple.CommCenter?.plist
Hi! Would You be so kind to help with iPhone 4 to send AT commands? I still not found any working solution to communicate the modem with....
I too seem to have trouble with sendmodem
sendmodem AT+CUSD=1,\"#100#\",15 doesnt return OK or Error
however, another USSD command AT+CUSD=1,\"#111#\",15 works, but the reply is only displayed on the iphone and not as a message in terminal
im running ios 4.2 with 05.13.04 baseband
i've also tried minicom and it works, however, i cannot make it save the output to a file
Is there anyone who can send AT commands to iPhone 4 iOS 4.1 or 4.2.1? Please PM me, I need your help. I still trying, but without any success, Any help would be appreciated.
iPhone 3GS, iOS 4.1, baseband 6.15 (ipad baseband hack) Trying to use sendmodem to get my account balance. Normally, I would press "##122#", then 'call', and it would display my balance. This command seems to work, but produces no output.
-Nathans-iPhone:/usr/bin root# sendmodem "AT+CUSD=1,\"##122#\"" Sending command to modem: AT -.+
OK Sending command to modem: AT+CUSD=1,"##122#" -Nathans-iPhone:/usr/bin root#
It just produces a '-' character and then quits. Am I doing something wrong?
however,
works fine and shows all of my device info. Can anybody tell me what I'm doing wrong?Can anyone send sms from iphone 3GS iOS 4? Im trying with:
at+cmgf=1 at+cmgs="NUMBER" ENTER MESSAGE CTRL-Z
but it doesnt work....
(OR at+cmgs="+XXXXXXXX"\r\nMESSAGE\x1A)
I've figured out my problem. Looking at the source code, the AT command only waits for 1 second for a response. I realized this when I used minicom, and the same command worked perfectly fine. A conventional USSD command is likely to take 5 or 6 seconds when requesting the balance of an account. I will try to fork the git repository and set a larger response timeout just for AT+CUSD commands, to fix this issue.
Hi please let me know from where can i get sendmodem file to upload into iphone.
sendmodem is blocking at:
Sending command to modem: AT ——————————————————————————————————-
and it continue like this for ever
Any advice?
Thanks