add consolePrintf for C style code

This commit is contained in:
Kevin Hester 2021-03-10 15:21:30 +08:00
parent 772f2a15ff
commit 58715f454c
2 changed files with 13 additions and 2 deletions

View File

@ -1,13 +1,21 @@
#include "SerialConsole.h"
#include "NodeDB.h"
#include "PowerFSM.h"
#include "configuration.h"
#include "NodeDB.h"
#include <Arduino.h>
#define Port Serial
SerialConsole console;
void consolePrintf(const char *format, ...)
{
va_list arg;
va_start(arg, format);
console.vprintf(format, arg);
va_end(arg);
}
SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
{
canWrite = false; // We don't send packets to our port until it has talked to us first

View File

@ -32,4 +32,7 @@ class SerialConsole : public StreamAPI, public RedirectablePrint
virtual void onConnectionChanged(bool connected);
};
// A simple wrapper to allow non class aware code write to the console
void consolePrintf(const char *format, ...);
extern SerialConsole console;