2020-04-27 16:36:39 +00:00
|
|
|
#include "SerialConsole.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
#define Port Serial
|
|
|
|
|
|
|
|
SerialConsole console;
|
|
|
|
|
|
|
|
SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
|
|
|
{
|
|
|
|
canWrite = false; // We don't send packets to our port until it has talked to us first
|
2020-04-28 01:52:57 +00:00
|
|
|
// setDestination(&noopPrint); for testing, try turning off 'all' debug output and see what leaks
|
2020-04-27 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Do late init that can't happen at constructor time
|
|
|
|
void SerialConsole::init()
|
|
|
|
{
|
|
|
|
Port.begin(SERIAL_BAUD);
|
|
|
|
StreamAPI::init();
|
2020-04-29 00:43:16 +00:00
|
|
|
emitRebooted();
|
2020-04-27 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* we override this to notice when we've received a protobuf over the serial stream. Then we shunt off
|
|
|
|
* debug serial output.
|
|
|
|
*/
|
|
|
|
void SerialConsole::handleToRadio(const uint8_t *buf, size_t len)
|
|
|
|
{
|
2020-04-28 01:52:57 +00:00
|
|
|
// Note: for the time being we could _allow_ debug printing to keep going out the console
|
2020-04-27 16:46:06 +00:00
|
|
|
// I _think_ this is okay because we currently only print debug msgs from loop() and we are only
|
|
|
|
// dispatching serial protobuf msgs from loop() as well. When things are more threaded in the future this
|
|
|
|
// will need to change.
|
|
|
|
// setDestination(&noopPrint);
|
2020-04-27 16:36:39 +00:00
|
|
|
canWrite = true;
|
|
|
|
|
|
|
|
StreamAPI::handleToRadio(buf, len);
|
|
|
|
}
|