summaryrefslogtreecommitdiff
path: root/test/get-serving-cell-info
blob: 7a5d89816b9a72c3b5b240ce12dacb525db2ba8c (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/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'
rxlev = 'ReceivedSignalStrength'
rscp = 'ReceivedSignalCodePower'
ecn0 = 'ReceivedEnergyRatio'
rsrq = 'ReferenceSignalReceivedQuality'
rsrp = 'ReferenceSignalReceivedPower'
earfcn = 'EARFCN'
eband = 'EBand'
cqi = 'ChannelQualityIndicator'

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 rxlev in servingcell:
	print("    [ Received Signal Strength = %d]" % (servingcell[rxlev]))

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

if rscp in servingcell:
	print("    [ Received Signal Code Power = %d]" % (servingcell[rscp]))

if ecn0 in servingcell:
	print("    [ Received Energy Ratio = %d]" % (servingcell[ecn0]))

if rsrq in servingcell:
	print("    [ Reference Signal Received Quality = %d]" % (servingcell[rsrq]))

if rsrp in servingcell:
	print("    [ Reference Signal Received Power = %d]" % (servingcell[rsrp]))

if earfcn in servingcell:
	print("    [ E-UTRA Absolue Radio Frequency Channel = %d ]" % (servingcell[earfcn]))

if eband in servingcell:
	print("    [ E-UTRA operating Band = %d ]" % (servingcell[eband]))

if cqi in servingcell:
	print("    [ Channel Quality Indicator = %d ]" % (servingcell[cqi]))

print('')