From fe09667f3cd304e3f920df42b4101ce9d7da2d24 Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Tue, 7 Jan 2025 15:49:58 +0100 Subject: [PATCH] fix: unstow --- cli/starlink.php | 15 +++++++++++---- src/Dishy.php | 13 +++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cli/starlink.php b/cli/starlink.php index 5cfbfc7..12d831c 100644 --- a/cli/starlink.php +++ b/cli/starlink.php @@ -15,11 +15,18 @@ } $dishy = new Dishy; -$history = $dishy->getStatsHistory(); -foreach ($history as $key => $value) { - echo $key.': '.(is_array($value) ? count($value) : $value).PHP_EOL; -} +$dishy->stow(); + +sleep(10); + +$dishy->unstow(); + +// $history = $dishy->getStatsHistory(); + +// foreach ($history as $key => $value) { +// echo $key.': '.(is_array($value) ? count($value) : $value).PHP_EOL; +// } // dump($history['outages']); diff --git a/src/Dishy.php b/src/Dishy.php index 202dbb1..9e16795 100644 --- a/src/Dishy.php +++ b/src/Dishy.php @@ -70,7 +70,7 @@ public function handle(Message $request, ?int $timeout = null): Response /** @var object{code: int, details: string, metadata:array} $status */ [$response, $status] = $this->client->Handle( argument: new Request([ - self::getRequestKey($request) => new $request, + self::getRequestKey($request) => $request, ]), options: $options )->wait(); @@ -172,6 +172,7 @@ public function getStatsHistory(): array return $array; } + // Can take a few seconds public function unstow(): void { $this->stow(false); @@ -179,9 +180,13 @@ public function unstow(): void public function stow(bool $stow = true): void { - $this->handle(new DishStowRequest( - array_filter(['unstow' => ! $stow]) - )); + $request = new DishStowRequest; + + if ($stow === false) { + $request->setUnstow(true); + } + + $this->handle($request, timeout: 5); } public function reboot(): void