feat(reliability): phy1 RF role manager with uplink-on-radio1
This commit is contained in:
@@ -4812,6 +4812,44 @@ def start_health_monitor():
|
||||
threading.Thread(target=_health_loop, daemon=True).start()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# RF role manager: radio1 shared between uplink STA and attack work.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def h_rfplan_get(ctx):
|
||||
import mk8_rfplan
|
||||
return 200, {'role': mk8_rfplan.current_role(),
|
||||
'assoc': mk8_rfplan.associated(),
|
||||
'hop_paused': mk8_rfplan.hop_paused()}
|
||||
|
||||
|
||||
def h_rfplan_post(ctx):
|
||||
import mk8_gate
|
||||
import mk8_events
|
||||
import mk8_rfplan
|
||||
body = ctx.body or {}
|
||||
role = (body.get('role') or '').strip().lower()
|
||||
if role not in ('uplink', 'attack', 'idle'):
|
||||
return 400, {'error': 'role must be uplink, attack or idle'}
|
||||
mk8_gate.enter('rfplan_' + role)
|
||||
try:
|
||||
result = mk8_rfplan.set_role(
|
||||
role,
|
||||
ssid=(body.get('ssid') or '').strip() or None,
|
||||
psk=(body.get('psk') or '').strip() or None)
|
||||
except Exception as exc:
|
||||
result = {'ok': False, 'error': str(exc)}
|
||||
ok = bool(result.get('ok'))
|
||||
try:
|
||||
mk8_events.log_event('rfplan', sev='info' if ok else 'warn',
|
||||
msg='rfplan role %s %s'
|
||||
% (role, 'applied' if ok else 'failed'),
|
||||
meta=result)
|
||||
except Exception:
|
||||
pass
|
||||
return (200, result) if ok else (502, result)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Startup environment check: run once at service startup (and via
|
||||
# ``server.py --env-check`` on the payload screen) to make the device match
|
||||
@@ -7194,6 +7232,8 @@ def h_mode_release(ctx):
|
||||
|
||||
ROUTER.add('GET', r'/api/mode', h_mode_get)
|
||||
ROUTER.add('POST', r'/api/mode/release', h_mode_release)
|
||||
ROUTER.add('GET', r'/api/rfplan', h_rfplan_get)
|
||||
ROUTER.add('POST', r'/api/rfplan/role', h_rfplan_post)
|
||||
|
||||
|
||||
def serve():
|
||||
|
||||
Reference in New Issue
Block a user