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