diff --git a/cereal b/cereal index 3c895e7b33..5514625137 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 3c895e7b33a06a4c087c7728a3e44986b360f3ab +Subproject commit 5514625137b1c736f7ce61a647f57273482cebd4 diff --git a/selfdrive/hardware/base.py b/selfdrive/hardware/base.py index edfd02aad0..d155f63b5d 100644 --- a/selfdrive/hardware/base.py +++ b/selfdrive/hardware/base.py @@ -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 diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py index 4f9a260cd2..1aefde26e9 100644 --- a/selfdrive/hardware/eon/hardware.py +++ b/selfdrive/hardware/eon/hardware.py @@ -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: diff --git a/selfdrive/hardware/pc/hardware.py b/selfdrive/hardware/pc/hardware.py index edbc4e07bd..0240f98bb1 100644 --- a/selfdrive/hardware/pc/hardware.py +++ b/selfdrive/hardware/pc/hardware.py @@ -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 diff --git a/selfdrive/hardware/tici/hardware.py b/selfdrive/hardware/tici/hardware.py index f277944aa3..99e8a96b27 100644 --- a/selfdrive/hardware/tici/hardware.py +++ b/selfdrive/hardware/tici/hardware.py @@ -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 diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index b7480a9ce6..7d409aed7c 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -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()