mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 10:12:50 +00:00
Chainsaw took too much off the top
This commit is contained in:
@@ -15,6 +15,7 @@ int32_t StreamAPI::runOncePart()
|
|||||||
checkConnectionTimeout();
|
checkConnectionTimeout();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t StreamAPI::runOncePart(char *buf, uint16_t bufLen)
|
int32_t StreamAPI::runOncePart(char *buf, uint16_t bufLen)
|
||||||
{
|
{
|
||||||
auto result = readStream(buf, bufLen);
|
auto result = readStream(buf, bufLen);
|
||||||
@@ -23,6 +24,38 @@ int32_t StreamAPI::runOncePart(char *buf, uint16_t bufLen)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read any rx chars from the link and call handleRecStream
|
||||||
|
*/
|
||||||
|
int32_t StreamAPI::readStream(char *buf, uint16_t bufLen)
|
||||||
|
{
|
||||||
|
if (bufLen < 1) {
|
||||||
|
// Nothing available this time, if the computer has talked to us recently, poll often, otherwise let CPU sleep a long time
|
||||||
|
bool recentRx = Throttle::isWithinTimespanMs(lastRxMsec, 2000);
|
||||||
|
return recentRx ? 5 : 250;
|
||||||
|
} else {
|
||||||
|
handleRecStream(buf, bufLen);
|
||||||
|
// we had bytes available this time, so assume we might have them next time also
|
||||||
|
lastRxMsec = millis();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* call getFromRadio() and deliver encapsulated packets to the Stream
|
||||||
|
*/
|
||||||
|
void StreamAPI::writeStream()
|
||||||
|
{
|
||||||
|
if (canWrite) {
|
||||||
|
uint32_t len;
|
||||||
|
do {
|
||||||
|
// Send every packet we can
|
||||||
|
len = getFromRadio(txBuf + HEADER_LEN);
|
||||||
|
emitTxBuffer(len);
|
||||||
|
} while (len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t StreamAPI::handleRecStream(char *buf, uint16_t bufLen)
|
int32_t StreamAPI::handleRecStream(char *buf, uint16_t bufLen)
|
||||||
{
|
{
|
||||||
uint16_t index = 0;
|
uint16_t index = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user