HomeWaterLeaksDetection
|
#include <EmailSender.h>
Public Types | |
enum | Type { BOOTING, DAILY_OVERVIEW, LEAK_DETECTED, VALVE_STATE, RESET, ALARM, CHANGED_SETTINGS, APPLIED_NEW_SETTING, BYPASS, COUNT = 9 } |
different types of e-mail that can be sent to the user More... | |
Public Member Functions | |
void | sendEmail (Type type, String subject, String data) |
Sends an e-mail to the smtp2go server. More... | |
void | enableNotification (Type type, bool state) |
Enables/disables the particular type of e-mail notification. More... | |
void | setReceiverEmailAddress (String email) |
Changes the user's e-mail address. More... | |
String | getFormatOfSettingsToSave () |
Returns settings. More... | |
const String | getHTMLData (const int id) const |
Since this class is registered as a source of data for the HTML content, it needs return the appropriate value according to the id given as a parameter. More... | |
Static Public Member Functions | |
static EmailSender * | getInstance () |
Returns the instance of the class. More... | |
Private Member Functions | |
EmailSender () | |
Constructor of the class. More... | |
~EmailSender () | |
Descrutor of the class. More... | |
EmailSender (EmailSender const &) | |
Copy constructor of the class. More... | |
EmailSender & | operator= (EmailSender const &) |
Assignmet operator of the class. More... | |
int | setEthernet () |
Initializes the ethernet shield. More... | |
byte | eRcv () |
Reads data using the ethernet client comming from the smtp2go server. More... | |
void | efail () |
Closes the ethernet client after the connection has failed. More... | |
byte | sendEmail (String subject, String data) |
Sends an e-mail off to the smtp2go server. More... | |
Private Attributes | |
std::map< Type, bool > | enabled |
map holding info about each time of e-mail - whether it's enabled or not More... | |
EthernetClient | client |
EthernetClient used to connect to the smt2go server. More... | |
byte | mac [6] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 } |
mac address of the ethernet shield More... | |
String | receiverEmailAddress = "jakub.sil@seznam.cz" |
the default user's email address More... | |
std::map< int, String(*)(const EmailSender &leaksController)> | htmlData |
A map of different values (keys) and their associated functions which returns the appropriate values. More... | |
Static Private Attributes | |
static EmailSender * | instance = NULL |
the instance of EmailSender More... | |
Friends | |
String | HTML_Notification_BOOTING (const EmailSender &emailSender) |
Associated function for returing the state of the 'bootup' notification. More... | |
String | HTML_Notification_DAILY_OVERVIEW (const EmailSender &emailSender) |
Associated function for returing the state of the 'daily overview' notification. More... | |
String | HTML_Notification_LEAK_DETECTED (const EmailSender &emailSender) |
Associated function for returing the state of the 'leak detected' notification. More... | |
String | HTML_Notification_VALVE_STATE (const EmailSender &emailSender) |
Associated function for returing the state of the 'valve state' notification. More... | |
String | HTML_Notification_RESET (const EmailSender &emailSender) |
Associated function for returing the state of the 'system reset' notification. More... | |
String | HTML_Notification_ALARM (const EmailSender &emailSender) |
Associated function for returing the state of the 'home alarm state' notification. More... | |
String | HTML_Notification_CHANGED_SETTINGS (const EmailSender &emailSender) |
Associated function for returing the state of the 'changed settings' notification. More... | |
String | HTML_Notification_APPLIED_NEW_SETTING (const EmailSender &emailSender) |
Associated function for returing the state of the 'applied settings' notification. More... | |
String | HTML_Notification_BYPASS (const EmailSender &emailSender) |
Associated function for returing the state of the 'bypass state' notification. More... | |
String | HTML_ReceiverEmailAddress (const EmailSender &emailSender) |
Associated function for returing the user's e-mail address. More... | |
Additional Inherited Members | |
![]() | |
static const String | UNDEFINED_DATA = String("UNDEFINED") |
string "UNDEFINED" More... | |
This calass is designed as a Singleton and is used for sending e-mails to the user.
Definition at line 35 of file EmailSender.h.
enum EmailSender::Type |
different types of e-mail that can be sent to the user
Definition at line 44 of file EmailSender.h.
|
private |
Constructor of the class.
Definition at line 47 of file EmailSender.cpp.
References ALARM, APPLIED_NEW_SETTING, BOOTING, BYPASS, CHANGED_SETTINGS, DAILY_OVERVIEW, enabled, HTML_Notification_ALARM, HTML_Notification_APPLIED_NEW_SETTING, HTML_Notification_BOOTING, HTML_Notification_BYPASS, HTML_Notification_CHANGED_SETTINGS, HTML_Notification_DAILY_OVERVIEW, HTML_Notification_LEAK_DETECTED, HTML_Notification_RESET, HTML_Notification_VALVE_STATE, HTML_ReceiverEmailAddress, htmlData, LEAK_DETECTED, RESET, setEthernet(), and VALVE_STATE.
Referenced by getInstance().
|
private |
Descrutor of the class.
|
inlineprivate |
|
private |
Closes the ethernet client after the connection has failed.
Definition at line 223 of file EmailSender.cpp.
References client.
Referenced by eRcv().
void EmailSender::enableNotification | ( | Type | type, |
bool | state | ||
) |
Enables/disables the particular type of e-mail notification.
type | of e-mail notification |
state | true/false - enable/disable |
Definition at line 43 of file EmailSender.cpp.
References enabled.
Referenced by setSettingsNotification().
|
private |
Reads data using the ethernet client comming from the smtp2go server.
Definition at line 192 of file EmailSender.cpp.
References client, and efail().
Referenced by sendEmail().
String EmailSender::getFormatOfSettingsToSave | ( | ) |
Returns settings.
It returns the user's e-mail address as well as information about which e-mail notifications are enabled/disabled so they can be stored on the SD card.
Definition at line 248 of file EmailSender.cpp.
References ALARM, APPLIED_NEW_SETTING, BOOTING, BYPASS, CHANGED_SETTINGS, DAILY_OVERVIEW, enabled, LEAK_DETECTED, receiverEmailAddress, RESET, and VALVE_STATE.
Referenced by WebServer::saveSettings().
|
virtual |
Since this class is registered as a source of data for the HTML content, it needs return the appropriate value according to the id given as a parameter.
id | - the id of the piece of data |
Implements HTMLDataSource.
|
static |
Returns the instance of the class.
Definition at line 87 of file EmailSender.cpp.
References EmailSender(), and instance.
Referenced by WebServer::saveSettings(), setSettingsNotification(), setup(), LowLeakDetection::update(), HighLeakDetection::update(), DailyOverview::update(), and LeaksController::update().
|
inlineprivate |
|
private |
Sends an e-mail off to the smtp2go server.
subject | of the e-mail |
data | content of the e-mail |
Definition at line 93 of file EmailSender.cpp.
References arduinoIP, auth64Login, auth64Pass, client, emailAddress, eRcv(), receiverEmailAddress, SMTPServerAddress, and SMTPServerPort.
Referenced by sendEmail(), setup(), LowLeakDetection::update(), HighLeakDetection::update(), DailyOverview::update(), and LeaksController::update().
void EmailSender::sendEmail | ( | Type | type, |
String | subject, | ||
String | data | ||
) |
Sends an e-mail to the smtp2go server.
type | of the e-mail |
subject | of the e-mail |
data | content of the e-mail |
Definition at line 78 of file EmailSender.cpp.
References enabled, and sendEmail().
|
private |
Initializes the ethernet shield.
This method initializes the the ethernet shield only if it has not been initialized yet.
Definition at line 18 of file EmailSender.cpp.
References mac, SS_ETHERNET, and SS_SD_CARD.
Referenced by EmailSender().
void EmailSender::setReceiverEmailAddress | ( | String | ) |
Changes the user's e-mail address.
the new e-mail address all e-mails will be sent to |
Definition at line 83 of file EmailSender.cpp.
References receiverEmailAddress.
Referenced by setSettingsNotification().
|
friend |
Associated function for returing the state of the 'home alarm state' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'applied settings' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'bootup' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'bypass state' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'changed settings' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'daily overview' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'leak detected' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'system reset' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the state of the 'valve state' notification.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
friend |
Associated function for returing the user's e-mail address.
emailSender | - the instance of the EmailSender class |
Referenced by EmailSender().
|
private |
EthernetClient used to connect to the smt2go server.
Definition at line 62 of file EmailSender.h.
Referenced by efail(), eRcv(), and sendEmail().
|
private |
map holding info about each time of e-mail - whether it's enabled or not
Definition at line 60 of file EmailSender.h.
Referenced by EmailSender(), enableNotification(), getFormatOfSettingsToSave(), and sendEmail().
|
private |
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition at line 139 of file EmailSender.h.
Referenced by EmailSender().
|
staticprivate |
the instance of EmailSender
Definition at line 61 of file EmailSender.h.
Referenced by getInstance().
|
private |
mac address of the ethernet shield
Definition at line 64 of file EmailSender.h.
Referenced by setEthernet().
|
private |
the default user's email address
Definition at line 65 of file EmailSender.h.
Referenced by getFormatOfSettingsToSave(), sendEmail(), and setReceiverEmailAddress().