(directory: Optional[str])
| 3624 | """Waterfall row for the CYD's Waterfall screen (WiFi transport; the serial |
| 3625 | transport streams these over the cable). `band` selects the sweep, `on=0` |
| 3626 | releases the SDR. Returns a data row, {'waiting':1}, or {'err':'no SDR'}.""" |
| 3627 | band = request.args.get('band') or '433' |
| 3628 | on = request.args.get('on', '1') not in ('0', 'false', 'off', '') |
| 3629 | cyd_waterfall.request(band, on) |
| 3630 | return jsonify(cyd_waterfall.latest_row()) |
| 3631 | |
| 3632 | |
| 3633 | @app.route('/api/cyd/action', methods=['POST']) |
| 3634 | def cyd_action(): |
| 3635 | """Dispatch an operator action requested from a node's touch screen. The |
| 3636 | action is validated against cyd_node.ALLOWED_ACTIONS, executed against the |
| 3637 | live subsystem (_cyd_dispatch_action), and logged with its outcome so the |
| 3638 | operator can see what a tap did via /api/cyd/nodes.""" |
| 3639 | data = request.get_json(silent=True) or {} |
| 3640 | action = str(data.get('action') or '').strip() |
| 3641 | node_name = data.get('node') or getattr(g, 'cyd_node', None) or 'cyd-node' |
| 3642 | if action not in cyd_node.ALLOWED_ACTIONS: |
| 3643 | return jsonify({'success': False, 'error': 'unknown action'}), 400 |
| 3644 | status, code = _cyd_dispatch_tracked(action, node_name) |
| 3645 | cyd_node.record_action(node_name, action, request.remote_addr, status=status) |
| 3646 | logger.info(f"[cyd] node {node_name} action '{action}' -> {status}") |
| 3647 | ok = status in ('done', 'started') |
| 3648 | return jsonify({'success': ok, 'accepted': action, 'status': status}), code |
no outgoing calls
no test coverage detected