56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
use Menking\Meshcore\Environment;
|
|
use Menking\Meshcore\Meshcore;
|
|
use Menking\Meshcore\CoreProtocol;
|
|
|
|
require(__DIR__ . '/../vendor/autoload.php');
|
|
|
|
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
|
|
|
|
Environment::configure($argv[1]);
|
|
|
|
$mc = Meshcore::getInstance();
|
|
|
|
$x = $mc->appStart("get remote tele");
|
|
|
|
$contacts = $mc->getContacts();
|
|
$idx = 1;
|
|
foreach($contacts as $contact) {
|
|
echo "(" . $idx++ . ") {$contact['contact_name']} [" . substr($contact['pub_key'], 0, 6) . "]\n";
|
|
}
|
|
|
|
$choice = readline("\nPlease select contact to attempt remote login: ");
|
|
$contact = $contacts[$choice - 1];
|
|
|
|
echo "Using {$contact['contact_name']}\n";
|
|
|
|
/*
|
|
if( !$mc->connected($contact['pub_key']) ) {
|
|
$password = readline("Password: ");
|
|
|
|
$mc->login($contact['pub_key'], $password);
|
|
}
|
|
*/
|
|
|
|
$req = base64_decode($contact['pub_key']) . chr(CoreProtocol::BINREQ_TELEMETRY);
|
|
|
|
$result = $mc->sendBinaryRequest($req);
|
|
echo "Tag: {$result['tag']}\n";
|
|
|
|
$timeout = 0;
|
|
|
|
while($timeout++ < 6) {
|
|
echo "timeout: $timeout\n";
|
|
$resp = $mc->getSyncNextMessage();
|
|
if( !empty($resp) ) {
|
|
print_r($resp);
|
|
if( $resp['code'] == 0x8c) {
|
|
exit;
|
|
}
|
|
}
|
|
sleep(1);
|
|
}
|
|
|
|
echo "Complete\n";
|