Do you have a question on how to do something.
Ask in here.
rrodriguess
Posts: 132 Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil
Post
by rrodriguess » Fri Jun 05, 2015 9:24 am
Hi everyone
Does anyone know why this code does not work? I wanna compare the current alert with the last sent alert, avoiding that the same alert to be sent multiple times.
Code: Select all
void sendAlert(char alertMessage[100]){
static WiFiAlert t;
static char lastAlertSent[100];
t.SetDelay(0);
if(strcmp(alertMessage,lastAlertSent)!=0) t.Send(alertMessage, true);
strcpy(lastAlertSent,alertMessage);
}
rimai
Posts: 12857 Joined: Fri Mar 18, 2011 6:47 pm
Post
by rimai » Fri Jun 05, 2015 10:37 am
I think this feature is already built into the WifiAlert class.
Roberto.
rrodriguess
Posts: 132 Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil
Post
by rrodriguess » Fri Jun 05, 2015 11:07 am
Hi Roberto
I think we are talking about two different things.
To make myself clear, suppose I want to add this line in loop():
Code: Select all
if(ReefAngel.Params.PH > 680)
sendAlert("-Warning:+Ph+too+high");
I know that can be done by something like:
Code: Select all
static boolean firstRun=true;
if(firstRun && ReefAngel.Params.PH > 680){
firstRun=false;
sendAlert("-Warning:+Ph+too+high");
}
I thought about the sendAlert function to avoid treating every case.
Rafa