add hiker_x9 support

This commit is contained in:
2026-02-12 18:13:56 +08:00
parent cba4212050
commit 957dd9862b
11 changed files with 773 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
_ _ _ _ _____ _ _
| | | (_) | | __ \ (_) | |
| |__| |_| | _____ _ __ | |__) | __ _ _ __ | |_
| __ | | |/ / _ \ '__| | ___/ '__| | '_ \| __|
| | | | | < __/ | | | | | | | | | | |_
|_| |_|_|_|\_\___|_| |_| |_| |_|_| |_|\__|
================================================
Hiker WiFi v0.5 - 全功能无线 ⭐
================================================
OpenWrt 24.10 | Linux 6.6
架构: ramips/rt305x
------------------------------------------------
功能: LuCI 中文 + WiFi AP + USB 打印 + HTTPS
性能: CPU 83% idle, 内存 ~14MB ✅
适用: 全功能无线路由器 (推荐)
------------------------------------------------
主机名: Hiker-WiFi
Web 界面: http://192.168.100.1 / https://192.168.100.1
WiFi SSID: Hiker-WiFi (默认无密码)
================================================

View File

@@ -0,0 +1,167 @@
#!/bin/sh
# Hiker Print - Reset Button Handler with LED feedback
# 按住2秒开始红蓝交替闪松开红蓝长亮2秒重启
# 按住超过5秒开始红蓝同时闪松开红蓝长亮2秒恢复出厂设置
. /lib/functions.sh
LED_R="/sys/class/leds/hiker:red:led_r/brightness"
LED_R_TRIGGER="/sys/class/leds/hiker:red:led_r/trigger"
LED_B="/sys/class/leds/hiker:blue:led_b/brightness"
LED_B_TRIGGER="/sys/class/leds/hiker:blue:led_b/trigger"
PIDFILE="/var/run/reset_button_led.pid"
# Function to check if LED script is running
stop_led_script() {
if [ -f "$PIDFILE" ]; then
local pid=$(cat "$PIDFILE")
if [ -d "/proc/$pid" ]; then
kill "$pid" 2>/dev/null
fi
rm -f "$PIDFILE"
fi
rm -f /tmp/stop_led_blink
}
# Function to turn off both LEDs
turn_off_leds() {
echo "none" > "$LED_R_TRIGGER" 2>/dev/null
echo "none" > "$LED_B_TRIGGER" 2>/dev/null
echo 0 > "$LED_R" 2>/dev/null
echo 0 > "$LED_B" 2>/dev/null
}
# Function to turn on both LEDs
turn_on_leds() {
echo "none" > "$LED_R_TRIGGER" 2>/dev/null
echo "none" > "$LED_B_TRIGGER" 2>/dev/null
echo 1 > "$LED_R" 2>/dev/null
echo 1 > "$LED_B" 2>/dev/null
}
# Function to alternate red and blue LEDs (for reboot: 2-5s)
led_alternate_blink_loop() {
local period=$1 # Blink period in seconds
echo "none" > "$LED_R_TRIGGER" 2>/dev/null
echo "none" > "$LED_B_TRIGGER" 2>/dev/null
local start_time=$(date +%s)
while [ ! -f /tmp/stop_led_blink ]; do
local now=$(date +%s)
local elapsed=$((now - start_time))
# Only start blinking after 2 seconds
if [ $elapsed -lt 2 ]; then
sleep 1
continue
fi
# Blue: on, Red: off
echo 1 > "$LED_B" 2>/dev/null
echo 0 > "$LED_R" 2>/dev/null
sleep "$period"
# Blue: off
echo 0 > "$LED_B" 2>/dev/null
# Red: on (instant switch)
echo 1 > "$LED_R" 2>/dev/null
sleep "$period"
# Red: off
echo 0 > "$LED_R" 2>/dev/null
# Blue: on (instant switch, next iteration)
done
turn_off_leds
rm -f /tmp/stop_led_blink
}
# Function to blink both LEDs together (for factory reset: 5s+)
led_both_blink_loop() {
local period=$1 # Blink period in seconds
echo "none" > "$LED_R_TRIGGER" 2>/dev/null
echo "none" > "$LED_B_TRIGGER" 2>/dev/null
local start_time=$(date +%s)
while [ ! -f /tmp/stop_led_blink ]; do
local now=$(date +%s)
local elapsed=$((now - start_time))
# Only start blinking after 2 seconds
if [ $elapsed -lt 2 ]; then
sleep 1
continue
fi
# Check if we've passed 5 seconds - switch from alternate to both blink
if [ $elapsed -lt 5 ]; then
# Still in reboot zone (2-5s): alternate
echo 1 > "$LED_B" 2>/dev/null
echo 0 > "$LED_R" 2>/dev/null
sleep "$period"
echo 0 > "$LED_B" 2>/dev/null
echo 1 > "$LED_R" 2>/dev/null
sleep "$period"
echo 0 > "$LED_R" 2>/dev/null
else
# Factory reset zone (5s+): both blink together
turn_on_leds
sleep "$period"
turn_off_leds
sleep "$period"
fi
done
turn_off_leds
rm -f /tmp/stop_led_blink
}
case "${ACTION}" in
pressed)
# Button pressed - wait 2 seconds then start LED feedback loop
stop_led_script
# Start background LED blink process (alternates 2-5s, both blink 5s+)
rm -f /tmp/stop_led_blink
led_both_blink_loop 1 &
echo $! > "$PIDFILE"
;;
released)
# Button released - stop LED and execute action
stop_led_script
# Wait for LED to turn off (no sleep - busybox doesn't support decimals)
logger "$BUTTON pressed for $SEEN seconds"
if [ "$SEEN" -lt 2 ]
then
# <2秒: 无操作
echo "No action (<2s)" > /dev/console
turn_off_leds
exit 0
elif [ "$SEEN" -ge 2 ] && [ "$SEEN" -lt 5 ]
then
# 2-5秒: 红蓝长亮2秒然后重启
echo "REBOOT (${SEEN}s pressed)" > /dev/console
turn_on_leds
sleep 2
sync
reboot
elif [ "$SEEN" -ge 5 ]
then
# >=5秒: 红蓝长亮2秒然后恢复出厂设置
echo "FACTORY RESET (${SEEN}s pressed)" > /dev/console
turn_on_leds
sleep 2
jffs2reset -y && reboot &
fi
;;
esac
return 0

