Pause BLE logging during want_config flow (#4162)

This commit is contained in:
Ben Meadors 2024-06-22 07:00:48 -05:00 committed by GitHub
parent f8db38cf99
commit d32cdecc06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 3 deletions

View File

@ -169,7 +169,7 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)
isContinuationMessage = !hasNewline; isContinuationMessage = !hasNewline;
if (config.bluetooth.device_logging_enabled) { if (config.bluetooth.device_logging_enabled && !pauseBluetoothLogging) {
bool isBleConnected = false; bool isBleConnected = false;
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
isBleConnected = nimbleBluetooth && nimbleBluetooth->isActive() && nimbleBluetooth->isConnected(); isBleConnected = nimbleBluetooth && nimbleBluetooth->isActive() && nimbleBluetooth->isConnected();

View File

@ -154,6 +154,7 @@ bool isVibrating = false;
bool eink_found = true; bool eink_found = true;
uint32_t serialSinceMsec; uint32_t serialSinceMsec;
bool pauseBluetoothLogging = false;
bool pmu_found; bool pmu_found;

View File

@ -85,6 +85,8 @@ extern uint32_t serialSinceMsec;
// This will suppress the current delay and instead try to run ASAP. // This will suppress the current delay and instead try to run ASAP.
extern bool runASAP; extern bool runASAP;
extern bool pauseBluetoothLogging;
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds(), enterDfuMode(); void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds(), enterDfuMode();
meshtastic_DeviceMetadata getDeviceMetadata(); meshtastic_DeviceMetadata getDeviceMetadata();

View File

@ -46,6 +46,7 @@ void PhoneAPI::handleStartConfig()
// even if we were already connected - restart our state machine // even if we were already connected - restart our state machine
state = STATE_SEND_MY_INFO; state = STATE_SEND_MY_INFO;
pauseBluetoothLogging = true;
LOG_INFO("Starting API client config\n"); LOG_INFO("Starting API client config\n");
nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos
@ -352,9 +353,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
fromRadioScratch.config_complete_id = config_nonce; fromRadioScratch.config_complete_id = config_nonce;
config_nonce = 0; config_nonce = 0;
state = STATE_SEND_PACKETS; state = STATE_SEND_PACKETS;
pauseBluetoothLogging = false;
break; break;
case STATE_SEND_PACKETS: case STATE_SEND_PACKETS:
pauseBluetoothLogging = false;
// Do we have a message from the mesh or packet from the local device? // Do we have a message from the mesh or packet from the local device?
LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n"); LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n");
if (queueStatusPacketForPhone) { if (queueStatusPacketForPhone) {
@ -398,6 +401,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
void PhoneAPI::handleDisconnect() void PhoneAPI::handleDisconnect()
{ {
pauseBluetoothLogging = false;
LOG_INFO("PhoneAPI disconnect\n"); LOG_INFO("PhoneAPI disconnect\n");
} }

View File

@ -98,8 +98,6 @@ class PhoneAPI
bool isConnected() { return state != STATE_SEND_NOTHING; } bool isConnected() { return state != STATE_SEND_NOTHING; }
void setInitialState() { state = STATE_SEND_MY_INFO; }
protected: protected:
/// Our fromradio packet while it is being assembled /// Our fromradio packet while it is being assembled
meshtastic_FromRadio fromRadioScratch = {}; meshtastic_FromRadio fromRadioScratch = {};