mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-18 16:52:27 +00:00
Fix #115: wake from light sleep if a character arrives on the serial port
Note - we do this not by using the uart wake feature, but by the lower power GPIO edge feature. Recommend sending "Z" 0x5A - because that has many edges. Send the character 4 times to make sure the device is awake
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "esp_pm.h"
|
||||
#include "rom/rtc.h"
|
||||
#include <driver/rtc_io.h>
|
||||
#include <driver/uart.h>
|
||||
|
||||
#include "BluetoothUtil.h"
|
||||
|
||||
@@ -111,7 +112,6 @@ void initDeepSleep()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool doPreflightSleep()
|
||||
{
|
||||
if (preflightSleep.notifyObservers(NULL) != 0)
|
||||
@@ -257,6 +257,17 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
||||
gpio_pullup_en((gpio_num_t)BUTTON_PIN);
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL0_RX_GPIO
|
||||
// We treat the serial port as a GPIO for a fast/low power way of waking, if we see a rising edge that means
|
||||
// someone started to send something
|
||||
|
||||
// Alas - doesn't work reliably, instead need to use the uart specific version (which burns a little power)
|
||||
// FIXME: gpio 3 is RXD for serialport 0 on ESP32
|
||||
// Send a few Z characters to wake the port
|
||||
gpio_wakeup_enable((gpio_num_t)SERIAL0_RX_GPIO, GPIO_INTR_LOW_LEVEL);
|
||||
// uart_set_wakeup_threshold(UART_NUM_0, 3);
|
||||
// esp_sleep_enable_uart_wakeup(0);
|
||||
#endif
|
||||
#ifdef BUTTON_PIN
|
||||
gpio_wakeup_enable((gpio_num_t)BUTTON_PIN, GPIO_INTR_LOW_LEVEL); // when user presses, this button goes low
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user