🤞 Sync 2026-04-23 06:19:46

This commit is contained in:
github-actions[bot]
2026-04-23 06:19:46 +08:00
parent a1df15cd3d
commit b86d032e91
250 changed files with 41507 additions and 188 deletions
+42
View File
@@ -0,0 +1,42 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=event-handler
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/event-handler
include $(INCLUDE_DIR)/package.mk
define Package/event-handler
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Event Handler for lt70
PKGARCH:=all
endef
define Package/event-handler/description
This package contains a utility
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/event-handler/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) ./files/event-handler $(1)/bin/
$(INSTALL_DIR) $(1)/etc/config
$(CP) ./files/event-handler.config $(1)/etc/config/event-handler
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/event-handler.init $(1)/etc/init.d/event-handler
$(INSTALL_DIR) $(1)/etc/rc.button
$(INSTALL_BIN) ./files/BTN_0 $(1)/etc/rc.button/
endef
$(eval $(call BuildPackage,event-handler))
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
if [ "${ACTION}" = "released" ]; then
#logger "gd3x: waiting for interrupt"
fi
if [ "${ACTION}" = "pressed" ]; then
event-handler int
#logger "gd3x: new interrupt"
fi
+71
View File
@@ -0,0 +1,71 @@
#!/bin/sh
POE="$(uci -q get event-handler.@event-handler[0].poe_gpio)"
USB="$(uci -q get event-handler.@event-handler[0].usb_gpio)"
HEAT="$(uci -q get event-handler.@event-handler[0].heat_gpio)"
WD="$(uci -q get event-handler.@event-handler[0].wd_gpio)"
LOG=/etc/event_log
int=$1
while true; do
touch $LOG
DATE=$(date)
INTS_MASK=$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/int_sum)
# poe out power error int
if [[ "$(echo $((INTS_MASK & 1)))" == "1" ]]; then
VALUE=$(cat /sys/class/gpio/gpio$POE/value)
if [[ "$VALUE" == "1" ]]; then
echo "$DATE: ${int:+$int: }poe: Warning! The maximum current limit on the PoE-OUT output has been exceeded." >> $LOG
else
echo "$DATE: ${int:+$int: }poe: The PoE-OUT output current has been restored to normal values after exceeding the maximum thresholds." >> $LOG
fi
fi
# usb power error int
if [[ "$(echo $((INTS_MASK & 2)))" == "2" ]]; then
VALUE=$(cat /sys/class/gpio/gpio$USB/value)
if [[ "$VALUE" == "1" ]]; then
echo "$DATE: ${int:+$int: }usb: Warning! The maximum current limit for the USB has been exceeded." >> $LOG
else
echo "$DATE: ${int:+$int: }usb: The USB current has been restored to normal values after exceeding the maximum threshold." >> $LOG
fi
fi
# heat int
if [[ "$(echo $((INTS_MASK & 4)))" == "4" ]]; then
VALUE=$(cat /sys/class/gpio/gpio$HEAT/value)
if [[ "$VALUE" == "1" ]]; then
echo "$DATE: ${int:+$int: }heat: The device heating circuit is enabled." >> $LOG
else
echo "$DATE: ${int:+$int: }heat: The device heating circuit is disabled." >> $LOG
fi
fi
# wd toggle int
if [[ "$(echo $((INTS_MASK & 8)))" == "8" ]]; then
VALUE=$(cat /sys/class/gpio/gpio$WD/value)
fi
# voltage threshold int
if [[ "$(echo $((INTS_MASK & 16)))" == "16" ]]; then
input_voltage="$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/input_voltage)"
voltage_threshold="$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/voltage_threshold)"
poe_out_power_gpio="$(uci -q get powersupply.system.poe_out_power_gpio)"
if [[ "$input_voltage" -lt "$voltage_threshold" ]]; then
echo 0 > /sys/class/gpio/gpio$poe_out_power_gpio/value
echo "$DATE: ${int:+$int: }voltage: PoE-OUT power supply is disabled. The input voltage is below the required threshold of $voltage_threshold mV DC. Current voltage: $input_voltage mV." >> $LOG
fi
fi
if [[ "$(wc -l < $LOG)" -ge "100" ]]; then
mv $LOG $LOG.old
fi
if [[ -n "$int" ]]; then
break
fi
sleep 1
done
exit 0
+6
View File
@@ -0,0 +1,6 @@
config event-handler
option poe_gpio '632'
option usb_gpio '633'
option heat_gpio '634'
option wd_gpio '635'
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh /etc/rc.common
START=11
USE_PROCD=1
PROG=/bin/event-handler
start_service() {
touch /etc/event_log
poe_gpio="$(uci -q get event-handler.@event-handler[0].poe_gpio)"
echo $poe_gpio > /sys/class/gpio/export
usb_gpio="$(uci -q get event-handler.@event-handler[0].usb_gpio)"
echo $usb_gpio > /sys/class/gpio/export
heat_gpio="$(uci -q get event-handler.@event-handler[0].heat_gpio)"
echo $heat_gpio > /sys/class/gpio/export
wd_gpio="$(uci -q get event-handler.@event-handler[0].wd_gpio)"
echo $wd_gpio > /sys/class/gpio/export
procd_open_instance
procd_set_param command "$PROG"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}