Fix jwt-token
This commit is contained in:
@@ -106,6 +106,9 @@ def haversine_distance(lat1, lon1, lat2, lon2):
|
||||
|
||||
def rssi_from_distance(distance_km):
|
||||
"""Calculate RSSI based on distance for Orlan drone"""
|
||||
# Ensure distance_km is a float
|
||||
distance_km = float(distance_km)
|
||||
|
||||
# Orlan drones have powerful military-grade transmission systems
|
||||
# Base RSSI at 1km = -55 dBm (stronger than civilian drones)
|
||||
base_rssi = -55
|
||||
@@ -143,6 +146,8 @@ def fetch_devices():
|
||||
|
||||
def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps):
|
||||
"""Send a detection to the API using EXACT standard payload format"""
|
||||
# Ensure distance_km is a float
|
||||
distance_km = float(distance_km)
|
||||
rssi = rssi_from_distance(distance_km)
|
||||
|
||||
# Use the EXACT standard payload format - NEVER change this!
|
||||
@@ -161,7 +166,7 @@ def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps)
|
||||
response = requests.post(f"{API_BASE_URL}/detectors", json=detection_data, verify=False)
|
||||
if response.status_code == 201:
|
||||
status = "🚨 CRITICAL ALERT" if distance_km <= 5 else "⚠️ DETECTED" if is_detectable(distance_km) else "📡 MONITORING"
|
||||
print(f"{status} - Step {step}/{total_steps}: Distance={distance_km:.1f}km, RSSI={rssi:.0f}dBm")
|
||||
print(f"{status} - Step {step}/{total_steps}: Distance={float(distance_km):.1f}km, RSSI={float(rssi):.0f}dBm")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to send detection: {response.status_code}")
|
||||
@@ -245,7 +250,7 @@ def run_orlan_detection_test():
|
||||
start_lon = target_device['geo_lon'] # Same longitude
|
||||
|
||||
print(f"🛫 Orlan Starting Position: {start_lat:.6f}, {start_lon:.6f}")
|
||||
print(f"📏 Initial Distance: {start_distance:.1f}km")
|
||||
print(f"📏 Initial Distance: {float(start_distance):.1f}km")
|
||||
|
||||
# Verify starting position is undetectable
|
||||
if is_detectable(start_distance):
|
||||
@@ -284,7 +289,7 @@ def run_orlan_detection_test():
|
||||
# Send detection only if within detectable range
|
||||
if detectable:
|
||||
if not detection_started:
|
||||
print(f"\n🔍 FIRST DETECTION at {distance_km:.1f}km - Orlan has entered detection range!")
|
||||
print(f"\n🔍 FIRST DETECTION at {float(distance_km):.1f}km - Orlan has entered detection range!")
|
||||
detection_started = True
|
||||
|
||||
success = send_detection(target_device, current_lat, current_lon, distance_km, step, total_steps)
|
||||
@@ -295,15 +300,15 @@ def run_orlan_detection_test():
|
||||
|
||||
# Show escalation messages
|
||||
if distance_km <= 5 and not critical_alerts_started:
|
||||
print(f"🚨 CRITICAL ALERT THRESHOLD REACHED at {distance_km:.1f}km!")
|
||||
print(f"🚨 CRITICAL ALERT THRESHOLD REACHED at {float(distance_km):.1f}km!")
|
||||
critical_alerts_started = True
|
||||
elif distance_km <= 1:
|
||||
print(f"🔥 IMMEDIATE THREAT: Orlan within {distance_km:.1f}km!")
|
||||
print(f"🔥 IMMEDIATE THREAT: Orlan within {float(distance_km):.1f}km!")
|
||||
elif distance_km <= 0.1:
|
||||
print(f"💥 DIRECTLY OVERHEAD: Orlan at {distance_km*1000:.0f}m altitude!")
|
||||
print(f"💥 DIRECTLY OVERHEAD: Orlan at {float(distance_km)*1000:.0f}m altitude!")
|
||||
else:
|
||||
# Outside detection range
|
||||
print(f"📡 Step {step}/{total_steps}: Distance={distance_km:.1f}km (undetectable, RSSI={rssi_from_distance(distance_km):.0f}dBm)")
|
||||
print(f"📡 Step {step}/{total_steps}: Distance={float(distance_km):.1f}km (undetectable, RSSI={float(rssi_from_distance(distance_km)):.0f}dBm)")
|
||||
|
||||
# Variable delay based on distance
|
||||
if distance_km > 30:
|
||||
@@ -321,8 +326,8 @@ def run_orlan_detection_test():
|
||||
print("🚨 ORLAN DETECTION TEST COMPLETED")
|
||||
print("=" * 70)
|
||||
print("Test Summary:")
|
||||
print(f"• Starting distance: {start_distance:.1f}km (undetectable)")
|
||||
print(f"• Detection range entered: ~{MAX_DETECTION_RANGE_KM:.1f}km")
|
||||
print(f"• Starting distance: {float(start_distance):.1f}km (undetectable)")
|
||||
print(f"• Detection range entered: ~{float(MAX_DETECTION_RANGE_KM):.1f}km")
|
||||
print(f"• Critical alerts triggered: <5km")
|
||||
print(f"• Final position: Directly overhead")
|
||||
print(f"• Target device: {target_device['name']}")
|
||||
|
||||
Reference in New Issue
Block a user