fix for back-to-back issue

This commit is contained in:
Ben Menking
2026-05-07 22:05:48 -04:00
parent fb807f42c6
commit 9f44882aa7
2 changed files with 41 additions and 18 deletions
+15 -2
View File
@@ -282,11 +282,24 @@ class Meshcore {
*/
public function sendBinaryRequest(string $request): mixed {
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);
}
public function readFrame(): mixed {
return CoreProtocol::readFrame($this->serial);
}
/**
*
* @param string $tag
@@ -305,7 +318,7 @@ class Meshcore {
usleep(500000);
}
while( (time() - $mark) < $timeout_ms );
while( ((time() - $mark) * 1000) < $timeout_ms );
return false;
}