mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-03 00:20:43 +00:00
New serial protobuf transport approximately works and is backward
compatiable with the text debug output.
This commit is contained in:
@@ -57,12 +57,12 @@ class PhoneAPI
|
||||
PhoneAPI();
|
||||
|
||||
/// Do late init that can't happen at constructor time
|
||||
void init();
|
||||
virtual void init();
|
||||
|
||||
/**
|
||||
* Handle a ToRadio protobuf
|
||||
*/
|
||||
void handleToRadio(const uint8_t *buf, size_t len);
|
||||
virtual void handleToRadio(const uint8_t *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Get the next packet we want to send to the phone
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -59,4 +59,8 @@ class StreamAPI : public PhoneAPI
|
||||
* call getFromRadio() and deliver encapsulated packets to the Stream
|
||||
*/
|
||||
void writeStream();
|
||||
|
||||
protected:
|
||||
/// Are we allowed to write packets to our output stream (subclasses can turn this off - i.e. SerialConsole)
|
||||
bool canWrite = true;
|
||||
};
|
||||
Reference in New Issue
Block a user