private void CheckForMissingReading() { Log.Debug(Logging.WatchdogTag, "DT1WatchdogService checking for missing reading"); var latesValidReading = DT1WatchdogData.GetLatestValidReading(); if (latesValidReading != null) { var timeSinceLastValidReading = DateTimeOffset.UtcNow - latesValidReading.ScanTime; if (timeSinceLastValidReading.TotalMinutes > MissingReadingTimeoutMinutes) { // disconnect everything to go again if (Gatt != null) { Gatt.Close(); Gatt = null; } StartScan(); var additionalInfo = String.Format( Resources.GetString(Resource.String.MissingReadingFormatMinutes), timeSinceLastValidReading.TotalMinutes.ToString("0.00")); TriggerAlert(AlertType.MissingReading, additionalInfo, true); } } }
private static void ClearAlert() { DT1WatchdogData.ClearAlert(); if (dt1WatchdogAudioAlert != null && dt1WatchdogAudioAlert.IsPlaying) { dt1WatchdogAudioAlert.Pause(); } ExitAlertMode(); }
public void TriggerAlert(AlertType alertType, String optionalText, bool isConditional) { var alertText = alertType.ToString(); if (!string.IsNullOrEmpty(optionalText)) { alertText = alertText + System.Environment.NewLine + optionalText; } DT1WatchdogData.SetAlert(alertText); if ((!isConditional) || (DT1WatchdogData.MuteAlertTimeout <= DateTimeOffset.UtcNow)) { EnterAlertMode(); switch (DT1WatchdogData.AlertNotificationType) { case DT1WatchdogData.AlertNotification.SMSAlert: { if (!string.IsNullOrEmpty(DT1WatchdogData.SMSAlertContact)) { SmsManager.Default.SendTextMessage(DT1WatchdogData.SMSAlertContact, null, alertText, null, null); if (!isConditional) { // non conditional trigger audio also dt1WatchdogAudioAlert.Start(); } } else { // fallback trigger audio alert dt1WatchdogAudioAlert.Start(); } break; } case DT1WatchdogData.AlertNotification.AudioAlert: { dt1WatchdogAudioAlert.Start(); break; } } } }