Add auto notification setting

Alllow to automaticatilly send notification when device is online
This commit is contained in:
Luc
2019-09-08 10:48:28 +02:00
parent 46f2d27a7b
commit 7b2d4612df
6 changed files with 47 additions and 3 deletions

View File

@@ -92,9 +92,22 @@ bool Wait4Answer(TSecureClient & client, const char * linetrigger, const char *
return false;
}
bool NotificationsService::sendAutoNotification(const char * msg)
{
if ((WiFi.getMode() == WIFI_AP) || (!_started) || (!_autonotification))return false;
String msgtpl = msg;
//check if has variable to change
if (msgtpl.indexOf("%") != -1) {
msgtpl.replace("%ESP_IP%", WiFi.localIP().toString().c_str());
msgtpl.replace("%ESP_NAME%", wifi_config.get_hostname());
}
return sendMSG("ESP3D Notification", msgtpl.c_str());
}
NotificationsService::NotificationsService()
{
_started = false;
_autonotification = false;
_notificationType = 0;
_token1 = "";
_token1 = "";
@@ -411,7 +424,9 @@ bool NotificationsService::begin()
return false;
break;
}
if (CONFIG::read_byte (ESP_NOTIFICATION_TYPE, &bbuf ) ) {
_autonotification = (bbuf == 0) ? false: true;
}
if (!res) {
end();
}