Ticket #149: gprs-on.py

File gprs-on.py, 820 bytes (added by Fredrik Wendt <fredrik@…>, 4 years ago)
Line 
1#!/usr/bin/python
2
3import dbus
4
5apns = {
6        'S COMVIQ': 'internet.parlino.se',
7#       'S COMVIQ': 'internet.tele2.se',
8        'TELIA S': 'internet.telia.se',
9        'vodafone SE': 'services.vodafone.net'
10}
11username = 'x'
12password = 'x'
13
14sbus = dbus.SystemBus()
15obj = 'org.freesmartphone.frameworkd'
16objpath = '/org/freesmartphone/GSM/Device'
17proxy = sbus.get_object(obj, objpath)
18status = proxy.GetStatus(dbus_interface='org.freesmartphone.GSM.Network')
19
20if (status['registration'] != 'home'):
21  print "Illegal GSM network registration state: " + status['registration'];
22  print "You might want to mdbus -s org.freesmartphone.ophoned /org/freesmartphone/GSM/Device org.freesmartphone.GSM.Network.Register"
23else:
24  apn = apns[status['provider']]
25  proxy.ActivateContext(apn, username, password, dbus_interface='org.freesmartphone.GSM.PDP')