diff --git a/bin/version.sh b/bin/version.sh index fb34ea22b..75c088c98 100644 --- a/bin/version.sh +++ b/bin/version.sh @@ -1,3 +1,3 @@ -export VERSION=1.1.1 \ No newline at end of file +export VERSION=1.1.2 \ No newline at end of file diff --git a/docs/software/gps-todo.txt b/docs/software/gps-todo.txt index 79503ebcd..5dc8c273e 100644 --- a/docs/software/gps-todo.txt +++ b/docs/software/gps-todo.txt @@ -1,4 +1,4 @@ -gps todo - bug 376 +You probably don't care about this ugly file of personal notes ;-) for taiwan region: bin/run.sh --set region 8 @@ -6,40 +6,12 @@ bin/run.sh --set region 8 time only mode ./bin/run.sh --set gps_operation 3 -increase acquisition time until ublox power management can be improved see 9.3.1 - ublox parsing failure record power measurements and update spreadsheet -fix has_gps based on new logic - -make sure we are turning off lora radio in deep sleep - -don't send locations if the user has forbidden that (lie to phone so phone won't either) - have loop methods return allowable sleep time (from their perspective) increase main cpu sleep time -add set router mode in python tool - it will also set GPS to stationary -make sure location still gets set once per boot and stays marked as valid on the gui -send position updates super rarely -turn off checking for usb power and forcing always on -(which will shrink DARK and NB period to zero and - make light_sleep very long) - warn people about crummy gps antennas - add to faq - -gps states - -Active - for gps_attempt_time seconds -Sleeping - for (gps_update_rate or sleep forever) seconds -ForcedSleep - PowerFSM says we don't want to use GPS right now -(no need for sleep forever state) - -gps triggers -GPS_TRIG_FORCE_SLEEP - from powerfsm -GPS_TRIG_FORCE_WAKE - from powerfsm -GPS_SETTINGS - if GPS settings changed, reset params and possibly become active - diff --git a/platformio.ini b/platformio.ini index b48dc3938..cf255f380 100644 --- a/platformio.ini +++ b/platformio.ini @@ -62,8 +62,8 @@ lib_deps = 1260 ; OneButton library for non-blocking button debounce 1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib https://github.com/meshtastic/arduino-fsm.git - https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git#cb8353dfddd1b0e205098f5e70d5f2a5f74b4838 - https://github.com/meshtastic/RadioLib.git#1083c2e76f9906c5f80dfec726facebf8413eef0 + https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git#31015a55e630a2df77d9d714669c621a5bf355ad + https://github.com/meshtastic/RadioLib.git#8657380241bce681c33aab46598bbf13b11f876c https://github.com/meshtastic/TinyGPSPlus.git https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460 Wire ; explicitly needed here because the AXP202 library forgets to add it diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index ba43041d7..8e75e20fe 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1,10 +1,10 @@ #include "GPS.h" #include "NodeDB.h" +#include "RTC.h" #include "configuration.h" #include "sleep.h" #include -#include // If we have a serial GPS port it will not be null #ifdef GPS_RX_PIN @@ -23,76 +23,8 @@ uint8_t GPS::i2cAddress = GPS_I2C_ADDRESS; uint8_t GPS::i2cAddress = 0; #endif -bool timeSetFromGPS; // We try to set our time from GPS each time we wake from sleep - GPS *gps; -// stuff that really should be in in the instance instead... -static uint32_t - timeStartMsec; // Once we have a GPS lock, this is where we hold the initial msec clock that corresponds to that time -static uint64_t zeroOffsetSecs; // GPS based time in secs since 1970 - only updated once on initial lock - -void readFromRTC() -{ - struct timeval tv; /* btw settimeofday() is helpfull here too*/ - - if (!gettimeofday(&tv, NULL)) { - uint32_t now = millis(); - - DEBUG_MSG("Read RTC time as %ld (cur millis %u) valid=%d\n", tv.tv_sec, now, timeSetFromGPS); - timeStartMsec = now; - zeroOffsetSecs = tv.tv_sec; - } -} - -/// If we haven't yet set our RTC this boot, set it from a GPS derived time -bool perhapsSetRTC(const struct timeval *tv) -{ - if (!timeSetFromGPS) { - timeSetFromGPS = true; - DEBUG_MSG("Setting RTC %ld secs\n", tv->tv_sec); -#ifndef NO_ESP32 - settimeofday(tv, NULL); -#else - DEBUG_MSG("ERROR TIME SETTING NOT IMPLEMENTED!\n"); -#endif - readFromRTC(); - return true; - } else { - return false; - } -} - -bool perhapsSetRTC(struct tm &t) -{ - /* Convert to unix time - The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 - (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). - */ - time_t res = mktime(&t); - struct timeval tv; - tv.tv_sec = res; - tv.tv_usec = 0; // time.centisecond() * (10 / 1000); - - // DEBUG_MSG("Got time from GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec); - if (t.tm_year < 0 || t.tm_year >= 300) { - // DEBUG_MSG("Ignoring invalid GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec); - return false; - } else { - return perhapsSetRTC(&tv); - } -} - -uint32_t getTime() -{ - return ((millis() - timeStartMsec) / 1000) + zeroOffsetSecs; -} - -uint32_t getValidTime() -{ - return timeSetFromGPS ? getTime() : 0; -} - bool GPS::setup() { setAwake(true); // Wake GPS power before doing any init @@ -151,7 +83,7 @@ uint32_t GPS::getWakeTime() const return t; // already maxint if (t == 0) - t = 5 * 60; // Allow up to 5 mins for each attempt (probably will be much less if we can find sats) + t = 15 * 60; // Allow up to 5 mins for each attempt (probably will be much less if we can find sats) t *= 1000; // msecs @@ -165,7 +97,8 @@ uint32_t GPS::getSleepTime() const uint32_t t = radioConfig.preferences.gps_update_interval; auto op = getGpsOp(); - if ((timeSetFromGPS && op == GpsOperation_GpsOpTimeOnly) || (op == GpsOperation_GpsOpDisabled)) + bool gotTime = (getRTCQuality() >= RTCQualityGPS); + if ((gotTime && op == GpsOperation_GpsOpTimeOnly) || (op == GpsOperation_GpsOpDisabled)) t = UINT32_MAX; // Sleep forever now if (t == UINT32_MAX) @@ -208,13 +141,13 @@ void GPS::loop() // While we are awake if (isAwake) { // DEBUG_MSG("looking for location\n"); - if ((now - lastWhileActiveMsec) > 1000) { + if ((now - lastWhileActiveMsec) > 5000) { lastWhileActiveMsec = now; whileActive(); } // If we've already set time from the GPS, no need to ask the GPS - bool gotTime = timeSetFromGPS || lookForTime(); + bool gotTime = (getRTCQuality() >= RTCQualityGPS) || lookForTime(); bool gotLoc = lookForLocation(); // We've been awake too long - force sleep @@ -224,7 +157,7 @@ void GPS::loop() // Once we get a location we no longer desperately want an update // or if we got a time and we are in GpsOpTimeOnly mode // DEBUG_MSG("gotLoc %d, tooLong %d, gotTime %d\n", gotLoc, tooLong, gotTime); - if (gotLoc || tooLong || (gotTime && getGpsOp() == GpsOperation_GpsOpTimeOnly)) { + if ((gotLoc && gotTime) || tooLong || (gotTime && getGpsOp() == GpsOperation_GpsOpTimeOnly)) { if (gotLoc) hasValidLocation = true; @@ -247,7 +180,10 @@ void GPS::forceWake(bool on) wakeAllowed = true; } else { wakeAllowed = false; - setAwake(false); + + // Note: if the gps was already awake, we DO NOT shut it down, because we want to allow it to complete its lock + // attempt even if we are in light sleep. Once the attempt succeeds (or times out) we'll then shut it down. + // setAwake(false); } } diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 1f8429a44..3c0b0c480 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -1,25 +1,11 @@ #pragma once -#include "../concurrency/PeriodicTask.h" #include "GPSStatus.h" #include "Observer.h" -#include "sys/time.h" - -/// If we haven't yet set our RTC this boot, set it from a GPS derived time -bool perhapsSetRTC(const struct timeval *tv); -bool perhapsSetRTC(struct tm &t); // Generate a string representation of DOP const char *getDOPString(uint32_t dop); -/// Return time since 1970 in secs. Until we have a GPS lock we will be returning time based at zero -uint32_t getTime(); - -/// Return time since 1970 in secs. If we don't have a GPS lock return zero -uint32_t getValidTime(); - -void readFromRTC(); - /** * A gps class that only reads from the GPS periodically (and FIXME - eventually keeps the gps powered down except when reading) * diff --git a/src/gps/NMEAGPS.cpp b/src/gps/NMEAGPS.cpp index 1b6bb1b35..50367469e 100644 --- a/src/gps/NMEAGPS.cpp +++ b/src/gps/NMEAGPS.cpp @@ -1,5 +1,6 @@ #include "NMEAGPS.h" #include "configuration.h" +#include "RTC.h" static int32_t toDegInt(RawDegrees d) { @@ -44,7 +45,7 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s t.tm_mon = d.month() - 1; t.tm_year = d.year() - 1900; t.tm_isdst = false; - perhapsSetRTC(t); + perhapsSetRTC(RTCQualityGPS, t); return true; } else diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp new file mode 100644 index 000000000..ff2e9afac --- /dev/null +++ b/src/gps/RTC.cpp @@ -0,0 +1,77 @@ +#include "RTC.h" +#include "configuration.h" +#include +#include + +static RTCQuality currentQuality = RTCQualityNone; + +RTCQuality getRTCQuality() +{ + return currentQuality; +} + +// stuff that really should be in in the instance instead... +static uint32_t + timeStartMsec; // Once we have a GPS lock, this is where we hold the initial msec clock that corresponds to that time +static uint64_t zeroOffsetSecs; // GPS based time in secs since 1970 - only updated once on initial lock + +void readFromRTC() +{ + struct timeval tv; /* btw settimeofday() is helpfull here too*/ + + if (!gettimeofday(&tv, NULL)) { + uint32_t now = millis(); + + DEBUG_MSG("Read RTC time as %ld (cur millis %u) quality=%d\n", tv.tv_sec, now, currentQuality); + timeStartMsec = now; + zeroOffsetSecs = tv.tv_sec; + } +} + +/// If we haven't yet set our RTC this boot, set it from a GPS derived time +bool perhapsSetRTC(RTCQuality q, const struct timeval *tv) +{ + if (q > currentQuality) { + currentQuality = q; + DEBUG_MSG("Setting RTC %ld secs\n", tv->tv_sec); +#ifndef NO_ESP32 + settimeofday(tv, NULL); +#else + DEBUG_MSG("ERROR TIME SETTING NOT IMPLEMENTED!\n"); +#endif + readFromRTC(); + return true; + } else { + return false; + } +} + +bool perhapsSetRTC(RTCQuality q, struct tm &t) +{ + /* Convert to unix time + The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 + (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). + */ + time_t res = mktime(&t); + struct timeval tv; + tv.tv_sec = res; + tv.tv_usec = 0; // time.centisecond() * (10 / 1000); + + // DEBUG_MSG("Got time from GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec); + if (t.tm_year < 0 || t.tm_year >= 300) { + // DEBUG_MSG("Ignoring invalid GPS month=%d, year=%d, unixtime=%ld\n", t.tm_mon, t.tm_year, tv.tv_sec); + return false; + } else { + return perhapsSetRTC(q, &tv); + } +} + +uint32_t getTime() +{ + return ((millis() - timeStartMsec) / 1000) + zeroOffsetSecs; +} + +uint32_t getValidTime() +{ + return (currentQuality >= RTCQualityFromNet) ? getTime() : 0; +} diff --git a/src/gps/RTC.h b/src/gps/RTC.h new file mode 100644 index 000000000..e17ca7a94 --- /dev/null +++ b/src/gps/RTC.h @@ -0,0 +1,30 @@ +#pragma once + +#include "configuration.h" +#include "sys/time.h" +#include + +enum RTCQuality { + /// We haven't had our RTC set yet + RTCQualityNone = 0, + + /// Some other node gave us a time we can use + RTCQualityFromNet = 1, + + /// Our time is based on our own GPS + RTCQualityGPS = 2 +}; + +RTCQuality getRTCQuality(); + +/// If we haven't yet set our RTC this boot, set it from a GPS derived time +bool perhapsSetRTC(RTCQuality q, const struct timeval *tv); +bool perhapsSetRTC(RTCQuality q, struct tm &t); + +/// Return time since 1970 in secs. While quality is RTCQualityNone we will be returning time based at zero +uint32_t getTime(); + +/// Return time since 1970 in secs. If quality is RTCQualityNone return zero +uint32_t getValidTime(); + +void readFromRTC(); \ No newline at end of file diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index 1007162b6..acbe02208 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -1,4 +1,5 @@ #include "UBloxGPS.h" +#include "RTC.h" #include "error.h" #include "sleep.h" #include @@ -32,7 +33,7 @@ bool UBloxGPS::setupGPS() _serial_gps->begin(GPS_BAUDRATE); #endif #ifndef NO_ESP32 - _serial_gps->setRxBufferSize(1024); // the default is 256 + _serial_gps->setRxBufferSize(2048); // the default is 256 #endif } @@ -126,7 +127,7 @@ void UBloxGPS::whileActive() // Update fixtype if (ublox.moduleQueried.fixType) { fixType = ublox.getFixType(0); - DEBUG_MSG("GPS fix type %d\n", fixType); + DEBUG_MSG("GPS fix type %d, numSats %d\n", fixType, numSatellites); } } @@ -138,23 +139,21 @@ void UBloxGPS::whileActive() */ bool UBloxGPS::lookForTime() { - if (fixType >= 2) { - if (ublox.moduleQueried.gpsSecond) { - /* Convert to unix time - The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January - 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). - */ - struct tm t; - t.tm_sec = ublox.getSecond(0); - t.tm_min = ublox.getMinute(0); - t.tm_hour = ublox.getHour(0); - t.tm_mday = ublox.getDay(0); - t.tm_mon = ublox.getMonth(0) - 1; - t.tm_year = ublox.getYear(0) - 1900; - t.tm_isdst = false; - perhapsSetRTC(t); - return true; - } + if (ublox.moduleQueried.gpsSecond) { + /* Convert to unix time + The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January + 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). + */ + struct tm t; + t.tm_sec = ublox.getSecond(0); + t.tm_min = ublox.getMinute(0); + t.tm_hour = ublox.getHour(0); + t.tm_mday = ublox.getDay(0); + t.tm_mon = ublox.getMonth(0) - 1; + t.tm_year = ublox.getYear(0) - 1900; + t.tm_isdst = false; + perhapsSetRTC(RTCQualityGPS, t); + return true; } return false; @@ -170,6 +169,12 @@ bool UBloxGPS::lookForLocation() { bool foundLocation = false; + if (ublox.moduleQueried.SIV) + numSatellites = ublox.getSIV(0); + + if (ublox.moduleQueried.pDOP) + dop = ublox.getPDOP(0); // PDOP (an accuracy metric) is reported in 10^2 units so we have to scale down when we use it + // we only notify if position has changed due to a new fix if ((fixType >= 3 && fixType <= 4)) { if (ublox.moduleQueried.latitude) // rd fixes only @@ -177,12 +182,10 @@ bool UBloxGPS::lookForLocation() latitude = ublox.getLatitude(0); longitude = ublox.getLongitude(0); altitude = ublox.getAltitudeMSL(0) / 1000; // in mm convert to meters - dop = ublox.getPDOP(0); // PDOP (an accuracy metric) is reported in 10^2 units so we have to scale down when we use it // Note: heading is only currently implmented in the ublox for the 8m chipset - therefore // don't read it here - it will generate an ignored getPVT command on the 6ms // heading = ublox.getHeading(0); - numSatellites = ublox.getSIV(0); // bogus lat lon is reported as 0 or 0 (can be bogus just for one) // Also: apparently when the GPS is initially reporting lock it can output a bogus latitude > 90 deg! diff --git a/src/main.cpp b/src/main.cpp index f4e811f54..1e1f1e014 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,7 @@ // #include "rom/rtc.h" #include "DSRRouter.h" // #include "debug.h" +#include "RTC.h" #include "SPILock.h" #include "graphics/Screen.h" #include "main.h" @@ -151,6 +152,8 @@ void userButtonPressedLong() screen.adjustBrightness(); } +RadioInterface *rIf = NULL; + void setup() { #ifdef USE_SEGGER @@ -298,8 +301,7 @@ void setup() digitalWrite(SX1262_ANT_SW, 1); #endif - // MUST BE AFTER service.init, so we have our radio config settings (from nodedb init) - RadioInterface *rIf = NULL; + // radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init) #if defined(RF95_IRQ) if (!rIf) { @@ -405,6 +407,9 @@ void loop() loopWifi(); + // For debugging + // if (rIf) ((RadioLibInterface *)rIf)->isActivelyReceiving(); + // Show boot screen for first 3 seconds, then switch to normal operation. static bool showingBootScreen = true; if (showingBootScreen && (millis() > 3000)) { diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index b514b0c5b..a32423271 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -10,6 +10,7 @@ #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" +#include "RTC.h" #include "main.h" #include "mesh-pb-constants.h" #include "power.h" @@ -139,7 +140,7 @@ void MeshService::handleIncomingPosition(const MeshPacket *mp) tv.tv_sec = secs; tv.tv_usec = 0; - perhapsSetRTC(&tv); + perhapsSetRTC(RTCQualityFromNet, &tv); } } else { DEBUG_MSG("Ignoring incoming packet - not a position\n"); @@ -150,12 +151,8 @@ int MeshService::handleFromRadio(const MeshPacket *mp) { powerFSM.trigger(EVENT_RECEIVED_PACKET); // Possibly keep the node from sleeping - // If it is a position packet, perhaps set our clock (if we don't have a GPS of our own, otherwise wait for that to work) - if (!gps->isConnected) - handleIncomingPosition(mp); - else { - DEBUG_MSG("Ignoring incoming time, because we have a GPS\n"); - } + // If it is a position packet, perhaps set our clock + handleIncomingPosition(mp); if (mp->which_payload == MeshPacket_decoded_tag && mp->decoded.which_payload == SubPacket_user_tag) { mp = handleFromRadioUser(mp); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 349e7e67d..1224ae6dd 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -10,6 +10,7 @@ #include "NodeDB.h" #include "PacketHistory.h" #include "PowerFSM.h" +#include "RTC.h" #include "Router.h" #include "configuration.h" #include "error.h" diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 3cbcef170..fce496c87 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -109,7 +109,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) break; case STATE_SEND_MY_INFO: - myNodeInfo.has_gps = gps && gps->isConnected; // Update with latest GPS connect info + // If the user has specified they don't want our node to share its location, make sure to tell the phone + // app not to send locations on our behalf. + myNodeInfo.has_gps = (radioConfig.preferences.location_share == LocationSharing_LocDisabled) + ? true + : (gps && gps->isConnected); // Update with latest GPS connect info fromRadioScratch.which_variant = FromRadio_my_info_tag; fromRadioScratch.variant.my_info = myNodeInfo; state = STATE_SEND_RADIO; diff --git a/src/mesh/RadioLibInterface.h b/src/mesh/RadioLibInterface.h index d393077b5..b1d62bdb7 100644 --- a/src/mesh/RadioLibInterface.h +++ b/src/mesh/RadioLibInterface.h @@ -137,6 +137,11 @@ class RadioLibInterface : public RadioInterface, private concurrency::PeriodicTa */ virtual void startReceive() = 0; + /** are we actively receiving a packet (only called during receiving state) + * This method is only public to facilitate debugging. Do not call. + */ + virtual bool isActivelyReceiving() = 0; + private: /** if we have something waiting to send, start a short random timer so we can come check for collision before actually doing * the transmit @@ -176,9 +181,6 @@ class RadioLibInterface : public RadioInterface, private concurrency::PeriodicTa /** Could we send right now (i.e. either not actively receiving or transmitting)? */ virtual bool canSendImmediately(); - /** are we actively receiving a packet (only called during receiving state) */ - virtual bool isActivelyReceiving() = 0; - /** * Raw ISR handler that just calls our polymorphic method */ diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 74bb21960..6a3382000 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -1,6 +1,6 @@ #include "Router.h" #include "CryptoEngine.h" -#include "GPS.h" +#include "RTC.h" #include "configuration.h" #include "mesh-pb-constants.h" #include diff --git a/src/mesh/SX1262Interface.cpp b/src/mesh/SX1262Interface.cpp index b17acd9fe..a177441a4 100644 --- a/src/mesh/SX1262Interface.cpp +++ b/src/mesh/SX1262Interface.cpp @@ -179,16 +179,18 @@ void SX1262Interface::startReceive() /** Could we send right now (i.e. either not actively receving or transmitting)? */ bool SX1262Interface::isActivelyReceiving() { - // The IRQ status will be cleared when we start our read operation. Check if we've started a preamble, but haven't yet + // The IRQ status will be cleared when we start our read operation. Check if we've started a header, but haven't yet // received and handled the interrupt for reading the packet/handling errors. + // FIXME: it would be better to check for preamble, but we currently have our ISR not set to fire for packets that + // never even get a valid header, so we don't want preamble to get set and stay set due to noise on the network. uint16_t irq = lora.getIrqStatus(); - bool hasPreamble = (irq & SX126X_IRQ_PREAMBLE_DETECTED); + bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID); // this is not correct - often always true - need to add an extra conditional // size_t bytesPending = lora.getPacketLength(); - // if (hasPreamble || bytesPending) DEBUG_MSG("rx hasPre %d, bytes %d\n", hasPreamble, bytesPending); + // if (hasPreamble) DEBUG_MSG("rx hasPreamble\n"); return hasPreamble; } diff --git a/src/sleep.cpp b/src/sleep.cpp index a6753d8ac..d3a550628 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -170,17 +170,18 @@ void doDeepSleep(uint64_t msecToWake) #ifdef TBEAM_V10 if (axp192_found) { + // Obsolete comment: from back when we we used to receive lora packets while CPU was in deep sleep. + // We no longer do that, because our light-sleep current draws are low enough and it provides fast start/low cost + // wake. We currently use deep sleep only for 'we want our device to actually be off - because our battery is + // critically low'. So in deep sleep we DO shut down power to LORA (and when we boot later we completely reinit it) + // // No need to turn this off if the power draw in sleep mode really is just 0.2uA and turning it off would // leave floating input for the IRQ line - // If we want to leave the radio receving in would be 11.5mA current draw, but most of the time it is just waiting // in its sequencer (true?) so the average power draw should be much lower even if we were listinging for packets // all the time. - // axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); // LORA radio - - // now done by UBloxGPS.cpp - // setGPSPower(false); + axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); // LORA radio } #endif