feat: publish NIRO Gen5W research overview and reviewed source examples

This commit is contained in:
seo committed 2026-11-02 09:59:38 +09:00
commit ccad0ed9f3
23 files changed
+1279

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../backend/php/NiroMqttKeepalive.php';
function assertMqttKeepalive(bool $condition, string $message): void
{
if (!$condition) {
fwrite(STDERR, "NiroMqttKeepaliveTest failed: {$message}\n");
exit(1);
}
}
$keepalive = new NiroMqttKeepalive(100, 15);
for ($now = 101; $now < 115; $now++) {
assertMqttKeepalive(!$keepalive->isDue($now), 'PINGREQ became due too early');
}
assertMqttKeepalive($keepalive->isDue(115),
'continuous inbound packets postponed the client PINGREQ');
$keepalive->markSent(115);
assertMqttKeepalive(!$keepalive->isDue(129), 'PINGREQ repeated before its interval');
assertMqttKeepalive($keepalive->isDue(130), 'next PINGREQ was not scheduled');
$invalidIntervalRejected = false;
try {
new NiroMqttKeepalive(100, 0);
} catch (InvalidArgumentException) {
$invalidIntervalRejected = true;
}
assertMqttKeepalive($invalidIntervalRejected, 'invalid keepalive interval was accepted');
echo "NiroMqttKeepaliveTest passed\n";