From 250b5b3371aafa08d7828eac94dbfb376bcb8d69 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Fri, 3 Aug 2018 18:38:24 +1200 Subject: [PATCH] Added SMS send code to core::notifyFailures --- GpsTracker/Core.cpp | 7 ++++++- GpsTracker/Network.cpp | 1 - GpsTracker/Network.h | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/GpsTracker/Core.cpp b/GpsTracker/Core.cpp index 3c0ee03..48ae3b4 100644 --- a/GpsTracker/Core.cpp +++ b/GpsTracker/Core.cpp @@ -57,7 +57,12 @@ namespace core { sprintf_P(buffer + strlen(buffer), PSTR(" - Temperature is %.2f°C. Backup battery failure ?\n"), metadata.batteryLevel); } - //TODO : send sms, return if failed + config_t* config = &config::main::value; + if (!network::sendSms(config->contactPhone, buffer)) { + NOTICE_MSG("notifyFailure", "SMS not sent !"); + return; + } + alerts::add(notified); //only add the successly notified failures //TODO : network::powerOff(); count "handles" like for i2c ? } diff --git a/GpsTracker/Network.cpp b/GpsTracker/Network.cpp index fb9e6a3..3073ca7 100644 --- a/GpsTracker/Network.cpp +++ b/GpsTracker/Network.cpp @@ -63,5 +63,4 @@ namespace network { bool enableGprs() { return hardware::sim808::device.enableGprs(config::main::value.network.apn); } - } \ No newline at end of file diff --git a/GpsTracker/Network.h b/GpsTracker/Network.h index a704004..1f6e8af 100644 --- a/GpsTracker/Network.h +++ b/GpsTracker/Network.h @@ -10,4 +10,8 @@ namespace network { SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true); bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); bool enableGprs(); + + inline bool sendSms(const char * phoneNumber, const char * msg) { + return hardware::sim808::device.sendSms(phoneNumber, msg); + } } \ No newline at end of file