Files
2026-05-07 09:48:36 -04:00

45 lines
1.1 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']}\n";
}
$choice = readline("\nPlease select contact to attempt remote login: ");
$contact = $contacts[$choice - 1];
echo "Using {$contact['contact_name']}\n";
$password = readline("Please enter contact's password: ");
$resp = $mc->login($contact['pub_key'], $password);
if( !$resp['status'] ) die("Login failed\n");
$payload =
chr(0x00)
. chr(0xff) // count
. pack('v', 0x0000) // offset
. chr(0x00)
. chr(0x04)
. pack('V', time());
echo "Payload: \n" . \Menking\Meshcore\Util\Debug::hexDump($payload) . "\n";
CoreProtocol::writeFrame($this->serial, $payload);
$response = CoreProtocol::readFrame($this->serial);