A Convenient Tool to Send AT Commands

PmgRiPhone of elite team has released a tool (sendmodem) to send command directly to iPhone modem. This is convenient. The tool uses /dev/tty.debug to communicate with modem, so you don’t have to turn off the communication center during the operations.

The command syntax is quite straight forward:

sendmodem “AT command”

Here are some examples:

Querying the baseband version:
sendmodem
“AT+XGENDATA”

Querying the lock state:
sendmodem “AT+XSIMSTATE=1”

Querying the battery capacity:
sendmodem “AT+CBC”

Querying the signal quality:
sendmodem “AT+CSQ”

If you wanna use double quote in an AT command, you have to escape it like in C language (\”), eg.:

sendmodem “AT+CLCK=\”PN\”,2″

For available AT commands, refer to ETS 300 642 documentation.

UPDATE: to check the bootloader version of your iPhone, enter the following command (equivalent to ‘bbupdater -v’):

sendmodem “AT+XGENDATA”

Example output:

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

The source code of sendmodem is here:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

UPDATE: Another proggie (igsm from Marcio’s iPhone Apps) has the similar functions (thanks Ais’ comment) or maybe more powerful, however, the igsm uses /dev/tty.baseband which means you have to turn off the communication center before using it, fortunately, igsm has options to do these jobs so you don’t have to enter the long ‘launchctl …’ lines manually.

The syntax:

usage: igsm [-p pin] [-c command … -c command] [-l] [-L] [-u] [-d] [-v] [-r]

-p pin SIM pin (if needed)
-d dump IMEI IMSI …
-c cmd command to be executed (more than 1 is supported)
-l load commcenter
-L list all jobs loaded into launchd
-u unload commcenter
-r reset baseband
-m string modem init string
-M num max lines on any command
-v verbose mode
-vv verbose mode and hex dump
-h this help
-hh extended help

An example:

# igsm -c AT+CPBS?
Opened: /dev/tty.baseband
> ATE0 – set echo OFF
< OK

> AT
< OK

> AT+CPIN? – SIM requires PIN ?
< +CPIN: READY
< OK

> AT+CPBS?
< +CPBS: “SM”,34,150
< OK
Done

Marcio’s site also has a native utility iToggle, which can be useful if you frequently switch on/off some of your services. The following is a screenshot of the application’s startup screen:

iToggle


5 Comments

  1. Naren
    Posted January 6, 2009 at 9:21 pm | Permalink

    Hi there,
    in what case openconn(“dev/tty.debug “) will return -1,
    because my application is returning -1 and getting exit with status 1.
    how to avoid this situation. plase help me.
    Thanks a lot

  2. Naren
    Posted January 6, 2009 at 9:26 pm | Permalink

    Hi there,
    in what case openconn(\”dev/tty.debug \”) will return -1,
    because my application is returning -1 and getting exit with status 1.
    how to avoid this situation. plase help me.
    Thanks a lot

  3. Naren
    Posted January 6, 2009 at 9:37 pm | Permalink

    Hi
    i am getting -1 from openConn(“dev/tty.debug”), can you tell me what is the problem and how can i avoid that. please reply.
    thanks a lot.
    Naren

  4. Posted January 6, 2009 at 9:42 pm | Permalink

    Hi ,
    In what case i will get -1 from openConn(“dev/tty.debug”), i am getting it and my application is terminated with the status 1. I am writing an application to send an sms and getting this problem . I am stucked here. please help.
    thanks a lot

  5. naren
    Posted January 7, 2009 at 1:23 pm | Permalink

    Hi all,
    I am very sorry for posting same message 4 times, when i was posting
    it was not redirecting to other page so i was retrying and today i found that there are 4 posts. anyhow please reply for the same.