About Blog Projects Papers Contact

I said I'd never blog

DeforaOS, NetBSD, reverse-engineering and stuff
Working on gsmd
Blog post by khorben
on Wednesday, September 16 2009, 15:51

Member of

Name
gprs
gsmd
hackable1
 
Last week, I have spent some time figuring out how to improve the status of the phone stack for the hopefully-soon-to-be-released development version of hackable:1 [1]. There are unfortunately a few major problems:
  • asking the PIN code multiple times [2]
  • network registration rarely effective
  • SIM contacts and messages not always fetched [3]
  • sending messages not always working
  • no GPRS support at all (from a GUI like [4])
It sounds like a lot, but I'm pretty sure the cause is the same for all: interaction with the gsmd. It's somewhat strange, since the development sources were synchronized with rev4...

Therefore, I've been using libgsmd-tool extensively for a while. First, I realized that the code for its "shell" mode (-m shell) is somewhat fragile. Unfortunately, the design of this part doesn't make it trivial to fix.

Anyway, then, I've been using the "atcmd" mode as well (-m atcmd), while working on the GPRS interaction in particular. Here comes the funny part: since this command then basically works like a serial console, why not tell pppd to use it instead of the actual serial device?

gsm-tool - (C) 2006-2007 by Harald Welte and OpenMoko, Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

ATZ
STR=`ATZ'
RSTR=`OK'
It makes even more sense in this context, since the phone stack no longer runs as root, and therefore shouldn't be allowed to tinker with the gsmd daemon at all anymore (eg "/etc/init.d/gsmd start/stop").

The first part was easy; patching libgsmd-tool to:
  • output errors to stderr,
  • remove the local echo (eg "STR=...")
  • write the response without escaping (eg "RSTR=...")
The second part took me a bit more time, but is actually trivial when you know it: using the "pty" directive of pppd instead of "/dev/ttySAC0". The change goes in /etc/ppp/peers/gprs:

##
## pppd options
##
#/dev/ttySAC0
pty "/usr/bin/libgsmd-tool -m atcmd"
It actually works up to a certain point:
  • I doubt that connectivity reports still work while the connection is up (eg signal quality, etc)
  • gsmd probably currently doesn't expect this to happen,
  • there should be some kind of pass-through mode, where libgsmd-tool would pipe the data in and out of stdin to and from the gsm daemon.
With this solved, this could be a rather elegant solution to be able to use GPRS without interrupting gsmd. I guess it would also allow the other applications sharing access to the daemon to keep the communication socket open during that time.

For the record:
Sep 16 15:47:34 syn pppd[321]: pppd 2.4.4 started by khorben, uid 1000
Sep 16 15:47:34 syn chat[518]: send (ATZ^M)
Sep 16 15:47:34 syn chat[518]: expect (OK)
Sep 16 15:47:34 syn chat[518]: OK
Sep 16 15:47:34 syn chat[518]:  -- got it
Sep 16 15:47:34 syn chat[518]: send (AT+CGDCONT=1,"IP","internet.eplus.de"^M)
Sep 16 15:47:35 syn chat[518]: expect (OK)
Sep 16 15:47:35 syn chat[518]:
Sep 16 15:47:35 syn chat[518]: OK
Sep 16 15:47:35 syn chat[518]:  -- got it
Sep 16 15:47:35 syn chat[518]: send (ATD*99***1#^M)
Sep 16 15:47:35 syn chat[518]: expect (CONNECT)
[1] http://www.hackable1.org/
[2] http://trac.hackable1.org/trac/ticket/254
[3] http://trac.hackable1.org/trac/ticket/264
[4] http://people.defora.org/~khorben/place/blog/60/New-project--gprs-for-hackable-1-on-the-Openmoko-Freerunner

Come back...

Creative Commons License RSS