60 lines
1.3 KiB
PHP
60 lines
1.3 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");
|
|
|
|
$repeaters = ['Simpsonville 3810gvr1', 'Simpsonville im37r1'];
|
|
|
|
$contacts = $mc->getContacts();
|
|
|
|
echo "Found " . count($contacts) . " contacts\n";
|
|
|
|
/*
|
|
$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];
|
|
*/
|
|
|
|
foreach($contacts as $contact) {
|
|
if( !in_array($contact['contact_name'], $repeaters) ) continue;
|
|
|
|
echo "Using {$contact['contact_name']}\n";
|
|
|
|
$req = base64_decode($contact['pub_key']) . chr(CoreProtocol::BINREQ_TELEMETRY);
|
|
|
|
$result = $mc->sendBinaryRequest($req);
|
|
|
|
if( !isset($result->tag) ) {
|
|
var_dump($result);
|
|
echo "sendBinaryRequest sent nothing??\n";
|
|
continue;
|
|
}
|
|
|
|
echo "Tag: {$result->tag}\n";
|
|
|
|
$msgs = $mc->pollForMessage($result->tag);
|
|
|
|
foreach($msgs as $msg) {
|
|
if( $msg->tag == $result->tag) {
|
|
echo json_encode($msg->lpp) . "\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
echo "Complete\n";
|