mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 04:13:54 +08:00
thermald: fetch more detailed network info (#20928)
This commit is contained in:
2
cereal
2
cereal
Submodule cereal updated: 3c895e7b33...5514625137
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user