Fix jwt-token
This commit is contained in:
@@ -218,22 +218,9 @@ class SwedishDroneSimulator:
|
||||
def send_heartbeat(self, device: DroneDevice) -> bool:
|
||||
"""Send device heartbeat to the API"""
|
||||
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 = {
|
||||
"type": "heartbeat",
|
||||
"key": str(device.device_id), # Use device ID directly 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
|
||||
"key": str(device.device_id) # Just the device ID as key
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
@@ -245,8 +232,8 @@ class SwedishDroneSimulator:
|
||||
|
||||
if response.status_code == 200:
|
||||
device.last_heartbeat = time.time()
|
||||
status_icon = "🟢" if device.battery_level > 30 else "🟡" if device.battery_level > 15 else "🔴"
|
||||
print(f"{status_icon} Heartbeat: {device.name} ({device.location}) - Battery: {device.battery_level}%")
|
||||
status_icon = "🟢"
|
||||
print(f"{status_icon} Heartbeat: {device.name} ({device.location})")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to send heartbeat for device {device.device_id}: {response.status_code}")
|
||||
|
||||
@@ -38,7 +38,7 @@ const limiter = rateLimit({
|
||||
message: 'Too many requests from this IP, please try again later.',
|
||||
skip: (req) => {
|
||||
// Skip rate limiting for drone detection endpoints during testing
|
||||
return req.path.includes('/detections');
|
||||
return req.path.includes('/detections') || req.path.includes('/detectors');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user