#!/bin/bash # Simple bash script to test drone detection API with curl API_BASE="http://selfservice.cqers.com/drones/api" # Alternative for local testing: "http://localhost:3002/api" echo "🚁 Drone Detection API Test Script" echo "==================================" # Test API health echo "🔍 Testing API health..." curl -s "$API_BASE/health" | jq '.' || echo "Health check failed" echo "" # Send test detection data echo "📡 Sending test drone detection..." # Generate timestamp TIMESTAMP=$(date +%s)000 # Test detection payload DETECTION_DATA='{ "device_id": 1, "drone_id": 1001, "drone_type": 1, "rssi": -65, "freq": 2400, "geo_lat": 59.3293, "geo_lon": 18.0686, "device_timestamp": '$TIMESTAMP', "confidence_level": 0.85, "signal_duration": 2500 }' echo "Payload:" echo "$DETECTION_DATA" | jq '.' echo "" # Send the detection echo "Sending detection..." RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" \ -X POST "$API_BASE/detections" \ -H "Content-Type: application/json" \ -d "$DETECTION_DATA") # Parse response HTTP_BODY=$(echo "$RESPONSE" | sed '$d') HTTP_STATUS=$(echo "$RESPONSE" | tail -n1 | sed 's/HTTP_STATUS://') echo "Response Status: $HTTP_STATUS" echo "Response Body:" echo "$HTTP_BODY" | jq '.' 2>/dev/null || echo "$HTTP_BODY" if [ "$HTTP_STATUS" = "201" ]; then echo "✅ Detection sent successfully!" else echo "❌ Detection failed with status $HTTP_STATUS" fi