Compare commits
6 Commits
b7625a883c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 01b9e0bca9 | |||
| 07b0b8c1b5 | |||
| d32ad8c94e | |||
| c5cba6a318 | |||
| f978bf31dd | |||
| 84527b9820 |
@ -23,6 +23,7 @@ peer = 'connect://127.0.0.1:14550' # outgoing connection
|
||||
[gs_video]
|
||||
peer = 'connect://127.0.0.1:5600' # outgoing connection
|
||||
bandwidth = 40 # Test HT40, aligné avec drone_video
|
||||
mcs_index = 0 # Valeur par défaut (override master.cfg defaut=1)
|
||||
|
||||
[gs_tunnel]
|
||||
fec_delay = 35000 # µs — décorrèle les 2 copies FEC (k=1/n=2) pour
|
||||
20
config/wifibroadcast_gs_5ghz.cfg
Normal file
20
config/wifibroadcast_gs_5ghz.cfg
Normal file
@ -0,0 +1,20 @@
|
||||
[common]
|
||||
wifi_channel = 149 # 149 = 5GHz (DFS/UNII) | 1 = 2.4GHz
|
||||
wifi_region = 'FR' # Réglementation CRDA — FR par défaut ici,
|
||||
# PAS 'BO'/'GY' (max tx power, hors cadre FR)
|
||||
|
||||
[gs_mavlink]
|
||||
fec_delay = 20000 # us -- meme mecanisme que gs_tunnel, valeur adaptee a MCS3. Validation formelle en attente (trafic MAVLink vivant requis). Cf v16.
|
||||
peer = 'connect://127.0.0.1:14550' # outgoing connection
|
||||
|
||||
[gs_video]
|
||||
peer = 'connect://127.0.0.1:5600' # outgoing connection
|
||||
bandwidth = 40 # HT40, jamais testé sur 5GHz avant ce profil
|
||||
mcs_index = 0 # Valeur par défaut (override master.cfg defaut=1)
|
||||
|
||||
[gs_tunnel]
|
||||
fec_delay = 35000 # µs — décorrèle les 2 copies FEC (k=1/n=2) pour
|
||||
# échapper aux fenêtres de surdité half-duplex.
|
||||
# Cf. 20260718_wireclaw_avancement_v15.md / méthode Fable.
|
||||
# Plafonne le débit tunnel à ~300 kbps (OK ping/
|
||||
# sideband/SSH interactif, PAS pour scp/gros transferts).
|
||||
@ -62,6 +62,7 @@ _pi_stats: dict | None = None
|
||||
# RSSI du flux vidéo dédié WFB-NG reçu via API JSON 127.0.0.1:8103
|
||||
_rssi_lock = threading.Lock()
|
||||
_rssi_data: dict | None = None # {"rssi_avg": -63, "snr_avg": 17}
|
||||
_band_label: str = "?" # "2.4GHz" ou "5GHz", déterminé au démarrage
|
||||
RSSI_API_PORT = 8103
|
||||
|
||||
|
||||
@ -90,6 +91,29 @@ def sideband_loop() -> None:
|
||||
print("[SIDEBAND] Arrêt.")
|
||||
|
||||
|
||||
def band_label_loop() -> None:
|
||||
"""Relit /etc/wifibroadcast.cfg toutes les 10s pour détecter un
|
||||
changement de bande (ex: après switch_band.sh) sans jamais avoir
|
||||
besoin de redémarrer ce service."""
|
||||
global _band_label
|
||||
while _running:
|
||||
try:
|
||||
with open("/etc/wifibroadcast.cfg") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line.startswith("wifi_channel"):
|
||||
val = line.split("=", 1)[1].split("#")[0].strip()
|
||||
ch = int(val)
|
||||
new_label = "2.4GHz" if ch <= 14 else "5GHz"
|
||||
if new_label != _band_label:
|
||||
print(f"[BAND] Changement détecté : {_band_label} -> {new_label}")
|
||||
_band_label = new_label
|
||||
break
|
||||
except (FileNotFoundError, ValueError, IndexError) as e:
|
||||
print(f"[BAND] Impossible de lire wifi_channel : {e}")
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
def rssi_loop() -> None:
|
||||
"""Écoute l'API JSON wfb-ng locale (127.0.0.1:8103), extrait le RSSI
|
||||
du flux vidéo dédié (id="video rx") et le stocke pour l'overlay.
|
||||
@ -200,6 +224,7 @@ def draw_rssi_pyramid(frame: np.ndarray) -> np.ndarray:
|
||||
|
||||
def draw_overlay(frame: np.ndarray) -> np.ndarray:
|
||||
"""Dessine l'overlay stats Pi Zero (fond noir semi-transparent) sur le frame."""
|
||||
global _band_label
|
||||
with _stats_lock:
|
||||
stats = _pi_stats
|
||||
if stats is None:
|
||||
@ -212,10 +237,11 @@ def draw_overlay(frame: np.ndarray) -> np.ndarray:
|
||||
temp = stats.get("temp_c", "?")
|
||||
cpu = stats.get("cpu_pct", "?")
|
||||
throttled = stats.get("throttled", False)
|
||||
throttle_str = "THROTTLED" if throttled else "ok"
|
||||
|
||||
line1 = f"{w_res}x{h_res} | {fps}fps | {enc} | {temp}C"
|
||||
line2 = f"CPU {cpu}% | {throttle_str}"
|
||||
line2 = f"CPU {cpu}% | {_band_label}"
|
||||
if throttled:
|
||||
line2 += " | THROTTLED"
|
||||
|
||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||
scale = 0.55
|
||||
@ -399,6 +425,10 @@ def main():
|
||||
tr = threading.Thread(target=rssi_loop, daemon=True)
|
||||
tr.start()
|
||||
|
||||
# Thread bande : relit wifi_channel toutes les 10s pour détecter les changements
|
||||
tb = threading.Thread(target=band_label_loop, daemon=True)
|
||||
tb.start()
|
||||
|
||||
# Thread de fond : connexion/reconnexion continue au flux GStreamer réel
|
||||
tg = threading.Thread(target=gstreamer_watcher, daemon=True)
|
||||
tg.start()
|
||||
|
||||
Reference in New Issue
Block a user