Fix jwt-token

This commit is contained in:
2025-08-18 07:49:06 +02:00
parent 902a5b4c48
commit a89fa61005

View File

@@ -242,15 +242,13 @@ class DroneSimulator:
detection = {
"device_id": device["id"],
"drone_id": drone["id"],
"geo_lat": device["lat"], # Device detector location, NOT drone location
"geo_lon": device["lon"], # Device detector location, NOT drone location
"device_timestamp": int(time.time() * 1000),
"drone_type": drone["type"],
"rssi": rssi,
"freq": freq,
"geo_lat": drone["lat"],
"geo_lon": drone["lon"],
"device_timestamp": int(time.time() * 1000),
"confidence_level": round(confidence, 2),
"signal_duration": max(500, duration)
"drone_id": drone["id"]
}
# Update drone tracking
@@ -282,8 +280,23 @@ def send_detection(detection_data):
response = requests.post(url, json=detection_data, headers=headers, timeout=10)
if response.status_code == 201:
# Estimate distance from RSSI for display purposes only
estimated_distance = "N/A"
if 'rssi' in detection_data:
rssi = detection_data['rssi']
if rssi > -40:
estimated_distance = "<0.1km"
elif rssi > -60:
estimated_distance = "~0.5-2km"
elif rssi > -80:
estimated_distance = "~2-8km"
elif rssi > -90:
estimated_distance = "~8-15km"
else:
estimated_distance = ">15km"
print(f"✅ Device {detection_data['device_id']}: Drone {detection_data['drone_id']} "
f"(RSSI: {detection_data['rssi']}dBm, Dist: ~{detection_data.get('_distance', 'N/A')}km)")
f"(RSSI: {detection_data['rssi']}dBm, Est. distance: {estimated_distance})")
return True
else:
print(f"❌ Failed: {response.status_code} - {response.text}")
@@ -394,48 +407,45 @@ def simulate_orlan_detection_test():
# Send detection using EXACT standard payload format
detection_data = {
"device_id": target_device["id"],
"geo_lat": current_lat,
"geo_lon": current_lon,
"geo_lat": target_device["lat"], # Device detector location, NOT drone location
"geo_lon": target_device["lon"], # Device detector location, NOT drone location
"device_timestamp": int(time.time() * 1000),
"drone_type": 1, # Orlan/Military type
"rssi": rssi,
"freq": 24, # 2.4 GHz
"drone_id": drone_id,
"_distance": distance_km # Helper field for logging
"drone_id": drone_id
}
# Use centralized send_detection function for consistent debug output
success = send_detection(detection_data)
if success:
status = "🚨 CRITICAL ALERT" if distance_km <= 5 else "⚠️ DETECTED"
status = "🚨 CRITICAL ALERT" if rssi > -70 else "⚠️ DETECTED" # Use RSSI for criticality
if not DEBUG_MODE: # Avoid duplicate output when debugging
print(f"{status} - Step {step}/{total_steps}: Distance={distance_km:.1f}km, RSSI={rssi}dBm")
print(f"{status} - Step {step}/{total_steps}: RSSI={rssi}dBm")
# Show escalation messages
if distance_km <= 5 and not critical_alerts_started:
print(f"🚨 CRITICAL ALERT: Orlan within {distance_km:.1f}km - AUTO-ESCALATED!")
# Show escalation messages based on RSSI strength
if rssi > -60 and not critical_alerts_started:
print(f"🚨 CRITICAL ALERT: Strong Orlan signal (RSSI {rssi}dBm) - AUTO-ESCALATED!")
critical_alerts_started = True
elif distance_km <= 1:
print(f"🔥 IMMEDIATE THREAT: Orlan within facility perimeter!")
elif distance_km <= 0.1:
print(f"💥 DIRECTLY OVERHEAD: Orlan at {distance_km*1000:.0f}m altitude!")
elif rssi > -40:
print(f"🔥 IMMEDIATE THREAT: Very strong Orlan signal - likely overhead!")
else:
print(f"❌ Failed to send Orlan detection at step {step}")
continue
print(f"❌ Error sending detection: {e}")
else:
# Outside detection range
print(f"📡 Step {step}/{total_steps}: Distance={distance_km:.1f}km (undetectable, RSSI={rssi}dBm)")
# Outside detection range (RSSI too weak)
print(f"📡 Step {step}/{total_steps}: RSSI={rssi}dBm (signal too weak for detection)")
# Variable delay based on distance
if distance_km > 30:
delay = 2.0
elif distance_km > 15:
# Variable delay based on RSSI strength (stronger signal = faster updates)
if rssi < -90:
delay = 2.0 # Weak signal, slow updates
elif rssi < -80:
delay = 1.5
elif distance_km > 5:
elif rssi < -60:
delay = 1.0
else:
delay = 0.8
delay = 0.8 # Strong signal, fast updates
time.sleep(delay)