thermald: fetch more detailed network info (#20928)

albatross
Willem Melching 2021-05-17 13:10:08 +02:00 committed by GitHub
parent 0495426535
commit f6cf350d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 1 deletions

2
cereal

@ -1 +1 @@
Subproject commit 3c895e7b33a06a4c087c7728a3e44986b360f3ab
Subproject commit 5514625137b1c736f7ce61a647f57273482cebd4

View File

@ -50,6 +50,10 @@ class HardwareBase:
def get_subscriber_info(self):
pass
@abstractmethod
def get_network_info(self):
pass
@abstractmethod
def get_network_type(self):
pass

View File

@ -130,6 +130,9 @@ class Android(HardwareBase):
'data_connected': cell_data_connected
}
def get_network_info(self):
return None
def get_network_type(self):
wifi_check = parse_service_call_string(service_call(["connectivity", "2"]))
if wifi_check is None:

View File

@ -32,6 +32,9 @@ class Pc(HardwareBase):
def get_subscriber_info(self):
return ""
def get_network_info(self):
return None
def get_network_type(self):
return NetworkType.wifi

View File

@ -129,6 +129,26 @@ class Tici(HardwareBase):
return str(self.get_modem().Get(MM_MODEM, 'EquipmentIdentifier', dbus_interface=DBUS_PROPS, timeout=TIMEOUT))
def get_network_info(self):
modem = self.get_modem()
try:
info = modem.Command("AT+QNWINFO", int(TIMEOUT * 1000), dbus_interface=MM_MODEM, timeout=TIMEOUT)
except Exception:
return None
if info and info.startswith('+QNWINFO: '):
info = info.replace('+QNWINFO: ', '').replace('"', '')
technology, operator, band, channel = info.split(',')
return({
'technology': technology,
'operator': operator,
'band': band,
'channel': int(channel)
})
else:
return None
def parse_strength(self, percentage):
if percentage < 25:
return NetworkStrength.poor

View File

@ -155,6 +155,7 @@ def thermald_thread():
network_type = NetworkType.none
network_strength = NetworkStrength.unknown
network_info = None
current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML)
cpu_temp_filter = FirstOrderFilter(0., CPU_TEMP_TAU, DT_TRML)
@ -230,6 +231,7 @@ def thermald_thread():
try:
network_type = HARDWARE.get_network_type()
network_strength = HARDWARE.get_network_strength(network_type)
network_info = HARDWARE.get_network_info() # pylint: disable=assignment-from-none
except Exception:
cloudlog.exception("Error getting network status")
@ -238,6 +240,9 @@ def thermald_thread():
msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent()))
msg.deviceState.networkType = network_type
msg.deviceState.networkStrength = network_strength
if network_info is not None:
msg.deviceState.networkInfo = network_info
msg.deviceState.batteryPercent = HARDWARE.get_battery_capacity()
msg.deviceState.batteryStatus = HARDWARE.get_battery_status()
msg.deviceState.batteryCurrent = HARDWARE.get_battery_current()