Open osa1 opened 2 years ago
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
)
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.
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.