nightscout / Trio

MIT License
45 stars 125 forks source link

[feature request] - Add silent playback to pump simulator to allow operation in the background for testing and development #276

Open bjornoleh opened 4 weeks ago

bjornoleh commented 4 weeks ago

Is your feature request related to a problem? Please describe.

Currently, testing in simulation on a real phone is a little awkward, since simulator pump and CGM sources such as the simulator CGM or NS does not provide a "heartbeat" to keep the app awake in the background. Hence, looping stops within seconds from closing the app / turning off the screen. The screen must be kept on to allow looping to proceed.

Describe the solution you'd like

The DanaKit implementation by @bastiaanv has an option to enable silent mp3 playback to work around the limitations on background operation imposed by Apple. This is a well known trick from CGM follower apps like Loop Follow, xDrip4iOS and Spike.

I would like to see this added (as an option?) for the pump simulator. Then it would be possible to do many types of testing and development on a physical phone device without the current limitation on background use.

The additional battery drain should be no issue for this use case, as it is only needed occasionally, and typically on a spare phone.

Describe alternatives you've considered

Alternatives include keeping the screen on, which also need a charger to be plugged in for extended testing. Or physical BT devices such as a spare G6 transmitter, which is costly and impractical (somewhat improved if having access to an Anubis simulator).

Additional context

Background silent playback could possibly be added as a general feature for all pumps, as this would allow the use of CGM sources without BT heartbeat, when the pump does not provide a reliable heartbeat (Dana, Dash, possibly others) (internet dependent CGM solutions included, although that isn't ideal).

bastiaanv commented 4 weeks ago

Another alternative for this (although it is untested and only a theory) is to use the GPS of the phone.

The biggest problem with the silent tones is the battery consumption. Normally iAPS (or any other) would use around the 15% battery per day on my phone (iphone 11), but when silent tones are enabled the battery consumption is 50% per day. When an increase is to be expected, maybe the GPS uses less battery.

Just an idea or something to look into

dsut4392 commented 4 weeks ago

I believe GPS is quite power hungry. My reason for thinking this is that on back-country trips when we already have the phone in flight mode (because there is no network availability), turning off location services in Photos app results in a significant increase in battery life.

LiroyvH commented 4 weeks ago

The SSH app "Shelly" deploys the GPS-method. I'm not sure if it asks an exact location (which might use more power) or just asks for system location. I don't think it drains more, but then again I haven't had Shelly run in the background for 24 hours... I guess I could give it a spin and keep a connection to a server open to see what it does in terms of power consumption. Or ask the dev, maybe he knows.

aug0211 commented 3 weeks ago

Another option we could consider adding is using an OrangeLink or similar as a heartbeat.

xDrip4iO5 supports this method and it consumes significantly less battery than silent audio.

And many devs will have an OL or similar.

bjornoleh commented 2 weeks ago

The SSH app "Shelly" deploys the GPS-method. I'm not sure if it asks an exact location (which might use more power) or just asks for system location. I don't think it drains more, but then again I haven't had Shelly run in the background for 24 hours... I guess I could give it a spin and keep a connection to a server open to see what it does in terms of power consumption. Or ask the dev, maybe he knows.

That's interesting. Did you get to try this with Shelly?

LiroyvH commented 2 weeks ago

@bjornoleh Haven't tested it for more than a few minutes yet (which works perfectly fine and keeps the connection to the server established np), but I'll try and keep it running for a bit longer; also see what it does to battery usage.

Btw, am I to understand that the Dana doesn't have a heartbeat of its own? (And thus it must be driven by the CGM heartbeat (eg: when using another app than Dexcom, Trio will likely start getting killed?)).

LiroyvH commented 2 weeks ago

@bjornoleh It keeps running for a while but eventually the connection is lost. I'm not sure if that's because the app feels it has timed-out or because the app is suspended. Can't really see the difference. So I think we'd have to test this. It has potential as it does keep running for (so far) 20 minutes or so and never loses the SSH connection, but I can't keep it running forever.

aug0211 commented 1 week ago

Would implementing a heartbeat function, like xDrip uses, help?

Things like a recently discarded CGM, RileyLink, OrangeLink, etc. could provide a heartbeat.

I can see a potential future world where this functionality could also provide useful for uses as well (potential caregiver mode, way down the road).