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);
|
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String versionDate = "2024.07.19";
|
String versionDate = "2024.07.24";
|
||||||
|
|
||||||
uint8_t myBeaconsIndex = 0;
|
uint8_t myBeaconsIndex = 0;
|
||||||
int myBeaconsSize = Config.beacons.size();
|
int myBeaconsSize = Config.beacons.size();
|
||||||
|
|
@ -97,7 +97,7 @@ APRSPacket lastReceivedPacket;
|
||||||
logging::Logger logger;
|
logging::Logger logger;
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
bool SleepModeActive = true;
|
bool SleepModeActive = false;
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
@ -127,26 +127,28 @@ void setup() {
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "WiFi controller stopped");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "WiFi controller stopped");
|
||||||
|
|
||||||
if (Config.bluetoothType == 0 || Config.bluetoothType == 2) {
|
if (!SleepModeActive) {
|
||||||
BLE_Utils::setup();
|
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 {
|
} else {
|
||||||
#ifdef HAS_BT_CLASSIC
|
SLEEP_Utils::setup();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
SLEEP_Utils::setup();
|
|
||||||
|
|
||||||
POWER_Utils::lowerCpuFrequency();
|
POWER_Utils::lowerCpuFrequency();
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "Smart Beacon is: %s", Utils::getSmartBeaconState());
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Main", "Smart Beacon is: %s", Utils::getSmartBeaconState());
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Setup Done!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Setup Done!");
|
||||||
|
|
@ -169,12 +171,13 @@ void loop() {
|
||||||
MSG_Utils::checkReceivedMessage(LoRa_Utils::receiveFromSleep());
|
MSG_Utils::checkReceivedMessage(LoRa_Utils::receiveFromSleep());
|
||||||
wakeUpFlag = false;
|
wakeUpFlag = false;
|
||||||
}
|
}
|
||||||
SLEEP_Utils::handle_wakeup();
|
//SLEEP_Utils::handle_wakeup();
|
||||||
SLEEP_Utils::processBufferAfterSleep();
|
//SLEEP_Utils::processBufferAfterSleep();
|
||||||
|
|
||||||
|
|
||||||
if (!wakeUpByButton) SLEEP_Utils::startSleep();
|
SLEEP_Utils::startSleep();
|
||||||
if (wakeUpByButton && (millis() - wakeUpByButtonTime > 10 * 1000)) wakeUpByButton = false;
|
//if (!wakeUpByButton) SLEEP_Utils::startSleep();
|
||||||
|
//if (wakeUpByButton && (millis() - wakeUpByButtonTime > 10 * 1000)) wakeUpByButton = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@
|
||||||
#define RADIO_BUSY_PIN 13
|
#define RADIO_BUSY_PIN 13
|
||||||
#define RADIO_WAKEUP_PIN RADIO_DIO1_PIN
|
#define RADIO_WAKEUP_PIN RADIO_DIO1_PIN
|
||||||
#define WAKEUP_BUTTON GPIO_NUM_0
|
#define WAKEUP_BUTTON GPIO_NUM_0
|
||||||
|
#define WAKEUP_RADIO GPIO_SEL_14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,20 @@ namespace SLEEP_Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep(int seconds) {
|
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);
|
delay(100);
|
||||||
POWER_Utils::deactivateGPS();
|
POWER_Utils::deactivateGPS();
|
||||||
|
delay(100);
|
||||||
|
#ifdef ADC_CTRL
|
||||||
|
#ifdef HELTEC_WIRELESS_TRACKER
|
||||||
|
digitalWrite(ADC_CTRL, LOW);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
LoRa_Utils::wakeRadio();
|
LoRa_Utils::wakeRadio();
|
||||||
|
//LoRa_Utils::sleepRadio();
|
||||||
|
delay(100);
|
||||||
|
//esp_deep_sleep_start();
|
||||||
esp_light_sleep_start();
|
esp_light_sleep_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +107,7 @@ namespace SLEEP_Utils {
|
||||||
|
|
||||||
void startSleep() {
|
void startSleep() {
|
||||||
#if defined(HELTEC_WIRELESS_TRACKER)
|
#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???
|
//pinMode(BUTTON_PIN, INPUT_PULLUP); //internal pull down???
|
||||||
//esp_sleep_enable_ext0_wakeup(WAKEUP_BUTTON, 0);
|
//esp_sleep_enable_ext0_wakeup(WAKEUP_BUTTON, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue