Fix jwt-token

This commit is contained in:
2025-09-07 15:14:28 +02:00
parent 3c4d338fdf
commit 9d75abc88f
2 changed files with 4 additions and 17 deletions

View File

@@ -218,22 +218,9 @@ class SwedishDroneSimulator:
def send_heartbeat(self, device: DroneDevice) -> bool: def send_heartbeat(self, device: DroneDevice) -> bool:
"""Send device heartbeat to the API""" """Send device heartbeat to the API"""
try: try:
# Simulate device status changes
if random.random() < 0.05: # 5% chance of status change
device.battery_level = max(10, device.battery_level - random.randint(1, 5))
device.signal_strength = random.randint(-65, -25)
device.temperature = random.uniform(10, 35)
payload = { payload = {
"type": "heartbeat", "type": "heartbeat",
"key": str(device.device_id), # Use device ID directly as key "key": str(device.device_id) # Just the device ID as key
"device_id": device.device_id, # Also include explicit device_id
"geo_lat": device.lat, # Include device coordinates
"geo_lon": device.lon,
"location_description": device.location, # Include location name
"battery_level": device.battery_level,
"signal_strength": device.signal_strength,
"temperature": device.temperature
} }
response = requests.post( response = requests.post(
@@ -245,8 +232,8 @@ class SwedishDroneSimulator:
if response.status_code == 200: if response.status_code == 200:
device.last_heartbeat = time.time() device.last_heartbeat = time.time()
status_icon = "🟢" if device.battery_level > 30 else "🟡" if device.battery_level > 15 else "🔴" status_icon = "🟢"
print(f"{status_icon} Heartbeat: {device.name} ({device.location}) - Battery: {device.battery_level}%") print(f"{status_icon} Heartbeat: {device.name} ({device.location})")
return True return True
else: else:
print(f"❌ Failed to send heartbeat for device {device.device_id}: {response.status_code}") print(f"❌ Failed to send heartbeat for device {device.device_id}: {response.status_code}")

View File

@@ -38,7 +38,7 @@ const limiter = rateLimit({
message: 'Too many requests from this IP, please try again later.', message: 'Too many requests from this IP, please try again later.',
skip: (req) => { skip: (req) => {
// Skip rate limiting for drone detection endpoints during testing // Skip rate limiting for drone detection endpoints during testing
return req.path.includes('/detections'); return req.path.includes('/detections') || req.path.includes('/detectors');
} }
}); });