diff --git a/test_orlan_detection.py b/test_orlan_detection.py index a2fa37c..5d7319c 100644 --- a/test_orlan_detection.py +++ b/test_orlan_detection.py @@ -144,20 +144,21 @@ def fetch_devices(): print(f"Error fetching devices: {e}") return [] -def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps): +def send_detection(device, 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! + # Use the device's coordinates as the detection location + # The RSSI indicates how close/far the drone is from this device detection_data = { "device_id": device["id"], - "geo_lat": drone_lat, - "geo_lon": drone_lon, + "geo_lat": float(device["geo_lat"]), # Device location + "geo_lon": float(device["geo_lon"]), # Device location "device_timestamp": int(time.time() * 1000), # Current timestamp in milliseconds "drone_type": 1, # Orlan/Military type - "rssi": int(rssi), + "rssi": int(rssi), # RSSI indicates distance from device "freq": 24, # Orlan operates on 2.4 GHz (24 = 2400 MHz) "drone_id": 2000 + step # Unique drone ID for tracking } @@ -176,13 +177,6 @@ def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps) print(f"āŒ Error sending detection: {e}") return False -def calculate_position_along_path(start_lat, start_lon, end_lat, end_lon, progress): - """Calculate position along great circle path""" - # Simple linear interpolation for this test - lat = start_lat + (end_lat - start_lat) * progress - lon = start_lon + (end_lon - start_lon) * progress - return lat, lon - def run_orlan_detection_test(): """Run the comprehensive Orlan detection test""" print("=" * 70) @@ -248,14 +242,11 @@ def run_orlan_detection_test(): print(f"šŸ“ Target Location: {target_lat:.6f}, {target_lon:.6f}") - # Calculate starting position 50km away (due north for simplicity) + # Calculate starting position 50km away for distance simulation start_distance = 50.0 # km - # Move 50km north of target - start_lat = target_lat + (start_distance / 111.0) # ~111km per degree latitude - start_lon = target_lon # Same longitude - print(f"šŸ›« Orlan Starting Position: {start_lat:.6f}, {start_lon:.6f}") - print(f"šŸ“ Initial Distance: {float(start_distance):.1f}km") + print(f"šŸ›« Orlan Starting Distance: {float(start_distance):.1f}km from device") + print(f"ļæ½ Device Location: {target_lat:.6f}, {target_lon:.6f}") # Verify starting position is undetectable if is_detectable(start_distance): @@ -281,13 +272,6 @@ def run_orlan_detection_test(): # Use exponential curve for realistic approach - slower at distance, faster when close distance_km = start_distance * (1 - progress) ** 1.8 + final_distance * progress ** 1.8 - # Calculate current position - current_lat, current_lon = calculate_position_along_path( - start_lat, start_lon, - target_lat, target_lon, - progress - ) - # Check detection status detectable = is_detectable(distance_km) @@ -297,7 +281,7 @@ def run_orlan_detection_test(): 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) + success = send_detection(target_device, distance_km, step, total_steps) if not success: print(f"āŒ Failed to send detection at step {step}")