mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-10 15:12:06 +00:00
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:
parent
1f9f885aca
commit
a5c96a29d5
@ -396,6 +396,7 @@ bool MQTT::wantsLink() const
|
|||||||
|
|
||||||
int32_t MQTT::runOnce()
|
int32_t MQTT::runOnce()
|
||||||
{
|
{
|
||||||
|
#ifdef HAS_NETWORKING
|
||||||
if (!moduleConfig.mqtt.enabled || !(moduleConfig.mqtt.map_reporting_enabled || channels.anyMqttEnabled()))
|
if (!moduleConfig.mqtt.enabled || !(moduleConfig.mqtt.map_reporting_enabled || channels.anyMqttEnabled()))
|
||||||
return disable();
|
return disable();
|
||||||
|
|
||||||
@ -408,7 +409,7 @@ int32_t MQTT::runOnce()
|
|||||||
publishQueuedMessages();
|
publishQueuedMessages();
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
#ifdef HAS_NETWORKING
|
|
||||||
else if (!pubSub.loop()) {
|
else if (!pubSub.loop()) {
|
||||||
if (!wantConnection)
|
if (!wantConnection)
|
||||||
return 5000; // If we don't want connection now, check again in 5 secs
|
return 5000; // If we don't want connection now, check again in 5 secs
|
||||||
|
@ -24,7 +24,12 @@
|
|||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
void setBluetoothEnable(bool enable)
|
void setBluetoothEnable(bool enable)
|
||||||
{
|
{
|
||||||
|
#ifndef MESHTASTIC_EXCLUDE_WIFI
|
||||||
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
|
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
|
||||||
|
#endif
|
||||||
|
#ifdef MESHTASTIC_EXCLUDE_WIFI
|
||||||
|
if (config.bluetooth.enabled == true) {
|
||||||
|
#endif
|
||||||
if (!nimbleBluetooth) {
|
if (!nimbleBluetooth) {
|
||||||
nimbleBluetooth = new NimbleBluetooth();
|
nimbleBluetooth = new NimbleBluetooth();
|
||||||
}
|
}
|
||||||
@ -35,22 +40,22 @@ void setBluetoothEnable(bool enable)
|
|||||||
// BLE advertising automatically stops when MCU enters light-sleep(?)
|
// BLE advertising automatically stops when MCU enters light-sleep(?)
|
||||||
// For deep-sleep, shutdown hardware with nimbleBluetooth->deinit(). Requires reboot to reverse
|
// For deep-sleep, shutdown hardware with nimbleBluetooth->deinit(). Requires reboot to reverse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void setBluetoothEnable(bool enable) {}
|
void setBluetoothEnable(bool enable) {}
|
||||||
void updateBatteryLevel(uint8_t level) {}
|
void updateBatteryLevel(uint8_t level) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void getMacAddr(uint8_t *dmac)
|
void getMacAddr(uint8_t * dmac)
|
||||||
{
|
{
|
||||||
assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
|
assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_32768HZ
|
#ifdef HAS_32768HZ
|
||||||
#define CALIBRATE_ONE(cali_clk) calibrate_one(cali_clk, #cali_clk)
|
#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 uint32_t cal_count = 1000;
|
||||||
// const float factor = (1 << 19) * 1000.0f; unused var?
|
// const float factor = (1 << 19) * 1000.0f; unused var?
|
||||||
uint32_t cali_val;
|
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);
|
cali_val = rtc_clk_cal(cal_clk, cal_count);
|
||||||
}
|
}
|
||||||
return cali_val;
|
return cali_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableSlowCLK()
|
void enableSlowCLK()
|
||||||
{
|
{
|
||||||
rtc_clk_32k_enable(true);
|
rtc_clk_32k_enable(true);
|
||||||
|
|
||||||
CALIBRATE_ONE(RTC_CAL_RTC_MUX);
|
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");
|
LOG_WARN("Failed to switch 32K XTAL RTC source to 32.768Khz !!! \n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void esp32Setup()
|
void esp32Setup()
|
||||||
{
|
{
|
||||||
uint32_t seed = esp_random();
|
uint32_t seed = esp_random();
|
||||||
LOG_DEBUG("Setting random seed %u\n", seed);
|
LOG_DEBUG("Setting random seed %u\n", seed);
|
||||||
|
|
||||||
@ -138,7 +143,7 @@ void esp32Setup()
|
|||||||
#ifdef HAS_32768HZ
|
#ifdef HAS_32768HZ
|
||||||
enableSlowCLK();
|
enableSlowCLK();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Turn off for now
|
// Turn off for now
|
||||||
@ -160,17 +165,17 @@ uint32_t axpDebugRead()
|
|||||||
Periodic axpDebugOutput(axpDebugRead);
|
Periodic axpDebugOutput(axpDebugRead);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// loop code specific to ESP32 targets
|
/// loop code specific to ESP32 targets
|
||||||
void esp32Loop()
|
void esp32Loop()
|
||||||
{
|
{
|
||||||
esp_task_wdt_reset(); // service our app level watchdog
|
esp_task_wdt_reset(); // service our app level watchdog
|
||||||
|
|
||||||
// for debug printing
|
// for debug printing
|
||||||
// radio.radioIf.canSleep();
|
// 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.
|
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
|
If an external circuit drives this pin in deep sleep mode, current consumption may
|
||||||
@ -214,8 +219,8 @@ void cpuDeepSleep(uint32_t msecToWake)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Not needed because both of the current boards have external pullups
|
// 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
|
// FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead
|
||||||
// just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
// of just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
||||||
|
|
||||||
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
#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_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs
|
||||||
esp_deep_sleep_start(); // TBD mA sleep current (battery)
|
esp_deep_sleep_start(); // TBD mA sleep current (battery)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user