diff --git a/source/ErrorView.mc b/source/ErrorView.mc index 13d08e8..2f8eea0 100644 --- a/source/ErrorView.mc +++ b/source/ErrorView.mc @@ -137,7 +137,7 @@ class ErrorView extends ScalableView { // The call to 'updateMenuItems()' must be on another thread so that the view is popped above. var myTimer = new Timer.Timer(); // Now this feels very "closely coupled" to the application, but it is the most reliable method instead of using a timer. - myTimer.start(getApp().method(:updateMenuItems), Globals.scApiResume, false); + myTimer.start(getApp().method(:updateMenuItems), Globals.scApiResumeMs, false); // This must be last to avoid a race condition with show(), where the // ErrorView can't be dismissed. mShown = false; diff --git a/source/Globals.mc b/source/Globals.mc index e383ad4..65f6574 100644 --- a/source/Globals.mc +++ b/source/Globals.mc @@ -21,28 +21,32 @@ using Toybox.Lang; class Globals { //! Alert is a toast at the top of the watch screen, it stays present until tapped //! or this timeout has expired. - static const scAlertTimeout = 2000; // ms + static const scAlertTimeoutMs = 2000; // ms //! Time to let the existing HTTP responses get serviced after a //! `Communications.NETWORK_RESPONSE_OUT_OF_MEMORY` response code. - static const scApiBackoff = 2000; // ms + static const scApiBackoffMs = 2000; // ms //! Needs to be long enough to enable a "double ESC" to quit the application from //! an ErrorView. - static const scApiResume = 200; // ms + static const scApiResumeMs = 200; // ms //! Warn the user after fetching the menu if their watch is low on memory before the device crashes. - static const scLowMem = 0.90; // percent as a fraction. + static const scLowMem = 0.90; // percent as a fraction. //! Constant for PIN confirmation dialog.
//! Maximum number of failed PIN confirmation attempts allowed in `scPinMaxFailureMinutes`. - static const scPinMaxFailures = 5; + static const scPinMaxFailures = 5; //! Constant for PIN confirmation dialog.
//! Period in minutes during which no more than `scPinMaxFailures` PIN attempts are tolerated. - static const scPinMaxFailureMinutes = 2; + static const scPinMaxFailureMinutes = 2; //! Constant for PIN confirmation dialog.
//! Lock out time in minutes after a failed PIN entry. - static const scPinLockTimeMinutes = 10; + static const scPinLockTimeMinutes = 10; + + //! After running a task by Wi-Fi/LTE synchronisation the periodic updates need to resume. This + //! is the delay between synchronisation completion and resumption of updates. + static const wifiPollResumeDelayMs = 2000; // ms } diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index 14a88e9..985241b 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -42,8 +42,6 @@ class HomeAssistantApp extends Application.AppBase { private var mTemplates as Lang.Dictionary = {}; private var mNotifiedNoBle as Lang.Boolean = false; - private const wifiPollDelayMs = 2000; - //! Class Constructor // function initialize() { @@ -385,7 +383,7 @@ class HomeAssistantApp extends Application.AppBase { // System.println("HomeAssistantApp onReturnUpdateMenuItems() Response Code: NETWORK_RESPONSE_OUT_OF_MEMORY, are we going too fast?"); var myTimer = new Timer.Timer(); // Now this feels very "closely coupled" to the application, but it is the most reliable method instead of using a timer. - myTimer.start(method(:updateMenuItems), Globals.scApiBackoff, false); + myTimer.start(method(:updateMenuItems), Globals.scApiBackoffMs, false); // Revert status status = getApiStatus(); break; @@ -447,7 +445,7 @@ class HomeAssistantApp extends Application.AppBase { WatchUi.showToast(toast, null); } else { new Alert({ - :timeout => Globals.scAlertTimeout, + :timeout => Globals.scAlertTimeoutMs, :font => Graphics.FONT_MEDIUM, :text => toast, :fgcolor => Graphics.COLOR_WHITE, @@ -458,7 +456,7 @@ class HomeAssistantApp extends Application.AppBase { mNotifiedNoBle = true; setApiStatus(WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String); - mUpdateTimer.start(method(:startUpdates), wifiPollDelayMs, false); + mUpdateTimer.start(method(:startUpdates), Globals.wifiPollResumeDelayMs, false); mUpdating = false; return; @@ -807,7 +805,7 @@ class HomeAssistantApp extends Application.AppBase { Settings.update(); updateStatus(); mGlanceTimer = new Timer.Timer(); - mGlanceTimer.start(method(:updateStatus), Globals.scApiBackoff, true); + mGlanceTimer.start(method(:updateStatus), Globals.scApiBackoffMs, true); return [new HomeAssistantGlanceView(self)]; } diff --git a/source/HomeAssistantService.mc b/source/HomeAssistantService.mc index 4c350bb..6e14882 100644 --- a/source/HomeAssistantService.mc +++ b/source/HomeAssistantService.mc @@ -100,7 +100,7 @@ class HomeAssistantService { WatchUi.showToast(toast, null); } else { new Alert({ - :timeout => Globals.scAlertTimeout, + :timeout => Globals.scAlertTimeoutMs, :font => Graphics.FONT_MEDIUM, :text => toast, :fgcolor => Graphics.COLOR_WHITE, diff --git a/source/WifiLteExecutionConfirmDelegate.mc b/source/WifiLteExecutionConfirmDelegate.mc index 93cd7e1..0cae605 100644 --- a/source/WifiLteExecutionConfirmDelegate.mc +++ b/source/WifiLteExecutionConfirmDelegate.mc @@ -136,7 +136,7 @@ class WifiLteExecutionConfirmDelegate extends WatchUi.ConfirmationDelegate { WatchUi.showToast(toast, null); } else { new Alert({ - :timeout => Globals.scAlertTimeout, + :timeout => Globals.scAlertTimeoutMs, :font => Graphics.FONT_MEDIUM, :text => toast, :fgcolor => Graphics.COLOR_WHITE,