Handle scan start request via WebSocket
(data)
| 14467 | |
| 14468 | # Force fresh timestamp and prevent caching |
| 14469 | debug_info['timestamp'] = datetime.now().isoformat() |
| 14470 | debug_info['generated_at'] = time.time() |
| 14471 | |
| 14472 | response = jsonify(debug_info) |
| 14473 | response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' |
| 14474 | response.headers['Pragma'] = 'no-cache' |
| 14475 | response.headers['Expires'] = '0' |
| 14476 | return response |
| 14477 | |
| 14478 | except Exception as e: |
| 14479 | logger.error(f"Error in verbose debug logs: {e}") |
| 14480 | return jsonify({'error': str(e), 'timestamp': datetime.now().isoformat()}), 500 |
| 14481 | |
| 14482 | @app.route('/api/debug/test-robust-tracking') |
| 14483 | def test_robust_tracking(): |
| 14484 | """Test endpoint to verify robust tracking logic is working""" |
| 14485 | try: |
| 14486 | logger.info("[TEST] Robust tracking test endpoint called") |
| 14487 | |
| 14488 | # Test the network data reading with new logic |
| 14489 | network_data = read_wifi_network_data() |
| 14490 | |
| 14491 | # Count devices by failure status |
| 14492 | max_failed_pings = shared_data.config.get('network_max_failed_pings', 15) # Changed to 15 for more stability |
| 14493 | results = { |
| 14494 | 'total_devices': len(network_data), |
| 14495 | 'devices_with_failure_data': 0, |
| 14496 | 'devices_exceeding_failure_limit': 0, |
| 14497 | 'devices_active_by_robust_rule': 0, |
| 14498 | 'max_failed_pings_threshold': max_failed_pings, |
| 14499 | 'sample_devices': [], |
| 14500 | 'test_timestamp': datetime.now().isoformat() |
| 14501 | } |
| 14502 | |
| 14503 | for entry in network_data[:5]: # Sample first 5 |
| 14504 | ip = entry.get('IPs', '') |
| 14505 | failed_ping_count = entry.get('FailedPingCount', 'N/A') |
| 14506 | alive_status = entry.get('Alive', 'N/A') |
| 14507 | |
| 14508 | if isinstance(failed_ping_count, int): |
| 14509 | results['devices_with_failure_data'] += 1 |
| 14510 | if failed_ping_count >= max_failed_pings: |
| 14511 | results['devices_exceeding_failure_limit'] += 1 |
| 14512 | else: |
| 14513 | results['devices_active_by_robust_rule'] += 1 |
| 14514 | |
| 14515 | results['sample_devices'].append({ |
| 14516 | 'ip': ip, |