New serial protobuf transport approximately works and is backward

compatiable with the text debug output.
This commit is contained in:
geeksville
2020-04-27 09:36:39 -07:00
parent e5d2d24e2c
commit cceecf5f8e
7 changed files with 84 additions and 17 deletions

View File

@@ -52,18 +52,19 @@ void StreamAPI::readStream()
*/
void StreamAPI::writeStream()
{
uint32_t len;
if (canWrite) {
uint32_t len;
do {
// Send every packet we can
len = getFromRadio(txBuf + HEADER_LEN);
if (len != 0) {
txBuf[0] = START1;
txBuf[1] = START2;
txBuf[2] = (len >> 8) & 0xff;
txBuf[3] = len & 0xff;
do {
// Send every packet we can
len = getFromRadio(txBuf + HEADER_LEN);
if (len != 0) {
txBuf[0] = START1;
txBuf[1] = START2;
txBuf[2] = (len >> 8) & 0xff;
txBuf[3] = len & 0xff;
stream->write(txBuf, len + HEADER_LEN);
}
} while (len);
stream->write(txBuf, len + HEADER_LEN);
}
} while (len);
}
}