View File

@@ -0,0 +1,71 @@
#!/bin/sh
# Hiker Full-WiFi network configuration
# Execute on first boot
uci delete network.lan 2>/dev/null
uci set network.LanBackup=interface
uci set network.LanBackup.proto=static
uci set network.LanBackup.device=br-lan
uci set network.LanBackup.ipaddr=192.168.100.1
uci set network.LanBackup.netmask=255.255.255.0
uci set network.LanPrint=interface
uci set network.LanPrint.proto=dhcp
uci set network.LanPrint.device=br-lan
idx=0
lan_zone_idx=""
wan_zone_idx=""
while uci get firewall.@zone[$idx] >/dev/null 2>&1; do
zone_name=$(uci get firewall.@zone[$idx].name 2>/dev/null)
if [ "$zone_name" = "lan" ] || [ "$zone_name" = "LAN" ]; then
lan_zone_idx=$idx
fi
if [ "$zone_name" = "wan" ] || [ "$zone_name" = "WAN" ]; then
wan_zone_idx=$idx
fi
idx=$((idx + 1))
done
if [ -n "$lan_zone_idx" ]; then
uci del firewall.@zone[$lan_zone_idx].network 2>/dev/null
uci add_list firewall.@zone[$lan_zone_idx].network=LanBackup 2>/dev/null
uci add_list firewall.@zone[$lan_zone_idx].network=LanPrint 2>/dev/null
fi
if [ -f /etc/config/wireless ]; then
uci set wireless.radio0.cell_density=0 2>/dev/null
uci set wireless.radio0.disabled=0 2>/dev/null
uci set wireless.default_radio0.ssid=HikerPrint 2>/dev/null
uci set wireless.default_radio0.encryption=none 2>/dev/null
uci set wireless.default_radio0.network="LanBackup LanPrint" 2>/dev/null
fi
uci set system.@system[0].hostname=HikerWifi 2>/dev/null
uci set system.@system[0].zonename=Asia/Shanghai 2>/dev/null
uci set system.@system[0].timezone=CST-8 2>/dev/null
if [ -f /etc/config/p910nd ]; then
uci set p910nd.@p910nd[0].enabled=1 2>/dev/null
uci commit p910nd 2>/dev/null
fi
led_exists=$(uci show system 2>/dev/null | grep "\.name='led_r'" | cut -d'=' -f1 | cut -d'.' -f1-2 | head -1)
if [ -z "$led_exists" ]; then
uci add system led >/dev/null 2>&1
uci set system.@led[-1].name=led_r 2>/dev/null
uci set system.@led[-1].sysfs=red:led_r 2>/dev/null
uci set system.@led[-1].trigger=netdev 2>/dev/null
uci set system.@led[-1].dev=br-lan 2>/dev/null
uci add_list system.@led[-1].mode=tx 2>/dev/null
uci add_list system.@led[-1].mode=rx 2>/dev/null
fi
uci commit network 2>/dev/null
uci commit firewall 2>/dev/null
uci commit wireless 2>/dev/null
uci commit system 2>/dev/null
exit 0