Gsmd

From Openmoko

Revision as of 23:58, 12 April 2007 by VlgY6e (Talk | contribs)

Jump to: navigation, search

gsmd is the GSM daemon running in background of the GTA01 phone, managing the actual 'phone' part of the phone :)

Contents

Usage

gsmd is usually started as a daemon in background, but can be run in foreground mode for debugging.

The options can be queried like:

> src/gsmd/gsmd --help
gsmd - (C) 2006 by Harald Welte <laforge@gnumonks.org>
This program is FREE SOFTWARE under the terms of GNU GPL

Usage:
        -v      --version       Display program version
        -d      --daemon        Deamonize
        -h      --help          Display this help message
        -p dev  --device dev    Specify serial device to be used
        -s spd  --speed spd     Specify speed in bps (9600,38400,115200,...)
        -F      --hwflow        Hardware Flow Control (RTS/CTS)
        -L      --leak-report   Leak Report of talloc memory allocator
        -l file --logfile file  Specify a logfile to log to

If your GSM modem is attached to ttySAC0 (like in the Neo1973, you can e.g. use:

gsmd -p /dev/ttySAC0 -s 115200 -F

libgsmd

libgsmd is a library with C language API for application programs. Programs using this library can use the phone, e.g. make phone calls, receive incoming calls, register to the network, etc.

libgsmd-tool

libgsmd-tool is a small demo applicaiton that can be used to demonstrate the usage of the libgsmd API.

Usage

libgsmd-tool has multiple modes.

Usage of shell mode

Shell mode provides a simple text-based command interface for making voice calls.

The shell mode can be started using

libgsmd-tool -m shell

It can be used like in the following example:

> src/util/libgsmd-tool -m shell
libgsm-tool - (C) 2006 by Harald Welte
This program is Free Software and has ABSOLUTELY NO WARRANTY

?
#       A       Answer incoming call
        D       Dial outgoing number
        H       Hangup call
        O       Power On
        o       Power Off
        R       Register Netowrk
O
# EVENT: PIN request (type=1) Please enter PIN: 6582
R
# EVENT: Netreg searching for network 
EVENT: Netreg registered (home network) 

D03024033902
# Dial 03024033902
EVENT: Call Progress: UNKNOWN
EVENT: Call Progress: PROCEED
EVENT: Call Progress: SYNC
EVENT: Call Progress: ALERT
H
# Hangup
EVENT: Call Progress: DISCONNECT
EVENT: Call Progress: RELEASE

EVENT: Incoming call type=2!
EVENT: Incoming call clip=`"03024033902"'
EVENT: Incoming call type=2!
A
# Answer
RSTR=`OK'
H
# Hangup
RSTR=`OK'

Usage of atcmd mode

The atcmd mode is a passthrough-mode. Passthrough means that it accepts GSM 07.07 commands, passes them through the daemon to the phone, and returns you the response. this is very useful for debugging.

The atcmd mode can be started using

libgsmd-tool -m atcmd

Usage is like in the following example:

> src/util/libgsmd-tool -m atcmd
libgsm-tool - (C) 2006 by Harald Welte
This program is Free Software and has ABSOLUTELY NO WARRANTY

AT CPAS
STR=`AT CPAS'
RSTR=` CPAS: 0'
AT COPS=?
STR=`AT COPS=?'
RSTR=` COPS: (2,"E-Plus","E-Plus","26203"),(3,"o2 - de","o2 - de","26207"),(3,"Vodafone.de","Vodafone","26202"),(3,"T-Mobile D","TMO D","26201")'

Currently missing

(please add items to this list if you're missing more features)

  • Phone related functions
    • Airplane mode / gsmd stop (this will be done outside gsmd, by using runlevels / upstart)
    • obtain manufacturer/model/revision/IMEI
  • Network related functions
    • obtain list of available operators
    • select operator out of the list
    • obtain list of operator names
    • query field strength (rather than just events)
  • SMS related features
    • send SMS
    • receive SMS
    • obtain IMSI
    • access to SIM-card stored SMS
  • SIM related functions
    • read phonebook entry
    • write phonebook entry
  • GPRS related functions
    • set up GPRS link, use it via separate DLC of TS07.10 multiplex
  • gsmd internal infrastructure
    • fine-grained event subscriptions (rather than wildcard-subscribe)
    • possibility to specify log-level from command line
    • logfile re-opening on SIGUSR1 or SIGHUP (logrotate)
    • permission handling
    • d-bus interface

Implementation Thoughts

State tracking

gsmd needs to do apropriate state tracking of the underlying GSM hardware. For many of the state transition we only get events from the GSM Modem, but don't have apropriate query commands. Thus, assuming gsmd runs all the time, applications can come and go, but still have an idea about the current state of the modem, even if they missed the initial state transitions.

Also, gsmd state tracking allows us to allow for safer interoperability of multiple applications. If i.e. one applications has just started an outgoing call, gsmd can detect another application who intends to interfere with that and deny access

device power state

  • modem completely off, not responding to AT commands
  • modem responding to AT commands, but powered off (CFUN=0)
  • modem responding to AT commands, in some power saving mode
  • modem responding to AT commands, powered on, fully operational (CFUN=1)

network registration state

  • not registered to any network, not trying to register
  • not registred to any network, searching/trying to register
  • registered to home network (including cellID)
  • registered to roaming network (including cellID)

ciphering indication state

  • ciphering indications not supported by modem
  • ciphering indications supported, but disabled in SIM
  • ciphering indications supported, ciphering active
  • ciphering indications supported, ciphering inactive

call state

  • idle
  • busy

Sources of gsmd are kept in OpenMoko svn in src/target/gsm directory.

Personal tools

gsmd is the GSM daemon running in background of the GTA01 phone, managing the actual 'phone' part of the phone :)

Usage

gsmd is usually started as a daemon in background, but can be run in foreground mode for debugging.

The options can be queried like:

> src/gsmd/gsmd --help
gsmd - (C) 2006 by Harald Welte <laforge@gnumonks.org>
This program is FREE SOFTWARE under the terms of GNU GPL

Usage:
        -v      --version       Display program version
        -d      --daemon        Deamonize
        -h      --help          Display this help message
        -p dev  --device dev    Specify serial device to be used
        -s spd  --speed spd     Specify speed in bps (9600,38400,115200,...)
        -F      --hwflow        Hardware Flow Control (RTS/CTS)
        -L      --leak-report   Leak Report of talloc memory allocator
        -l file --logfile file  Specify a logfile to log to

If your GSM modem is attached to ttySAC0 (like in the Neo1973, you can e.g. use:

gsmd -p /dev/ttySAC0 -s 115200 -F

libgsmd

libgsmd is a library with C language API for application programs. Programs using this library can use the phone, e.g. make phone calls, receive incoming calls, register to the network, etc.

libgsmd-tool

libgsmd-tool is a small demo applicaiton that can be used to demonstrate the usage of the libgsmd API.

Usage

libgsmd-tool has multiple modes.

Usage of shell mode

Shell mode provides a simple text-based command interface for making voice calls.

The shell mode can be started using

libgsmd-tool -m shell

It can be used like in the following example:

> src/util/libgsmd-tool -m shell
libgsm-tool - (C) 2006 by Harald Welte
This program is Free Software and has ABSOLUTELY NO WARRANTY

?
#       A       Answer incoming call
        D       Dial outgoing number
        H       Hangup call
        O       Power On
        o       Power Off
        R       Register Netowrk
O
# EVENT: PIN request (type=1) Please enter PIN: 6582
R
# EVENT: Netreg searching for network 
EVENT: Netreg registered (home network) 

D03024033902
# Dial 03024033902
EVENT: Call Progress: UNKNOWN
EVENT: Call Progress: PROCEED
EVENT: Call Progress: SYNC
EVENT: Call Progress: ALERT
H
# Hangup
EVENT: Call Progress: DISCONNECT
EVENT: Call Progress: RELEASE

EVENT: Incoming call type=2!
EVENT: Incoming call clip=`"03024033902"'
EVENT: Incoming call type=2!
A
# Answer
RSTR=`OK'
H
# Hangup
RSTR=`OK'

Usage of atcmd mode

The atcmd mode is a passthrough-mode. Passthrough means that it accepts GSM 07.07 commands, passes them through the daemon to the phone, and returns you the response. this is very useful for debugging.

The atcmd mode can be started using

libgsmd-tool -m atcmd

Usage is like in the following example:

> src/util/libgsmd-tool -m atcmd
libgsm-tool - (C) 2006 by Harald Welte
This program is Free Software and has ABSOLUTELY NO WARRANTY

AT CPAS
STR=`AT CPAS'
RSTR=` CPAS: 0'
AT COPS=?
STR=`AT COPS=?'
RSTR=` COPS: (2,"E-Plus","E-Plus","26203"),(3,"o2 - de","o2 - de","26207"),(3,"Vodafone.de","Vodafone","26202"),(3,"T-Mobile D","TMO D","26201")'

Currently missing

(please add items to this list if you're missing more features)

  • Phone related functions
    • Airplane mode / gsmd stop (this will be done outside gsmd, by using runlevels / upstart)
    • obtain manufacturer/model/revision/IMEI
  • Network related functions
    • obtain list of available operators
    • select operator out of the list
    • obtain list of operator names
    • query field strength (rather than just events)
  • SMS related features
    • send SMS
    • receive SMS
    • obtain IMSI
    • access to SIM-card stored SMS
  • SIM related functions
    • read phonebook entry
    • write phonebook entry
  • GPRS related functions
    • set up GPRS link, use it via separate DLC of TS07.10 multiplex
  • gsmd internal infrastructure
    • fine-grained event subscriptions (rather than wildcard-subscribe)
    • possibility to specify log-level from command line
    • logfile re-opening on SIGUSR1 or SIGHUP (logrotate)
    • permission handling
    • d-bus interface

Implementation Thoughts

State tracking

gsmd needs to do apropriate state tracking of the underlying GSM hardware. For many of the state transition we only get events from the GSM Modem, but don't have apropriate query commands. Thus, assuming gsmd runs all the time, applications can come and go, but still have an idea about the current state of the modem, even if they missed the initial state transitions.

Also, gsmd state tracking allows us to allow for safer interoperability of multiple applications. If i.e. one applications has just started an outgoing call, gsmd can detect another application who intends to interfere with that and deny access

device power state

  • modem completely off, not responding to AT commands
  • modem responding to AT commands, but powered off (CFUN=0)
  • modem responding to AT commands, in some power saving mode
  • modem responding to AT commands, powered on, fully operational (CFUN=1)

network registration state

  • not registered to any network, not trying to register
  • not registred to any network, searching/trying to register
  • registered to home network (including cellID)
  • registered to roaming network (including cellID)

ciphering indication state

  • ciphering indications not supported by modem
  • ciphering indications supported, but disabled in SIM
  • ciphering indications supported, ciphering active
  • ciphering indications supported, ciphering inactive

call state

  • idle
  • busy

Sources of gsmd are kept in OpenMoko svn in src/target/gsm directory.