mirror of
https://github.com/luc-github/ESP3D.git
synced 2025-10-31 11:56:48 -07:00
Add auto notification setting
Alllow to automaticatilly send notification when device is online
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user