Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ble_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ void ble_init() {

#ifdef TARGET_ESP32
volatile bool bleRestartAdvertisingPending = false;
volatile bool bleConnectMsdUpdatePending = false;
volatile bool bleDirectWriteCleanupPending = false;
volatile bool esp32BleNotifySubscribed = false;
#if defined(CONFIG_BLUEDROID_ENABLED)
static BLE2902* s_bleNotifyCccd = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions src/ble_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void esp32_restart_ble_advertising(void);
void esp32_ble_clear_handles(void);
bool esp32_ble_notify_enabled(void);
extern volatile bool bleRestartAdvertisingPending;
extern volatile bool bleConnectMsdUpdatePending;
extern volatile bool bleDirectWriteCleanupPending;
extern volatile bool esp32BleNotifySubscribed;
#endif

Expand Down
5 changes: 2 additions & 3 deletions src/esp32_ble_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MyBLEServerCallbacks : public BLEServerCallbacks {
writeSerial("=== BLE CLIENT CONNECTED (ESP32) ===");
rebootFlag = 0;
esp32BleNotifySubscribed = false;
updatemsdata();
bleConnectMsdUpdatePending = true;
}
void onDisconnect(BLEServer* pServer) {
(void)pServer;
Expand All @@ -50,8 +50,7 @@ class MyBLEServerCallbacks : public BLEServerCallbacks {
if (epdRefreshInProgress) {
writeSerial("EPD refresh in progress — deferring cleanup/advertising to main loop");
} else if (directWriteActive) {
cleanupDirectWriteState(true);
touchResumeAfterEpdRefresh();
bleDirectWriteCleanupPending = true;
}
bleRestartAdvertisingPending = true;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ void loop() {
if (bleRestartAdvertisingPending) {
esp32_restart_ble_advertising();
}
if (bleConnectMsdUpdatePending) {
bleConnectMsdUpdatePending = false;
updatemsdata();
}
if (bleDirectWriteCleanupPending) {
bleDirectWriteCleanupPending = false;
if (directWriteActive) {
cleanupDirectWriteState(true);
touchResumeAfterEpdRefresh();
}
}
if (directWriteActive && directWriteStartTime > 0) {
uint32_t directWriteDuration = millis() - directWriteStartTime;
if (directWriteDuration > 900000UL) { // 15 minute timeout (upload + refresh window)
Expand Down