Skip to content

Commit

Permalink
Pause BLE logging during want_config flow (#4162)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored Jun 22, 2024
1 parent f8db38c commit d32cdec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/RedirectablePrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)

isContinuationMessage = !hasNewline;

if (config.bluetooth.device_logging_enabled) {
if (config.bluetooth.device_logging_enabled && !pauseBluetoothLogging) {
bool isBleConnected = false;
#ifdef ARCH_ESP32
isBleConnected = nimbleBluetooth && nimbleBluetooth->isActive() && nimbleBluetooth->isConnected();
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ bool isVibrating = false;
bool eink_found = true;

uint32_t serialSinceMsec;
bool pauseBluetoothLogging = false;

bool pmu_found;

Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ extern uint32_t serialSinceMsec;
// This will suppress the current delay and instead try to run ASAP.
extern bool runASAP;

extern bool pauseBluetoothLogging;

void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), rp2040Setup(), clearBonds(), enterDfuMode();

meshtastic_DeviceMetadata getDeviceMetadata();
Expand Down
4 changes: 4 additions & 0 deletions src/mesh/PhoneAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void PhoneAPI::handleStartConfig()

// even if we were already connected - restart our state machine
state = STATE_SEND_MY_INFO;
pauseBluetoothLogging = true;

LOG_INFO("Starting API client config\n");
nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos
Expand Down Expand Up @@ -352,9 +353,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
fromRadioScratch.config_complete_id = config_nonce;
config_nonce = 0;
state = STATE_SEND_PACKETS;
pauseBluetoothLogging = false;
break;

case STATE_SEND_PACKETS:
pauseBluetoothLogging = false;
// Do we have a message from the mesh or packet from the local device?
LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n");
if (queueStatusPacketForPhone) {
Expand Down Expand Up @@ -398,6 +401,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)

void PhoneAPI::handleDisconnect()
{
pauseBluetoothLogging = false;
LOG_INFO("PhoneAPI disconnect\n");
}

Expand Down
2 changes: 0 additions & 2 deletions src/mesh/PhoneAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ class PhoneAPI

bool isConnected() { return state != STATE_SEND_NOTHING; }

void setInitialState() { state = STATE_SEND_MY_INFO; }

protected:
/// Our fromradio packet while it is being assembled
meshtastic_FromRadio fromRadioScratch = {};
Expand Down

0 comments on commit d32cdec

Please sign in to comment.