-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPS Power State tidy-up #4161
base: master
Are you sure you want to change the base?
GPS Power State tidy-up #4161
Conversation
Just built an ran your code, there is a corner case that you need to address, that is when the GPS is asleep and you use the user button to put the esp32 into deep sleep, the GPS wakes up and stay's awake while the esp32 is in deep sleep. |
Perfect! I imagine there's a whole bunch of little things like this, so the more we can spot, the better! Did you notice if we still need to try hold the TX line high or anything too (something we discussed in the old PR, right?), or is this fix enough to keep the GPS asleep? Getting that PMREQ for deep-sleep was one of the key things we needed to sort with all this, so I'm glad it might be this easy to solve. I think maybe we can tie this into a nice high level |
Still testing, I noticed a few oddities with your code when the Update Interval was <= 10 sec. and I have not tested it with anything other than an esp32. I believe that the Tx line to the GPS needs to be held high. My mod did NOT do that, but I think it needs to be, more testing will tell. |
I'll definitely check those short update intervals tomorrow too. More than anything, I just wanted to make this WIP visible, even though it's still early days (or might get shelved, if there's reason to go in a different direction) |
Yeah, this whole GPS sleep/awake/idle/etc is very complicated, esp WRT the quality of the fix the GPS has. My use case is in may ways too simple in that the GPS is on all the time and gets a really good fix, Other use cases with power consumption as their primary goal suffer poor GPS fix quality and long acquisition times. |
I have to run off to DayJob... BBL (I hope) |
Keen to try fix it, but I can't spot anything super obvious just from the log of my T-Beam V1.2, with a 10 second update interval. What exactly are you seeing? Edit: actually, there might be some stuff happening when moving between "idle" and "active" which is at best unnecessary. I'll remove it and we'll see if that makes anything better (or worse) |
Your latest gps-refactor branch still has the problem if the GPS is asleep when you ask for a DeePSleep, that the GPS doesn't wake up to get the PMREQ with duration 0. The earlier problem I was seeing was that you were not sending a PMREQ with duration 0 at all when DeepSleep was requested. |
Oh yes, no, sorry, I should have been clear: I haven't changed anything yet. I just merged upstream ready to work on it, then paused because I wasn't sure exactly what needed doing. I'll make an attempt at both issues and then let you know here. |
@GPSFan Hoping I've got both of those issues sorted now. They seem to be fixed now with my test node, but let me know if I've missed them again. |
@todd-herbert That seems to work, except you are not waiting long enough for the GPS to wake up after sending the 0xff. I increased the delay from 100 to 500 and that seems to give my M8N enough time to wake up. This is tested on an esp32, I'll try it on my RAK later today. |
Hmm, sounds like it does need the full 500ms then, we'll definitely use that. 100ms was long enough on the ESP32 + Neo-6M(?) I was testing with, so I had hoped that maybe you just threw out that 500ms as a ballpark figure. But nope apparently not! No big deal, I just get a bit squeamish adding longer delays. Only place this one will ever come up outside of shutdown is when the user-button is triple pressed to disable GPS, but that happens so rarely there's probably no reason to worry about it impacting LoRa RX |
Specifically the standby pin for L76B, L76K and clones Discovered during T-Echo testing: totally broken function, probe method failing.
Now handled by setPowerState
Avoid those platform specific implementations..
New round of settings.json changes keep catching me out, have to remember to re-enable my "clang-format" for windows workaround.
Original aim was to prevent sending a 0 second PMREQ to U-blox hardware as part of a timed sleep (GPS_HARDSLEEP, GPS_SOFTSLEEP). I'm not sure this is super important, and it feels tidier to just allow the 0 second sleeptime here, rather than fudge the sleeptime further up.
(No significant behavior changes, just tying up loose ends) |
Haven't tested your new code yet, but I agree that we should wrap up this issue/PR. |
I think that would fit quite nicely with a Firmware Creation Tool, if / when that gets off the ground.
Ah there was no big issue there, just that the accidentally inverted standby pin logic was totally disrupting the affected hardware, so much that they failed the probe. As soon as HIGH / LOW was swapped, it all came right.
Definitely no more intended work on this, but I'd definitely like to make sure we merge this early in a release cycle, just because there's such an opportunity for little corner-case bugs to pop up. I'm not sure if 2.3.15 alpha is creeping up already, or if we're still a good distance off. One thing I'd like to test myself for a day or two is T-Echo battery life. I don't think the device has any hardware switching for the GPS, other that the "standby pin", and I'm pretty sure improper GPS config is know to cause issues, so I'd like to give it a bit more of a run first. Update: tested, fixed. Other than that, if you're happy that everything is still performing correctly after this tidy up, let me know and we'll mark this ready for review. |
Just got to test the latest, something isn't right (or the same as it used to be) with Update intervals <= 10 sec's. |
Sorry about that! I definitely didn't expect any of these latest commits to impact anything like that. Glad you caught something weird before it was too late! My ignorance is showing again here: exactly what were you seeing before, and what aren't you seeing now? I do see |
bisect finished, there seems to be a state that the GPS (M8N, maybe it;s only mine) can get in that it is not producing time pulses and not behaving at all like it normally does. This may have been a red herring. as I'm back to your current gpe-refactor head and things seem normal. |
Are you switching power with |
No, This config doesn't switch power at all, Vcc is there at all times. I haven't been able to reproduce the issue. But it was wierd as I was getting NMEA data out as if it were locked on and working but no time pulse. it said it had 8 sats, but that didn't change over time. once I went back to an earlier version and disconnected the antenna for a while it came back to "normal" operation, and 12 sats. Then when I went to a later version it was ok, then I went to the latest and it was still ok, and varying from 9 to 12 sats. |
Just for my understanding, are you talking about the time pulse signal from one of the hardware pins? |
the GPS breakout board I have for the M8N has an LED on the time pulse output when it flashes I know it is locked. |
Required to reach TTGO's advertised 0.25mA sleep current for T-Echo. Without this change: ~6mA.
t-beam seem to be behaving normally, I'm going to chalk that up to random weirdness... |
I do think it seems like a good idea, but it actually hadn't crossed my mind to change it here. I don't actually have that device to test, so I was hoping someone else would pick up the issue and try it out. I think @geeksville has plans to implement a SharedGPIO class which will specifically impact that VExt pin for Wireless Tracker V1.1, so might actually be convenient to roll it in when implementing that. |
SummaryIntention: to simplify GPS power management, to aid future maintenance (hopefully)
Even if everything looks good, might be wise to hold off merging this one until right at the start of a release cycle, in case any sneaky bugs slip through. |
Let's defer to @geeksville for the Tracker & SharedIO stuff. |
At first glance, looks great. I'll try to do some testing as well. |
In #4070 I said I'd follow up and have a go at tidying the GPS class, with the intention of then hunting down a bug affecting U-blox standby. I'm not at all confident working with GPS hardware, so this submission is a rough first draft. Seeking feedback / contribution / testing!
Initial intentions:
GPSPowerState
enumObservable
up()
,down()
methodsUpdate:
See #4161 (comment) for latest summary