Fix jwt-token
This commit is contained in:
@@ -59,7 +59,7 @@ def show_drone_types():
|
|||||||
if drone_id in DRONE_TYPES:
|
if drone_id in DRONE_TYPES:
|
||||||
print(f" {drone_id:2d}: {DRONE_TYPES[drone_id]}")
|
print(f" {drone_id:2d}: {DRONE_TYPES[drone_id]}")
|
||||||
|
|
||||||
def send_detection(drone_type=2, drone_id=None, geo_lat=0, geo_lon=0, rssi=-45, freq=2400, show_response=True):
|
def send_detection(drone_type=2, drone_id=None, geo_lat=0, geo_lon=0, rssi=-45, freq=2400, device_id=None, show_response=True):
|
||||||
"""
|
"""
|
||||||
Send a drone detection packet
|
Send a drone detection packet
|
||||||
|
|
||||||
@@ -70,16 +70,27 @@ def send_detection(drone_type=2, drone_id=None, geo_lat=0, geo_lon=0, rssi=-45,
|
|||||||
geo_lon: Longitude coordinate
|
geo_lon: Longitude coordinate
|
||||||
rssi: Signal strength
|
rssi: Signal strength
|
||||||
freq: Frequency
|
freq: Frequency
|
||||||
|
device_id: Device ID to use (uses global DEVICE_ID if None)
|
||||||
show_response: Whether to print the response
|
show_response: Whether to print the response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Use provided device_id or fall back to global DEVICE_ID
|
||||||
|
if device_id is None:
|
||||||
|
device_id = DEVICE_ID
|
||||||
|
else:
|
||||||
|
# Convert to int if it's a numeric string
|
||||||
|
try:
|
||||||
|
device_id = int(device_id) if device_id.isdigit() else device_id
|
||||||
|
except (AttributeError, ValueError):
|
||||||
|
pass # Keep as-is if conversion fails
|
||||||
|
|
||||||
# Generate drone_id if not specified
|
# Generate drone_id if not specified
|
||||||
if drone_id is None:
|
if drone_id is None:
|
||||||
drone_id = int(time.time()) % 100000 # Use timestamp for uniqueness
|
drone_id = int(time.time()) % 100000 # Use timestamp for uniqueness
|
||||||
|
|
||||||
# Create detection packet matching your original format
|
# Create detection packet matching your original format
|
||||||
packet = {
|
packet = {
|
||||||
"device_id": DEVICE_ID,
|
"device_id": device_id,
|
||||||
"geo_lat": float(geo_lat),
|
"geo_lat": float(geo_lat),
|
||||||
"geo_lon": float(geo_lon),
|
"geo_lon": float(geo_lon),
|
||||||
"device_timestamp": int(time.time()),
|
"device_timestamp": int(time.time()),
|
||||||
@@ -95,7 +106,7 @@ def send_detection(drone_type=2, drone_id=None, geo_lat=0, geo_lon=0, rssi=-45,
|
|||||||
print(f"📡 Sending detection:")
|
print(f"📡 Sending detection:")
|
||||||
print(f" Drone Type: {drone_type} ({drone_name})")
|
print(f" Drone Type: {drone_type} ({drone_name})")
|
||||||
print(f" Drone ID: {drone_id}")
|
print(f" Drone ID: {drone_id}")
|
||||||
print(f" Device ID: {DEVICE_ID}")
|
print(f" Device ID: {device_id}")
|
||||||
print(f" Location: ({geo_lat}, {geo_lon})")
|
print(f" Location: ({geo_lat}, {geo_lon})")
|
||||||
print(f" RSSI: {rssi}, Freq: {freq}")
|
print(f" RSSI: {rssi}, Freq: {freq}")
|
||||||
|
|
||||||
@@ -197,6 +208,8 @@ def main():
|
|||||||
help='Drone type (0-18), default: 2 (Orlan)')
|
help='Drone type (0-18), default: 2 (Orlan)')
|
||||||
parser.add_argument('--drone-id', '-d', type=int, default=None,
|
parser.add_argument('--drone-id', '-d', type=int, default=None,
|
||||||
help='Specific drone ID to simulate (auto-generated if not specified)')
|
help='Specific drone ID to simulate (auto-generated if not specified)')
|
||||||
|
parser.add_argument('--device-id', type=str, default='1941875381',
|
||||||
|
help='Device ID to use for detection (default: 1941875381)')
|
||||||
parser.add_argument('--simulate', '-s', action='store_true',
|
parser.add_argument('--simulate', '-s', action='store_true',
|
||||||
help='Run approach simulation instead of single detection')
|
help='Run approach simulation instead of single detection')
|
||||||
parser.add_argument('--steps', type=int, default=10,
|
parser.add_argument('--steps', type=int, default=10,
|
||||||
@@ -218,7 +231,7 @@ def main():
|
|||||||
print("🎯 ENHANCED DRONE DETECTION TEST")
|
print("🎯 ENHANCED DRONE DETECTION TEST")
|
||||||
print("="*70)
|
print("="*70)
|
||||||
print(f"API URL: {API_BASE_URL}")
|
print(f"API URL: {API_BASE_URL}")
|
||||||
print(f"Device ID: {DEVICE_ID}")
|
print(f"Device ID: {args.device_id}")
|
||||||
print("="*70)
|
print("="*70)
|
||||||
|
|
||||||
if args.list_types:
|
if args.list_types:
|
||||||
@@ -235,6 +248,7 @@ def main():
|
|||||||
simulate_drone_approach(
|
simulate_drone_approach(
|
||||||
drone_type=args.drone_type,
|
drone_type=args.drone_type,
|
||||||
drone_id=args.drone_id,
|
drone_id=args.drone_id,
|
||||||
|
device_id=args.device_id,
|
||||||
steps=args.steps
|
steps=args.steps
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -246,7 +260,8 @@ def main():
|
|||||||
geo_lat=args.lat,
|
geo_lat=args.lat,
|
||||||
geo_lon=args.lon,
|
geo_lon=args.lon,
|
||||||
rssi=args.rssi,
|
rssi=args.rssi,
|
||||||
freq=args.freq
|
freq=args.freq,
|
||||||
|
device_id=args.device_id
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user