fix for back-to-back issue
This commit is contained in:
+15
-2
@@ -282,11 +282,24 @@ class Meshcore {
|
|||||||
*/
|
*/
|
||||||
public function sendBinaryRequest(string $request): mixed {
|
public function sendBinaryRequest(string $request): mixed {
|
||||||
CoreProtocol::writeFrame($this->serial, chr(CoreProtocol::CMD_SEND_BINARY_REQ) . $request);
|
CoreProtocol::writeFrame($this->serial, chr(CoreProtocol::CMD_SEND_BINARY_REQ) . $request);
|
||||||
$response = CoreProtocol::readFrame($this->serial);
|
|
||||||
|
do {
|
||||||
|
$response = CoreProtocol::readFrame($this->serial);
|
||||||
|
|
||||||
|
}
|
||||||
|
while(
|
||||||
|
ord($response) != CoreProtocol::RESP_CODE_SENT &&
|
||||||
|
ord($response) != CoreProtocol::ERR_CODE_NOT_FOUND &&
|
||||||
|
ord($response) != CoreProtocol::ERR_CODE_NOT_FOUND
|
||||||
|
);
|
||||||
|
|
||||||
return CoreParser::parseResponse($response);
|
return CoreParser::parseResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function readFrame(): mixed {
|
||||||
|
return CoreProtocol::readFrame($this->serial);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
@@ -305,7 +318,7 @@ class Meshcore {
|
|||||||
|
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
while( (time() - $mark) < $timeout_ms );
|
while( ((time() - $mark) * 1000) < $timeout_ms );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-16
@@ -14,7 +14,12 @@ $mc = Meshcore::getInstance();
|
|||||||
|
|
||||||
$x = $mc->appStart("get remote tele");
|
$x = $mc->appStart("get remote tele");
|
||||||
|
|
||||||
|
$repeaters = ['Simpsonville 3810gvr1', 'Simpsonville im37r1'];
|
||||||
|
|
||||||
$contacts = $mc->getContacts();
|
$contacts = $mc->getContacts();
|
||||||
|
|
||||||
|
echo "Found " . count($contacts) . " contacts\n";
|
||||||
|
/*
|
||||||
$idx = 1;
|
$idx = 1;
|
||||||
foreach($contacts as $contact) {
|
foreach($contacts as $contact) {
|
||||||
echo "(" . $idx++ . ") {$contact['contact_name']} [" . substr($contact['pub_key'], 0, 6) . "]\n";
|
echo "(" . $idx++ . ") {$contact['contact_name']} [" . substr($contact['pub_key'], 0, 6) . "]\n";
|
||||||
@@ -22,25 +27,30 @@ foreach($contacts as $contact) {
|
|||||||
|
|
||||||
$choice = readline("\nPlease select contact to attempt remote login: ");
|
$choice = readline("\nPlease select contact to attempt remote login: ");
|
||||||
$contact = $contacts[$choice - 1];
|
$contact = $contacts[$choice - 1];
|
||||||
|
*/
|
||||||
|
|
||||||
echo "Using {$contact['contact_name']}\n";
|
foreach($contacts as $contact) {
|
||||||
|
if( !in_array($contact['contact_name'], $repeaters) ) continue;
|
||||||
|
|
||||||
/*
|
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);
|
||||||
|
|
||||||
|
if( !isset($result->tag) ) {
|
||||||
|
var_dump($result);
|
||||||
|
echo "sendBinaryRequest sent nothing??\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Tag: {$result->tag}\n";
|
||||||
|
|
||||||
|
$msg = $mc->pollForMessage($result->tag);
|
||||||
|
|
||||||
|
echo json_encode($msg->lpp) . "\n";
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
$req = base64_decode($contact['pub_key']) . chr(CoreProtocol::BINREQ_TELEMETRY);
|
|
||||||
|
|
||||||
$result = $mc->sendBinaryRequest($req);
|
|
||||||
|
|
||||||
echo "Tag: {$result->tag}\n";
|
|
||||||
|
|
||||||
$msg = $mc->pollForMessage($result->tag);
|
|
||||||
|
|
||||||
print_r($msg);
|
|
||||||
|
|
||||||
echo "Complete\n";
|
echo "Complete\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user