initial clean commit

This commit is contained in:
Ben Menking
2026-05-07 09:48:36 -04:00
commit d59f61d764
29 changed files with 1333 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$resp = $mc->appStart("battery storage");
$resp = $mc->getBatteryAndStorage();
echo "Battery voltage: " . $resp->battery_millivolt . " mV\n";
echo "Storage used: " . $resp->storage_used . " kB\n";
echo "Storage total: " . $resp->storage_total . " kB\n";
+18
View File
@@ -0,0 +1,18 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$mc->appStart("app_get_contacts");
$resp = $mc->getContacts();
print_r($resp);
+19
View File
@@ -0,0 +1,19 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$mc->appStart("app_get_contacts");
$resp = $mc->getDeviceInfo();
print_r($resp);
+18
View File
@@ -0,0 +1,18 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$mc->appStart("getdevicetime");
$ts = $mc->getDeviceTime();
echo "Current device time: " . date('r', $ts['current_time']) . "\n";
+20
View File
@@ -0,0 +1,20 @@
<?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();
$mc->appStart("get_messages");
$resp = $mc->getNextMessage();
print_r($resp);
exit;
+44
View File
@@ -0,0 +1,44 @@
<?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);
+33
View File
@@ -0,0 +1,33 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$mc->appStart("getstatusreq");
$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";
print_r($mc->login($contact['pub_key'], ''));
$ts = $mc->statusRequest($contact['pub_key']);
print_r($ts);
$mc->poll();
+55
View File
@@ -0,0 +1,55 @@
<?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";
+15
View File
@@ -0,0 +1,15 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$mc->appStart("reboot");
$mc->reboot();
+17
View File
@@ -0,0 +1,17 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
use Menking\Meshcore\Util\Debug;
require(__DIR__ . '/../vendor/autoload.php');
Environment::configure('/dev/ttyUSB0');
$mc = Meshcore::getInstance();
$mc->appStart("send message");
$resp = $mc->sendChannelTxtMessage("Ping", 0); // default channel Public on 0
echo Debug::hexDump($resp);
exit;
+21
View File
@@ -0,0 +1,21 @@
<?php
use Menking\Meshcore\Environment;
use Menking\Meshcore\Meshcore;
require(__DIR__ . '/../vendor/autoload.php');
if( !isset($argv[1]) ) die("{$argv[0]} <port>\n");
Environment::configure($argv[1]);
$mc = Meshcore::getInstance();
$mc->appStart("set device");
echo "Setting device time\n";
$result = $mc->setDeviceTime();
print_r($result);
$mc->poll();