Page 1 of 1

Send Alert Function

Posted: Fri Jun 05, 2015 9:24 am
by rrodriguess
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);
}

Re: Send Alert Function

Posted: Fri Jun 05, 2015 10:37 am
by rimai
I think this feature is already built into the WifiAlert class.

Re: Send Alert Function

Posted: Fri Jun 05, 2015 11:07 am
by rrodriguess
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