Refactor BLE

This commit is contained in:
Theo Arends 2021-01-18 11:51:24 +01:00
parent 1c6b0d8a4d
commit d99ba6992c
4 changed files with 256 additions and 267 deletions

View File

@ -690,12 +690,6 @@ void CmndSleep(void)
}
#ifdef USE_BLE_ESP32
// declare the fn
int ExtStopBLE();
#endif
void CmndUpgrade(void)
{
// Check if the payload is numerically 1, and had no trailing chars.
@ -706,11 +700,6 @@ void CmndUpgrade(void)
TasmotaGlobal.ota_state_flag = 3;
char stemp1[TOPSZ];
Response_P(PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"), XdrvMailbox.command, TasmotaGlobal.version, GetOtaUrl(stemp1, sizeof(stemp1)));
#ifdef USE_BLE_ESP32
ExtStopBLE();
#endif
} else {
Response_P(PSTR("{\"%s\":\"" D_JSON_ONE_OR_GT "\"}"), XdrvMailbox.command, TasmotaGlobal.version);
}

View File

@ -941,6 +941,11 @@ void Every100mSeconds(void)
* Every 0.25 second
\*-------------------------------------------------------------------------------------------*/
#ifdef USE_BLE_ESP32
// declare the fn
int ExtStopBLE();
#endif // USE_BLE_ESP32
void Every250mSeconds(void)
{
// As the max amount of sleep = 250 mSec this loop should always be taken...
@ -1010,6 +1015,9 @@ void Every250mSeconds(void)
SettingsSave(1); // Free flash for OTA update
}
if (TasmotaGlobal.ota_state_flag <= 0) {
#ifdef USE_BLE_ESP32
ExtStopBLE();
#endif // USE_BLE_ESP32
#ifdef USE_COUNTER
CounterInterruptDisable(true); // Prevent OTA failures on 100Hz counter interrupts
#endif // USE_COUNTER

View File

@ -2331,6 +2331,11 @@ void HandleUploadDone(void) {
WSContentStop();
}
#ifdef USE_BLE_ESP32
// declare the fn
int ExtStopBLE();
#endif
void UploadServices(uint32_t start_service) {
if (Web.upload_services_stopped != start_service) { return; }
Web.upload_services_stopped = !start_service;
@ -2355,6 +2360,9 @@ void UploadServices(uint32_t start_service) {
} else {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("UPL: Services disabled"));
#ifdef USE_BLE_ESP32
ExtStopBLE();
#endif
#ifdef USE_EMULATION
UdpDisconnect();
#endif // USE_EMULATION
@ -2374,11 +2382,6 @@ void UploadServices(uint32_t start_service) {
}
}
#ifdef USE_BLE_ESP32
// declare the fn
int ExtStopBLE();
#endif
void HandleUploadLoop(void) {
// Based on ESP8266HTTPUpdateServer.cpp uses ESP8266WebServer Parsing.cpp and Cores Updater.cpp (Update)
static uint32_t upload_size;
@ -2414,11 +2417,6 @@ void HandleUploadLoop(void) {
}
SettingsSave(1); // Free flash for upload
#ifdef USE_BLE_ESP32
ExtStopBLE();
#endif
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_FILE " %s"), upload.filename.c_str());
if (UPL_SETTINGS == Web.upload_file_type) {

File diff suppressed because it is too large Load Diff