From 0d68f8766d7183873dd839e03175e42671146f78 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Mon, 6 Aug 2018 17:44:31 +1200 Subject: [PATCH] Display alerts on Serial when available to avoid SMS costs while debugging --- Config.h | 20 ++++++++++++++------ Core.cpp | 10 ++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Config.h b/Config.h index 5171454..d509e69 100644 --- a/Config.h +++ b/Config.h @@ -15,11 +15,6 @@ #define CONFIG_RESERVED_SIZE 128 #define CONFIG_SEED 13 #define VERSION "1.10" -#define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1 45 -#define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2 38 -#define CONFIG_DEFAULT_BATTERY_ALERT_CLEAR 60 -#define CONFIG_DEFAULT_ACTIVE_ALERTS 0 -#define CONFIG_DEFAULT_CONTACT_PHONE "+642568452" #define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes @@ -31,8 +26,15 @@ Hard coded value for default sleep time between position acquisitions. Exprimed in seconds */ + +#define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1 45 +#define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2 38 +#define CONFIG_DEFAULT_BATTERY_ALERT_CLEAR 60 +#define CONFIG_DEFAULT_ACTIVE_ALERTS 0 +#define CONFIG_DEFAULT_CONTACT_PHONE "+642568452" + #define SLEEP_DEFAULT_TIME_SECONDS 1800 -#define SLEEP_DEFAULT_STOPPED_THRESHOLD 5 +#define SLEEP_DEFAULT_STOPPED_THRESHOLD 5 #define SLEEP_DEFAULT_PAUSING_TIME_SECONDS 270 #define SLEEP_TIMING_MIN SLEEP_TIMING_TIME(0, 0) @@ -48,6 +50,12 @@ #define NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD 8 #define NETWORK_DEFAULT_NO_NETWORK_TRIES 5 +#define ALERTS_ON_SERIAL_IF_AVAILABLE 1 +/** + \def ALERTS_ON_SERIAL_IF_AVAILABLE + Display alerts on serial when connected rather than sending an SMS. + Useful for debugging purpose and avoid costs related to SMS sending. +*/ #define ALERT_SUSPICIOUS_RTC_TEMPERATURE 0 #pragma endregion diff --git a/Core.cpp b/Core.cpp index 591c175..8424f64 100644 --- a/Core.cpp +++ b/Core.cpp @@ -80,7 +80,17 @@ namespace core { details::appendToSmsBuffer(buffer, PSTR("\n- RTC was stopped.%S"), backupFailureString); } +#if ALERTS_ON_SERIAL_IF_AVAILABLE + if(Serial) { + NOTICE_FORMAT("notifyFailure", "%s", buffer); + notified = true; + } + else { +#endif notified = network::sendSms(buffer); +#if ALERTS_ON_SERIAL_IF_AVAILABLE + } +#endif if (!notified) NOTICE_MSG("notifyFailure", "SMS not sent !"); }