Get network interface statistics
()
| 16666 | except Exception as e: |
| 16667 | logger.error(f"Error connecting to Wi-Fi: {e}") |
| 16668 | import traceback |
| 16669 | logger.error(traceback.format_exc()) |
| 16670 | return jsonify({'success': False, 'error': str(e)}), 500 |
| 16671 | |
| 16672 | @app.route('/api/wifi/disconnect', methods=['POST']) |
| 16673 | def disconnect_wifi(): |
| 16674 | """Disconnect from current Wi-Fi network""" |
| 16675 | try: |
| 16676 | wifi_manager = getattr(shared_data, 'ragnar_instance', None) |
| 16677 | if not wifi_manager or not hasattr(wifi_manager, 'wifi_manager'): |
| 16678 | return jsonify({'error': 'Wi-Fi manager not available'}), 503 |
| 16679 | |
| 16680 | # Stop any active connection and start AP mode |
| 16681 | result = wifi_manager.wifi_manager.start_ap_mode() |
| 16682 | |
| 16683 | return jsonify({ |
| 16684 | 'success': result, |
| 16685 | 'message': 'Disconnected and started AP mode' if result else 'Failed to start AP mode' |
| 16686 | }) |
| 16687 | |
| 16688 | except Exception as e: |
| 16689 | logger.error(f"Error disconnecting Wi-Fi: {e}") |
| 16690 | return jsonify({'error': str(e)}), 500 |
| 16691 | |
| 16692 | @app.route('/api/wifi/exit-ap', methods=['POST']) |
| 16693 | def exit_ap_mode(): |
| 16694 | """Exit AP mode and reconnect to WiFi""" |
| 16695 | try: |
| 16696 | wifi_manager = getattr(shared_data, 'ragnar_instance', None) |
| 16697 | if not wifi_manager or not hasattr(wifi_manager, 'wifi_manager'): |
| 16698 | return jsonify({'success': False, 'error': 'Wi-Fi manager not available'}), 503 |
| 16699 | |
| 16700 | # Use the existing method to exit AP mode from web interface |
| 16701 | result = wifi_manager.wifi_manager.exit_ap_mode_from_web() |
| 16702 | |
| 16703 | return jsonify({ |
| 16704 | 'success': result, |
| 16705 | 'message': 'Exiting AP mode and reconnecting to WiFi' if result else 'Failed to exit AP mode' |
| 16706 | }) |
| 16707 | |
| 16708 | except Exception as e: |
| 16709 | logger.error(f"Error exiting AP mode: {e}") |
| 16710 | return jsonify({'success': False, 'error': str(e)}), 500 |
nothing calls this directly
no test coverage detected