summaryrefslogtreecommitdiff
path: root/test/get-serving-cell-info
blob: 05dc9fe6e6a7980c8d555d95586922b95fb636aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python3

import dbus

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')

modems = manager.GetModems()
path = modems[0][0]

monitor = dbus.Interface(bus.get_object('org.ofono', path),
						'org.ofono.NetworkMonitor')

try:
	servingcell = monitor.GetServingCellInformation()
except dbus.DBusException as e:
	print("Unable to get serving cell information")
	exit()

tech = 'Technology'
mcc = 'MobileCountryCode'
mnc = 'MobileNetworkCode'
lac = 'LocationAreaCode'
cid = 'CellId'
psc = 'PrimaryScramblingCode'
rssi = 'Strength'
ber = 'BitErrorRate'

print("Current serving cell information:")

if tech in servingcell:
	print("    [ Radio Access Technology = %s]" % (servingcell[tech]))

if mcc in servingcell:
	print("    [ Mobile Country Code = %s]" % (servingcell[mcc]))

if mnc in servingcell:
	print("    [ Mobile Network Code = %s]" % (servingcell[mnc]))

if lac in servingcell:
	print("    [ Location Area Code = %d]" % (servingcell[lac]))

if cid in servingcell:
	print("    [ Cell Identity = %d]" % (servingcell[cid]))

if psc in servingcell:
	print("    [ Primary Scrambling Code = %d]" % (servingcell[psc]))

if rssi in servingcell:
	print("    [ Signal Strength = %d]" % (servingcell[rssi]))

if ber in servingcell:
	print("    [ Bit Error Rate = %d]" % (servingcell[ber]))

print('')