Skip to content

Add aggressive Nightscout polling after remote commands#566

Open
bjorkert wants to merge 1 commit intodevfrom
feature/remote-command-polling
Open

Add aggressive Nightscout polling after remote commands#566
bjorkert wants to merge 1 commit intodevfrom
feature/remote-command-polling

Conversation

@bjorkert
Copy link
Contributor

Summary

  • After a remote command (bolus, carbs, override, temp target) succeeds, poll Nightscout every 3s for up to 30s so the result appears on the main screen quickly
  • Polling stops early once fresh data matching the command type is detected
  • All remote command paths (Loop APNS, TRC, Trio Nightscout) post a remoteCommandSucceeded notification on success

Extracted from #558 to keep that PR focused on units/metrics.

After a remote command (bolus, carbs, override, temp target) succeeds,
poll Nightscout every 3 seconds for up to 30 seconds to quickly reflect
the command on the main screen. Polling stops early when fresh data
matching the command type is detected.
@bjorkert
Copy link
Contributor Author

Instead of starting to poll when the command is sent, I think we should start when we get confirmation that Loop/Trio received and acted on it, there can be a delay between those two points. We should in that case post remoteCommandSucceeded from userNotificationCenter(_:willPresent:).

This also naturally limits polling to when the app is in the foreground — if the user has already left the app, polling isn't needed.

This would also let us remove all the individual NotificationCenter.default.post(name: .remoteCommandSucceeded) calls from the remote command views, simplifying the code.

The only incoming notifications are confirmation and failure notifications, we can improve this in the future, classifying them somehow, but even if we start poll on a fail we would show the gray dot faster.

Should we do evaluateRemoteCommandPollingCompletion in devicestatus? All commands are treatments, should not that be enough?

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

Successfully merging this pull request may close these issues.

2 participants