Enhance 5G modem management with integrated web GUI and connection control
- Introduced a web GUI for managing 5G connections, replacing the standalone 5g-router service. - Updated scripts to ensure exclusive access to the AT port, preventing conflicts. - Improved troubleshooting documentation in 5G_MODEM_TROUBLESHOOTING.md, adding checks for processes using the AT port. - Enhanced connection management in the web app, including auto-connect and detailed status APIs. - Updated installation scripts to reflect changes in service management and dependencies.
This commit is contained in:
@@ -8,8 +8,13 @@ CONFIG="/etc/5g-router.conf"
|
||||
AT_PORT="${AT_PORT:-/dev/ttyUSB1}"
|
||||
WAN_IF="${WAN_IF:-eth1}"
|
||||
LOG_FILE="/var/log/5g-router.log"
|
||||
AT_LOCK="/var/lock/5g-at.lock"
|
||||
|
||||
[ -f "$CONFIG" ] && . "$CONFIG"
|
||||
[ -f "$CONFIG" ] && . "$CONFIG" || true
|
||||
|
||||
# Acquire lock on AT port so we don't conflict with connect-5g.sh or modem-status-at.sh
|
||||
exec 9>"$AT_LOCK"
|
||||
flock -w 15 9 || echo "Warning: could not acquire AT lock (another process using port)"
|
||||
|
||||
echo "=============================================="
|
||||
echo " Alpine 5G Router – Full Troubleshoot"
|
||||
@@ -59,10 +64,29 @@ else
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- 5) AT port test (with longer wait like connect-5g.sh) ---
|
||||
echo "--- 5) AT command test on $AT_PORT (wait 3s) ---"
|
||||
# --- 5) Processes using the AT port (can block or conflict) ---
|
||||
echo "--- 5) Processes using $AT_PORT (lsof) ---"
|
||||
if [ -e "$AT_PORT" ]; then
|
||||
if command -v lsof >/dev/null 2>&1; then
|
||||
_lsof=$(lsof 2>/dev/null | grep -F "$AT_PORT")
|
||||
if [ -n "$_lsof" ]; then
|
||||
echo "$_lsof" | sed 's/^/ /'
|
||||
else
|
||||
echo " No process has $AT_PORT open (good)"
|
||||
fi
|
||||
else
|
||||
echo " (lsof not installed – install with: apk add lsof)"
|
||||
fi
|
||||
else
|
||||
echo " Port does not exist (nothing to list)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- 6) AT port test (with longer wait like connect-5g.sh) ---
|
||||
echo "--- 6) AT command test on $AT_PORT (wait 3s) ---"
|
||||
if [ -c "$AT_PORT" ]; then
|
||||
out=$(timeout 8 sh -c "
|
||||
[ -c \"$AT_PORT\" ] || exit 1
|
||||
cat $AT_PORT 2>/dev/null &
|
||||
_p=\$!
|
||||
sleep 0.5
|
||||
@@ -82,11 +106,11 @@ else
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- 6) AT probe on all ttyUSB (which port responds) ---
|
||||
echo "--- 6) AT probe on each ttyUSB port ---"
|
||||
# --- 7) AT probe on all ttyUSB (which port responds) ---
|
||||
echo "--- 7) AT probe on each ttyUSB port ---"
|
||||
for port in /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3; do
|
||||
[ -c "$port" ] || continue
|
||||
out=$(timeout 5 sh -c "cat $port 2>/dev/null & _p=\$!; sleep 0.3; echo -e 'AT\r' > $port; sleep 2; kill \$_p 2>/dev/null" 2>/dev/null)
|
||||
out=$(timeout 5 sh -c "[ -c \"$port\" ] || exit 1; cat $port 2>/dev/null & _p=\$!; sleep 0.3; echo -e 'AT\r' > $port; sleep 2; kill \$_p 2>/dev/null" 2>/dev/null)
|
||||
if echo "$out" | grep -q 'OK'; then
|
||||
echo " $port: OK (use this as AT_PORT if different from config)"
|
||||
else
|
||||
@@ -95,8 +119,8 @@ for port in /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3; do
|
||||
done
|
||||
echo ""
|
||||
|
||||
# --- 7) 5g-router service ---
|
||||
echo "--- 7) 5g-router service ---"
|
||||
# --- 8) 5g-router service ---
|
||||
echo "--- 8) 5g-router service ---"
|
||||
if command -v rc-service >/dev/null 2>&1; then
|
||||
rc-service 5g-router status 2>&1 | sed 's/^/ /'
|
||||
else
|
||||
@@ -104,8 +128,8 @@ else
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- 8) WAN interface and routing ---
|
||||
echo "--- 8) WAN interface ($WAN_IF) and default route ---"
|
||||
# --- 9) WAN interface and routing ---
|
||||
echo "--- 9) WAN interface ($WAN_IF) and default route ---"
|
||||
if ip link show "$WAN_IF" >/dev/null 2>&1; then
|
||||
ip link show "$WAN_IF" 2>/dev/null | sed 's/^/ /'
|
||||
ip -4 addr show "$WAN_IF" 2>/dev/null | sed 's/^/ /'
|
||||
@@ -115,8 +139,8 @@ fi
|
||||
ip route show default 2>/dev/null | sed 's/^/ /'
|
||||
echo ""
|
||||
|
||||
# --- 9) Full 5g-router log ---
|
||||
echo "--- 9) Full 5g-router log (last 60 lines of $LOG_FILE) ---"
|
||||
# --- 10) Full 5g-router log ---
|
||||
echo "--- 10) Full 5g-router log (last 60 lines of $LOG_FILE) ---"
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
tail -60 "$LOG_FILE" 2>/dev/null | sed 's/^/ /'
|
||||
else
|
||||
@@ -124,12 +148,12 @@ else
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- 10) Optional: modem status script ---
|
||||
# --- 11) Optional: modem status script ---
|
||||
if [ -x "/usr/local/bin/modem-status-at.sh" ]; then
|
||||
echo "--- 10) modem-status-at.sh (registration, signal) ---"
|
||||
echo "--- 11) modem-status-at.sh (registration, signal) ---"
|
||||
/usr/local/bin/modem-status-at.sh 2>&1 | head -30 | sed 's/^/ /'
|
||||
else
|
||||
echo "--- 10) modem-status-at.sh ---"
|
||||
echo "--- 11) modem-status-at.sh ---"
|
||||
echo " Not installed"
|
||||
fi
|
||||
echo ""
|
||||
@@ -140,6 +164,8 @@ echo "=============================================="
|
||||
echo ""
|
||||
echo "Quick fixes to try:"
|
||||
echo " - ttyUSB is regular file: rm $AT_PORT && mknod $AT_PORT c 188 1 && chmod 660 $AT_PORT && chown root:dialout $AT_PORT"
|
||||
echo " - Stray /dev/ttyUSB (no number): rm /dev/ttyUSB"
|
||||
echo " - Port held by another process (see section 5): stop ModemManager (rc-service ModemManager stop) or restart 5g-router"
|
||||
echo " - Modem in Mode 41 (7127): power-cycle modem or reboot; need Mode 40 (7126) for AT"
|
||||
echo " - AT not OK: set AT_PORT in $CONFIG to the port that showed OK above (e.g. /dev/ttyUSB0)"
|
||||
echo " - Restart connection: service 5g-router restart or /usr/local/bin/connect-5g.sh"
|
||||
|
||||
Reference in New Issue
Block a user