Fix jwt-token
This commit is contained in:
@@ -69,10 +69,13 @@ def is_detectable(distance_km):
|
|||||||
def fetch_devices():
|
def fetch_devices():
|
||||||
"""Fetch devices from API"""
|
"""Fetch devices from API"""
|
||||||
try:
|
try:
|
||||||
response = requests.get(f"{API_BASE_URL}/devices/map")
|
response = requests.get(f"{API_BASE_URL}/devices")
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
return data.get('data', [])
|
return data.get('data', [])
|
||||||
|
else:
|
||||||
|
print(f"Failed to fetch devices: {response.status_code}")
|
||||||
|
print(f"Response: {response.text}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error fetching devices: {e}")
|
print(f"Error fetching devices: {e}")
|
||||||
return []
|
return []
|
||||||
@@ -94,16 +97,17 @@ def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(f"{API_BASE_URL}/detections", json=detection_data)
|
response = requests.post(f"{API_BASE_URL}/detectors", json=detection_data)
|
||||||
if response.status_code == 201:
|
if response.status_code == 201:
|
||||||
status = "🚨 CRITICAL ALERT" if distance_km <= 5 else "⚠️ DETECTED" if is_detectable(distance_km) else "📡 MONITORING"
|
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={distance_km:.1f}km, RSSI={rssi:.0f}dBm")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(f"Failed to send detection: {response.status_code}")
|
print(f"❌ Failed to send detection: {response.status_code}")
|
||||||
|
print(f"Response: {response.text}")
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error sending detection: {e}")
|
print(f"❌ Error sending detection: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def calculate_position_along_path(start_lat, start_lon, end_lat, end_lon, progress):
|
def calculate_position_along_path(start_lat, start_lon, end_lat, end_lon, progress):
|
||||||
@@ -125,13 +129,36 @@ def run_orlan_detection_test():
|
|||||||
print("• Critical alerts: <5km from target")
|
print("• Critical alerts: <5km from target")
|
||||||
print("• End position: Directly overhead (0m)")
|
print("• End position: Directly overhead (0m)")
|
||||||
print("=" * 70)
|
print("=" * 70)
|
||||||
|
print(f"🔗 API Endpoint: {API_BASE_URL}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
# Test API connectivity first
|
||||||
|
print("🔍 Testing API connectivity...")
|
||||||
|
try:
|
||||||
|
response = requests.get(f"{API_BASE_URL}/health")
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("✅ API is accessible")
|
||||||
|
else:
|
||||||
|
print(f"❌ API health check failed: {response.status_code}")
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Cannot connect to API: {e}")
|
||||||
|
print("Please check:")
|
||||||
|
print("1. Is the server running?")
|
||||||
|
print("2. Is the API_BASE_URL correct?")
|
||||||
|
print(f" Current: {API_BASE_URL}")
|
||||||
|
return
|
||||||
|
|
||||||
# Fetch devices
|
# Fetch devices
|
||||||
|
print("📡 Fetching devices...")
|
||||||
devices = fetch_devices()
|
devices = fetch_devices()
|
||||||
if not devices:
|
if not devices:
|
||||||
print("❌ No devices found!")
|
print("❌ No devices found!")
|
||||||
|
print("Make sure at least one device is registered in the system.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print(f"✅ Found {len(devices)} device(s)")
|
||||||
|
|
||||||
# Use the first device as target
|
# Use the first device as target
|
||||||
target_device = devices[0]
|
target_device = devices[0]
|
||||||
print(f"🎯 Target Device: {target_device['name']}")
|
print(f"🎯 Target Device: {target_device['name']}")
|
||||||
|
|||||||
Reference in New Issue
Block a user