Add background WiFi observation timer
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
define('CONTROL_API_LIBRARY', true);
|
||||
|
||||
require_once __DIR__ . '/../public/api.php';
|
||||
|
||||
$data = wifi_data();
|
||||
$clients = is_array($data['clients'] ?? null) ? $data['clients'] : [];
|
||||
$missing5g = 0;
|
||||
$missing24 = 0;
|
||||
|
||||
foreach ($clients as $client) {
|
||||
$band = (string)($client['band'] ?? '');
|
||||
if (!wifi_connected_time_missing($client['connected_time'] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($band === '5G') {
|
||||
$missing5g++;
|
||||
} elseif ($band === '2.4G') {
|
||||
$missing24++;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'ok' => true,
|
||||
'generated_at' => date('Y-m-d H:i:s'),
|
||||
'count24' => (int)($data['count24'] ?? 0),
|
||||
'count5' => (int)($data['count5'] ?? 0),
|
||||
'missing_connected_time_24g' => $missing24,
|
||||
'missing_connected_time_5g' => $missing5g,
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
|
||||
Reference in New Issue
Block a user