sysmngr: use sysfs for TemperatureStatus

This commit is contained in:
Vivek Kumar Dutta 2025-12-02 13:59:07 +05:30
parent ac78f69136
commit 39f30cd31a
No known key found for this signature in database
GPG key ID: 4E09F5AD8265FD4C
3 changed files with 2 additions and 158 deletions

View file

@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sysmngr
PKG_VERSION:=1.1.3
PKG_VERSION:=1.1.4
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/system/sysmngr.git
PKG_SOURCE_VERSION:=2643356bde5bc45c79f46c7e8969a085d2f3e39d
PKG_SOURCE_VERSION:=3b5dd192b5f4de1bb1d40e1da2e867c91e6ef975
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@ -112,16 +112,6 @@ define Package/$(PKG_NAME)/install
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) $(PKG_NAME)
$(INSTALL_BIN) ./files/etc/sysmngr/fwbank $(1)/etc/sysmngr/fwbank
ifeq ($(CONFIG_SYSMNGR_TEMPERATURE_STATUS),y)
$(INSTALL_DIR) $(1)/etc/sysmngr
ifeq ($(CONFIG_TARGET_brcmbca),y)
$(INSTALL_BIN) ./files/etc/sysmngr/broadcom.sh $(1)/etc/sysmngr/temperature.sh
else
$(INSTALL_BIN) ./files/etc/sysmngr/default.sh $(1)/etc/sysmngr/temperature.sh
endif
endif
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View file

@ -1,84 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
function get_wlan_temperature()
{
add_wlan_temp() {
local temp="$(wlctl -i "$1" phy_tempsense)"
[ -n "$temp" ] || temp='-274'
json_add_object
json_add_string "name" "wlan-$1"
json_add_int "temperature" "$temp"
json_close_object
}
config_load wireless
config_foreach add_wlan_temp wifi-device
}
function get_sfp_temperature()
{
local temp=""
local sfp="$(ubus call sfp.ddm get-temperature)"
json_load "$sfp"
json_get_var temp temperature
[ -n "$temp" ] || temp='-274'
echo "$temp"
}
function get_cpu_temperature()
{
local cpu="$(cat /sys/devices/virtual/thermal/thermal_zone0/temp 2>/dev/null)"
[ -n "$cpu" ] || cpu='-274000'
echo "${cpu:0:-3}"
}
function get_temperature_status()
{
local hasSfp="$(db -q get hw.board.hasSfp)"
json_init
json_add_array "status"
json_add_object
json_add_string "name" "cpu"
json_add_int "temperature" "$(get_cpu_temperature)"
json_close_object
[ -s /etc/config/wireless ] && get_wlan_temperature
[ "$hasSfp" = "1" ] && {
json_add_object
json_add_string "name" "sfp"
json_add_int "temperature" "$(get_sfp_temperature)"
json_close_object
}
json_close_array
json_dump
}
function dump_invalid()
{
json_init
json_add_string "fault" "invalid request"
json_dump
}
case "$1" in
status)
get_temperature_status
;;
*)
dump_invalid
;;
esac

View file

@ -1,62 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
function get_wlan_temperature()
{
:
}
function get_sfp_temperature()
{
echo "-274"
}
function get_cpu_temperature()
{
echo "-274"
}
function get_temperature_status()
{
local hasSfp="$(db -q get hw.board.hasSfp)"
json_init
json_add_array "status"
json_add_object
json_add_string "name" "cpu"
json_add_int "temperature" "$(get_cpu_temperature)"
json_close_object
[ -s /etc/config/wireless ] && get_wlan_temperature
[ "$hasSfp" = "1" ] && {
json_add_object
json_add_string "name" "sfp"
json_add_int "temperature" "$(get_sfp_temperature)"
json_close_object
}
json_close_array
json_dump
}
function dump_invalid()
{
json_init
json_add_string "fault" "invalid request"
json_dump
}
case "$1" in
status)
get_temperature_status
;;
*)
dump_invalid
;;
esac