added static Access Point and Captive Portal and some small adjustments

This commit is contained in:
Helva 2026-02-08 18:51:19 +01:00
parent c2bb45ac5a
commit 29b1e5c29d
12 changed files with 101 additions and 2 deletions

View File

@ -248,3 +248,10 @@ should be -> {"ok": true, ... } -> otherwise look at the logs:
journalctl -u drive-ctl -n 80 --no-pager
## Networking / AccessPoint / Captive Portal
see /network/ folder for config

View File

@ -0,0 +1,16 @@
# --- Captive Portal Trigger (Android/iOS/Windows) ---
# Android / Google connectivity check
location = /generate_204 { return 302 /; }
location = /gen_204 { return 302 /; }
# iOS/macOS captive check
location = /hotspot-detect.html { return 200 '<HTML><HEAD><TITLE>Success</TITLE></HEAD><BODY>OK</BODY></HTML>'; add_header Content-Type text/html; }
location = /library/test/success.html { return 302 /; }
# Windows NCSI check
location = /ncsi.txt { return 302 /; }
location = /connecttest.txt { return 302 /; }
# Optional: Android “portal” URL
location = /captiveportal { return 302 /; }

View File

@ -1,6 +1,6 @@
location ^~ /drive/ {
alias /opt/helva-robot/drive/var/www/drive/;
location ^~ /drive {
alias /opt/helva-robot/drive/var/www/drive;
try_files $uri $uri/ /drive/index.html;
}

View File

@ -5,6 +5,28 @@ import serial
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.responses import HTMLResponse
import time
import logging
log = logging.getLogger("drive")
logging.basicConfig(level=logging.INFO)
_last_send_t = None
def log_send_timing(note: str = ""):
global _last_send_t
now = time.perf_counter() # monotonic + hochauflösend
if _last_send_t is None:
_last_send_t = now
return
dt_ms = (now - _last_send_t) * 1000.0
_last_send_t = now
# Nur loggen wenn "auffällig"
if dt_ms > 120:
log.warning("SERIAL SEND GAP %.0f ms %s", dt_ms, note)
SERIAL_PORT = "/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0" # ggf. /dev/ttyUSB0
BAUD = 115200
@ -24,6 +46,7 @@ def send_lr(l: int, r: int):
l = clamp255(l)
r = clamp255(r)
line = f"L {l} R {r}\n".encode("ascii")
log_send_timing("(before write)")
ser.write(line)
@app.get("/health")

View File

@ -2,6 +2,10 @@ server {
listen 80;
server_name _;
# captive portal to face
include /opt/helva-robot/drive/etc/nginx/snippets/captive-portal.conf;
# gives access to drive control
include /opt/helva-robot/drive/etc/nginx/snippets/drive.conf;
root /opt/helva-robot/face/var/www/html;

View File

@ -18,8 +18,10 @@
</div>
<div class="label" id="label">neutral</div>
</div>
<a href="/drive" class="control-link">🎮 Steuerung öffnen</a>
<script src="/app.js?v=2"></script>
</body>
</html>

View File

@ -284,3 +284,17 @@ body.emotion-sleepy .eye {
opacity: calc(var(--mouth-line-opacity) + 0.10 * var(--mouth-open));
}
.control-link{
position: fixed;
right: 16px;
bottom: 16px;
padding: 12px 16px;
background: rgba(0,0,0,0.6);
color: white;
text-decoration: none;
border-radius: 12px;
font-family: system-ui, sans-serif;
font-size: 16px;
}
.control-link:active{ transform: scale(0.98); }

6
network/etc/dnsmasq.conf Normal file
View File

@ -0,0 +1,6 @@
interface=wlan0
dhcp-range=10.42.0.50,10.42.0.150,255.255.255.0,12h
bind-interfaces
# Captive Portal DNS
address=/#/10.42.0.1

View File

@ -0,0 +1,14 @@
interface=wlan0
driver=nl80211
ssid=Helva
hw_mode=g
channel=6
# wmm_enabled=1
auth_algs=1
# wpa=2
wpa=0
# wpa_passphrase=Helva
# wpa_key_mgmt=WPA-PSK
# rsn_pairwise=CCMP
country_code=AT
ieee80211n=1

View File

@ -0,0 +1,6 @@
[Match]
Name=wlan0
[Network]
Address=10.42.0.1/24
ConfigureWithoutCarrier=yes

View File

@ -0,0 +1,6 @@
[Unit]
After=network-online.target
Wants=network-online.target
[Service]
ExecStartPre=/sbin/ip link set wlan0 up

View File

@ -0,0 +1 @@
<html>