tracker now sleeps and listens when not sleeping
This commit is contained in:
parent
cead4c3d59
commit
2396fa4948
|
|
@ -46,7 +46,7 @@ TinyGPSPlus gps;
|
|||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
#endif
|
||||
|
||||
String versionDate = "2024.07.19";
|
||||
String versionDate = "2024.07.24";
|
||||
|
||||
uint8_t myBeaconsIndex = 0;
|
||||
int myBeaconsSize = Config.beacons.size();
|
||||
|
|
@ -97,7 +97,7 @@ APRSPacket lastReceivedPacket;
|
|||
logging::Logger logger;
|
||||
//#define DEBUG
|
||||
|
||||
bool SleepModeActive = true;
|
||||
bool SleepModeActive = false;
|
||||
|
||||
|
||||
void setup() {
|
||||
|
|
@ -127,26 +127,28 @@ void setup() {
|
|||
WiFi.mode(WIFI_OFF);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "WiFi controller stopped");
|
||||
|
||||
if (Config.bluetoothType == 0 || Config.bluetoothType == 2) {
|
||||
BLE_Utils::setup();
|
||||
if (!SleepModeActive) {
|
||||
if (Config.bluetoothType == 0 || Config.bluetoothType == 2) {
|
||||
BLE_Utils::setup();
|
||||
} else {
|
||||
#ifdef HAS_BT_CLASSIC
|
||||
BLUETOOTH_Utils::setup();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!Config.simplifiedTrackerMode) {
|
||||
#ifdef BUTTON_PIN
|
||||
userButton.attachClick(BUTTON_Utils::singlePress);
|
||||
userButton.attachLongPressStart(BUTTON_Utils::longPress);
|
||||
userButton.attachDoubleClick(BUTTON_Utils::doublePress);
|
||||
userButton.attachMultiClick(BUTTON_Utils::multiPress);
|
||||
#endif
|
||||
KEYBOARD_Utils::setup();
|
||||
}
|
||||
} else {
|
||||
#ifdef HAS_BT_CLASSIC
|
||||
BLUETOOTH_Utils::setup();
|
||||
#endif
|
||||
SLEEP_Utils::setup();
|
||||
}
|
||||
|
||||
if (!Config.simplifiedTrackerMode) {
|
||||
#ifdef BUTTON_PIN
|
||||
userButton.attachClick(BUTTON_Utils::singlePress);
|
||||
userButton.attachLongPressStart(BUTTON_Utils::longPress);
|
||||
userButton.attachDoubleClick(BUTTON_Utils::doublePress);
|
||||
userButton.attachMultiClick(BUTTON_Utils::multiPress);
|
||||
#endif
|
||||
KEYBOARD_Utils::setup();
|
||||
}
|
||||
|
||||
SLEEP_Utils::setup();
|
||||
|
||||
POWER_Utils::lowerCpuFrequency();
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "Smart Beacon is: %s", Utils::getSmartBeaconState());
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Setup Done!");
|
||||
|
|
@ -169,12 +171,13 @@ void loop() {
|
|||
MSG_Utils::checkReceivedMessage(LoRa_Utils::receiveFromSleep());
|
||||
wakeUpFlag = false;
|
||||
}
|
||||
SLEEP_Utils::handle_wakeup();
|
||||
SLEEP_Utils::processBufferAfterSleep();
|
||||
//SLEEP_Utils::handle_wakeup();
|
||||
//SLEEP_Utils::processBufferAfterSleep();
|
||||
|
||||
|
||||
if (!wakeUpByButton) SLEEP_Utils::startSleep();
|
||||
if (wakeUpByButton && (millis() - wakeUpByButtonTime > 10 * 1000)) wakeUpByButton = false;
|
||||
SLEEP_Utils::startSleep();
|
||||
//if (!wakeUpByButton) SLEEP_Utils::startSleep();
|
||||
//if (wakeUpByButton && (millis() - wakeUpByButtonTime > 10 * 1000)) wakeUpByButton = false;
|
||||
|
||||
} else {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@
|
|||
#define RADIO_BUSY_PIN 13
|
||||
#define RADIO_WAKEUP_PIN RADIO_DIO1_PIN
|
||||
#define WAKEUP_BUTTON GPIO_NUM_0
|
||||
#define WAKEUP_RADIO GPIO_SEL_14
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -77,10 +77,20 @@ namespace SLEEP_Utils {
|
|||
}
|
||||
|
||||
void sleep(int seconds) {
|
||||
esp_sleep_enable_timer_wakeup(seconds * 1000000); // 1 min = 60sec
|
||||
esp_sleep_enable_timer_wakeup(300 * 1000000);
|
||||
//esp_sleep_enable_timer_wakeup(seconds * 1000000); // 1 min = 60sec
|
||||
delay(100);
|
||||
POWER_Utils::deactivateGPS();
|
||||
delay(100);
|
||||
#ifdef ADC_CTRL
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
digitalWrite(ADC_CTRL, LOW);
|
||||
#endif
|
||||
#endif
|
||||
LoRa_Utils::wakeRadio();
|
||||
//LoRa_Utils::sleepRadio();
|
||||
delay(100);
|
||||
//esp_deep_sleep_start();
|
||||
esp_light_sleep_start();
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +107,7 @@ namespace SLEEP_Utils {
|
|||
|
||||
void startSleep() {
|
||||
#if defined(HELTEC_WIRELESS_TRACKER)
|
||||
esp_sleep_enable_ext1_wakeup(GPIO_SEL_14, ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
esp_sleep_enable_ext1_wakeup(WAKEUP_RADIO, ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
//pinMode(BUTTON_PIN, INPUT_PULLUP); //internal pull down???
|
||||
//esp_sleep_enable_ext0_wakeup(WAKEUP_BUTTON, 0);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue