Fix missing IFNDEF and IFDEF in main-esp32.cpp when EXCLUDE_WIFI is defined.

Moved IFDEF HAS_NETWORK to beginning of MQTT:runOnce (to catch when EXCLUDE_WIFI is defined)
This commit is contained in:
Talie5in 2024-06-06 22:52:11 +09:30
parent 1f9f885aca
commit a5c96a29d5
2 changed files with 128 additions and 122 deletions

View File

@ -396,6 +396,7 @@ bool MQTT::wantsLink() const
int32_t MQTT::runOnce()
{
#ifdef HAS_NETWORKING
if (!moduleConfig.mqtt.enabled || !(moduleConfig.mqtt.map_reporting_enabled || channels.anyMqttEnabled()))
return disable();
@ -408,7 +409,7 @@ int32_t MQTT::runOnce()
publishQueuedMessages();
return 200;
}
#ifdef HAS_NETWORKING
else if (!pubSub.loop()) {
if (!wantConnection)
return 5000; // If we don't want connection now, check again in 5 secs

View File

@ -24,7 +24,12 @@
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
void setBluetoothEnable(bool enable)
{
#ifndef MESHTASTIC_EXCLUDE_WIFI
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
#endif
#ifdef MESHTASTIC_EXCLUDE_WIFI
if (config.bluetooth.enabled == true) {
#endif
if (!nimbleBluetooth) {
nimbleBluetooth = new NimbleBluetooth();
}
@ -35,22 +40,22 @@ void setBluetoothEnable(bool enable)
// BLE advertising automatically stops when MCU enters light-sleep(?)
// For deep-sleep, shutdown hardware with nimbleBluetooth->deinit(). Requires reboot to reverse
}
}
}
#else
void setBluetoothEnable(bool enable) {}
void updateBatteryLevel(uint8_t level) {}
#endif
void getMacAddr(uint8_t *dmac)
{
void getMacAddr(uint8_t * dmac)
{
assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
}
}
#ifdef HAS_32768HZ
#define CALIBRATE_ONE(cali_clk) calibrate_one(cali_clk, #cali_clk)
static uint32_t calibrate_one(rtc_cal_sel_t cal_clk, const char *name)
{
static uint32_t calibrate_one(rtc_cal_sel_t cal_clk, const char *name)
{
const uint32_t cal_count = 1000;
// const float factor = (1 << 19) * 1000.0f; unused var?
uint32_t cali_val;
@ -58,10 +63,10 @@ static uint32_t calibrate_one(rtc_cal_sel_t cal_clk, const char *name)
cali_val = rtc_clk_cal(cal_clk, cal_count);
}
return cali_val;
}
}
void enableSlowCLK()
{
void enableSlowCLK()
{
rtc_clk_32k_enable(true);
CALIBRATE_ONE(RTC_CAL_RTC_MUX);
@ -81,11 +86,11 @@ void enableSlowCLK()
LOG_WARN("Failed to switch 32K XTAL RTC source to 32.768Khz !!! \n");
return;
}
}
}
#endif
void esp32Setup()
{
void esp32Setup()
{
uint32_t seed = esp_random();
LOG_DEBUG("Setting random seed %u\n", seed);
@ -138,7 +143,7 @@ void esp32Setup()
#ifdef HAS_32768HZ
enableSlowCLK();
#endif
}
}
#if 0
// Turn off for now
@ -160,17 +165,17 @@ uint32_t axpDebugRead()
Periodic axpDebugOutput(axpDebugRead);
#endif
/// loop code specific to ESP32 targets
void esp32Loop()
{
/// loop code specific to ESP32 targets
void esp32Loop()
{
esp_task_wdt_reset(); // service our app level watchdog
// for debug printing
// radio.radioIf.canSleep();
}
}
void cpuDeepSleep(uint32_t msecToWake)
{
void cpuDeepSleep(uint32_t msecToWake)
{
/*
Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default.
If an external circuit drives this pin in deep sleep mode, current consumption may
@ -214,8 +219,8 @@ void cpuDeepSleep(uint32_t msecToWake)
#endif
// Not needed because both of the current boards have external pullups
// FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead of
// just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN);
// FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead
// of just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN);
#if SOC_PM_SUPPORT_EXT_WAKEUP
#ifdef CONFIG_IDF_TARGET_ESP32
@ -232,4 +237,4 @@ void cpuDeepSleep(uint32_t msecToWake)
esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs
esp_deep_sleep_start(); // TBD mA sleep current (battery)
}
}