PHP code example of srwiez / starlink-client

1. Go to this page and download the library: Download srwiez/starlink-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

srwiez / starlink-client example snippets

 
use SRWieZ\StarlinkClient\Dishy;

$dishy = new Dishy('192.168.100.1:9200');
$infos = $dishy->getStatus();

$sleepConfig = $dishy->getSleepModeConfig();

$statistics = $dishy->getStatsHistory();

$location = $dishy->getLocation();

use SRWieZ\StarlinkClient\Dishy;

$dishy = new Dishy('192.168.100.1:9200');

// Get the obstruction map
$data = $dishy->getObstructionMap();

// Colored image
(new ObstructionMapGenerator($data))
    ->transparent()
    ->generate()
    ->asFile('assets/obstruction_map.png');

(new ObstructionMapGenerator($data))
    ->transparent(false)
    ->grayscale()
    ->opacity(0.95)
    ->generate()
    ->asFile('assets/obstruction_map_grayscale.png');

use SRWieZ\StarlinkClient\Dishy;

$dishy = new Dishy('192.168.100.1:9200');

// Reboot the dish
$dishy->reboot();

// Stow the dish
$dishy->stow();

// Unstow the dish
$dishy->unstow();

// Reset obstruction map
$dishy->resetObstructionMap();

// Enable power save mode
$dishy->setSleepModeConfig(
    start: 60, // 01:00
    duration: 120, // 03:00
);

// Disable power save mode
$dishy->disableSleepMode();

use SpaceX\API\Device\DeviceClient;
use Grpc\ChannelCredentials;
use SpaceX\API\Device\GetStatusRequest;

$client = new DeviceClient('192.168.100.1:9200', [
    'credentials' => ChannelCredentials::createInsecure(),
]);

[$response, $status] = $client->Handle(
    new Request(['get_status' => new GetStatusRequest()])
)->wait();