Skip to content
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

Optimize session renewals #3

Open
osa1 opened this issue Jul 28, 2022 · 2 comments
Open

Optimize session renewals #3

osa1 opened this issue Jul 28, 2022 · 2 comments

Comments

@osa1
Copy link
Owner

osa1 commented Jul 28, 2022

I think sessions get invalid after 24 hours. We should add a debug log (it should print the time) when we got an invalid session. After a few days we should be able to look at the logs and figure out the exact lifetime of a session.

Once we know the session lifetime for sure, we can store the last login time, and when the time between the next request and the last session renewal is more than the lifetime we login again instead of trying to read the bg data.

@osa1
Copy link
Owner Author

osa1 commented Jul 29, 2024

I think it should be possible to renew the session directly, instead of in the background service. That should avoid 5 minute delay to get the session id.

https://developer.garmin.com/connect-iq/core-topics/https/ doesn't mention any restrictions on where the request can be done, I think we can do it anywhere not just in the bg service. (ServiceDelegate)

@osa1
Copy link
Owner Author

osa1 commented Jul 29, 2024

It looks like I can't call makeWebRequest in AppBase:

Error: Permission Required
Details: Module 'Toybox.Communications' not available to 'Watch Face'
Stack:
  - getDexcomSessionId() at /home/omer/Dextrack/source/DextrackApp.mc:45 0x1000005c
  - onStart() at /home/omer/Dextrack/source/DextrackApp.mc:23 0x10000106

or in WatchFace:

Error: Permission Required
Details: Module 'Toybox.Communications' not available to 'Watch Face'
Stack:
  - getDexcomSessionId() at /home/omer/Dextrack/source/DextrackWatchFace.mc:31 0x10001f53
  - initialize() at /home/omer/Dextrack/source/DextrackWatchFace.mc:27 0x10002224
  - getInitialView() at /home/omer/Dextrack/source/DextrackApp.mc:34 0x100000a8
Encountered an app crash.

I will now try to make a request in a request response callback. If that works, we can login + get data in the same temporal event callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant