Send Alert Function

Do you have a question on how to do something.
Ask in here.
Post Reply
rrodriguess
Posts: 133
Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil

Send Alert Function

Post 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);
}
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Send Alert Function

Post by rimai »

I think this feature is already built into the WifiAlert class.
Roberto.
rrodriguess
Posts: 133
Joined: Sun Mar 09, 2014 11:01 am
Location: Santos - Brazil

Re: Send Alert Function

Post 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
Image
Post Reply