Maemo internet connection from command-line

Using OS2008/Diablo in maemo (tested in N800 but should work elsewhere) it is possible to initiate (and terminate) an Internet connection from the command line. This is useful for automating tasks.

The whole thing is easily done using some dbus functionality that is available from running services.

To initiate a new connection:

dbus-send --system --print-reply --type=method_call 
    --dest=com.nokia.icd 
    /com/nokia/icd com.nokia.icd.connect 
    string:"Connection Name" uint32:0

Where “Connection Name” is the connection name as it is listed in the UI when selecting where to connect to. It can be a wireless connection, a GPRS connection via bluetooth, a PAN connection or whetever will be supported in the future.

To terminate the connection:

dbus-send --system 
    --dest=com.nokia.icd 
    /com/nokia/icd_ui com.nokia.icd_ui.disconnect 
    boolean:true