Ejemplo n.º 1
0
    if (!setTimer($mac, $h, $m, $s, $action, $s20Table)) {
        echo "Set timer succeed\n";
    } else {
        echo "Some problem on set timer\n";
    }
    //
    //Let us check
    //
    while (1) {
        $timer = checkTimer($mac, $s20Table, $h, $m, $s, $action);
        $st = checkStatus($mac, $s20Table);
        if (!$timer) {
            echo "Timer is off, status = " . actionToTxt($st) . "\n";
            break;
        } else {
            echo sprintf("%02d:%02d:%02d to => %s, current is %s\n", $h, $m, $s, actionToTxt($action), actionToTxt($st));
        }
        ob_flush();
        sleep(2);
    }
}
//
// Test automatic switch off after on first device.
//
echo "\n\n\nTesting automatic switch off after on using switch " . $name . "\n";
$initValue = getSwitchOffTimer($mac, $s20Table);
$setOff = 1800;
$res = setSwitchOffTimer($mac, $setOff, $s20Table);
if ($res == $setOff) {
    echo "\nSetting automatic switch off timer to " . $setOff . "s OK\n";
} else {
Ejemplo n.º 2
0
    if ($st) {
        $action = 0;
    } else {
        $action = 1;
    }
    $h = 0;
    $m = 0;
    $s = 10;
    echo "setting timer: " . $name . ' -> ' . actionToTxt($action) . " Time=" . sprintf("%02d:%02d:%02d\n", $h, $m, $s);
    if (!setTimer($mac, $h, $m, $s, $action, $s20Table)) {
        echo "Set timer succeed\n";
    } else {
        echo "Some problem on set timer\n";
    }
    //
    //Let us check
    //
    while (1) {
        $timer = checkTimer($mac, $s20Table, $h, $m, $s, $action);
        $st = checkStatus($mac, $s20Table);
        if (!$timer) {
            echo "Timer is off, status = " . actionToTxt($st) . "\n";
            break;
        } else {
            echo sprintf("Current=%02d:%02d:%02d To => %s, curr = %s\n", $h, $m, $s, actionToTxt($action), actionToTxt($st));
        }
        ob_flush();
        sleep(2);
    }
}
echo "Test finished, everything seems OK\n";