From 1d978085eef8822677bf257102147002853d1ebf Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Mon, 7 Oct 2024 15:35:56 +0800 Subject: [PATCH] autocore: fix read mt7622 wifi temp Signed-off-by: Tianling Shen --- package/emortal/autocore/files/tempinfo | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/package/emortal/autocore/files/tempinfo b/package/emortal/autocore/files/tempinfo index cc3760539a..c9fbd6d34e 100755 --- a/package/emortal/autocore/files/tempinfo +++ b/package/emortal/autocore/files/tempinfo @@ -1,22 +1,33 @@ #!/bin/sh +. /etc/openwrt_release + IEEE_PATH="/sys/class/ieee80211" THERMAL_PATH="/sys/class/thermal" -if grep -Eq "ipq40xx|ipq806x" "/etc/openwrt_release"; then +case "$DISTRIB_TARGET" in +ipq40xx/*|ipq806x/*) wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" -else + ;; +mediatek/mt7622) + wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" + ;; +*) wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" -fi + ;; +esac -if grep -q "ipq40xx" "/etc/openwrt_release"; then +case "$DISTRIB_TARGET" in +ipq40xx/*) if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then mt76_temp="$(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input" 2>"/dev/null")°C" fi [ -z "$mt76_temp" ] || wifi_temp="${wifi_temp:+$wifi_temp }$mt76_temp" -else + ;; +*) cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp" 2>"/dev/null")" -fi + ;; +esac if [ -n "$cpu_temp" ] && [ -z "$wifi_temp" ]; then echo -n "CPU: $cpu_temp"