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:
nearxos
2026-02-02 10:34:25 +02:00
parent 78f7ccc6db
commit 9dc35a57a2
14 changed files with 1224 additions and 115 deletions

View File

@@ -2,6 +2,14 @@
Web interface with login and role-based access (admin and support). **One HTML page per function** (Status, Logs, Restart 5G, Config, Firewall, Routes, Users) with shared navigation.
**As of Rev 2, the Web GUI includes integrated 5G connection management.** It now handles:
- Modem AT commands via native Python (pyserial)
- 5G connection lifecycle (connect, disconnect, reconnect)
- Watchdog for automatic reconnection
- NAT/firewall configuration
The standalone `5g-router` service is no longer needed; `5g-webgui` is the recommended single service.
## Access
- **URL:** `http://<device-ip>:5000` (e.g. `http://10.130.60.121:5000`)
@@ -18,6 +26,7 @@ Web interface with login and role-based access (admin and support). **One HTML p
| View status | ✓ | ✓ |
| View logs | ✓ | ✓ |
| Restart 5G | ✓ | ✓ |
| Connect/Disconnect | ✓ | ✓ |
| Edit config | ✓ | |
| Edit firewall | ✓ | |
| View routes | ✓ | |
@@ -28,8 +37,9 @@ Web interface with login and role-based access (admin and support). **One HTML p
### On the device (after main install)
```bash
# Install Python and Flask (Alpine)
# Install Python, Flask, and pyserial (Alpine)
apk add python3 py3-flask
pip install pyserial
# If you used scripts/install.sh, Web GUI is already under /usr/local/share/5g-webgui
# Enable and start the service:
@@ -44,11 +54,36 @@ cd /usr/local/share/5g-webgui && ./run.sh
```bash
cd web
pip install -r requirements.txt # or: apk add py3-flask
pip install -r requirements.txt # Flask and pyserial
python3 app.py
# Open http://localhost:5000
```
## API Endpoints for 5G Control
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/api/status` | GET | Connection status + modem info |
| `/api/5g/status` | GET | Detailed connection status |
| `/api/5g/connect` | POST | Manually connect 5G |
| `/api/5g/disconnect` | POST | Manually disconnect 5G |
| `/api/5g/restart` | POST | Disconnect then reconnect |
## Architecture
```
5g-webgui service
├── Flask App (port 5000)
├── ATClient (pyserial → /dev/ttyUSB1)
└── ConnectionManager
├── connect() - APN, PDP, IP, NAT
├── disconnect()
├── check_health()
└── watchdog_loop() (background thread)
```
The connection auto-starts when the service starts (on first web request). If `WATCHDOG_INTERVAL` is set in `/etc/5g-router.conf`, a background thread periodically checks connection health and reconnects if needed.
## Security
- Set **SECRET_KEY** in production: `export SECRET_KEY="your-random-secret"` before starting the app (or in the OpenRC service).