Page 1 of 3

I can't find the WifiSendAlert() function in the libraries.

Posted: Sun May 12, 2013 5:15 pm
by mudcat1
Could someone please tell me where the WifiSendAlert() function is located in the libraries? I would like to see if I can figure out how to add a few more custom alert messages beyond the few that currently exist which are:

WifiSendAlert(0)="Nothing"
WifiSendAlert(1)="Auto top-off timeout"
WifiSendAlert(2)="Water temperature too high"
WifiSendAlert(3)="Water temperature too low"
WifiSendAlert(4)="Lights temperature too high"
WifiSendAlert(5)="PH too high"
WifiSendAlert(6)="PH too low Alert"

Examples of a few messages that I want to add are:
WifiSendAlert(7)="ATO reservior is empty"
WifiSendAlert(8)="Sump water level is too low"
WifiSendAlert(9)="Sump water level is too high"

I would also like to see if it could send the SMS alerts faster (ex. within 1 minute).

Thanks,
John

Re: I can't find the WifiSendAlert() function in the librari

Posted: Sun May 12, 2013 5:22 pm
by binder
it's not in the libraries.
here's a post made by you with the code you need:
http://forum.reefangel.com/viewtopic.ph ... ert#p18083

I can't find the WifiSendAlert() function in the libraries.

Posted: Sun May 12, 2013 5:24 pm
by lnevo
I dont think that function is in the libraries...i think it was a custom one...if i'm wrong though you can find it in the Doxygen docs.

http://www.easte.net/RA/html/

I can't find the WifiSendAlert() function in the libraries.

Posted: Sun May 12, 2013 5:57 pm
by lnevo
binder wrote:it's not in the libraries.
here's a post made by you with the code you need:
http://forum.reefangel.com/viewtopic.ph ... ert#p18083
Ahh yeah, looks like its happening in the portal...

Re: I can't find the WifiSendAlert() function in the librari

Posted: Sun May 12, 2013 8:51 pm
by mudcat1
This is the code that I am using but I don't see where the alert messages are being defined.

Code: Select all

// Setup SMS alerts
 void WifiSendAlert(byte id, boolean IsAlert)
{
  static byte alert_status;

  if (IsAlert)
  {
    if ((alert_status & 1<<(id-1))==0)
    {
      alert_status|=1<<(id-1);
      Serial.print("GET /status/alert.asp?e=3141234567@vtext.com&id=");
      Serial.println(alert_status,DEC);
      Serial.println("\n\n");
    }
  }
  else
  {
    if (id==0)
    {
      alert_status=0;
      delay(900);
    }
    else
    {
      alert_status&=~(1<<(id-1)); 
    }
  }
}
I don't see where these ids are defined in the code.
WifiSendAlert(0)="Nothing"
WifiSendAlert(1)="Auto top-off timeout"
WifiSendAlert(2)="Water temperature too high"
WifiSendAlert(3)="Water temperature too low"
WifiSendAlert(4)="Lights temperature too high"
WifiSendAlert(5)="PH too high"
WifiSendAlert(6)="PH too low Alert"

Can someone explain how it works?

Thanks,
John

I can't find the WifiSendAlert() function in the libraries.

Posted: Sun May 12, 2013 9:16 pm
by lnevo
This code is sending the alert to the portal...it's not happening in the library code.
mudcat1 wrote:

Code: Select all

      alert_status|=1<<(id-1);
      Serial.print("GET /status/alert.asp?e=3141234567@vtext.com&id=");
      Serial.println(alert_status,DEC);
Roberto, maybe we can extend this to take some custom strings instead of just id=

That could solve having to use custom variables for alert flags and solve mudcat's issue, also enable faster alerting to make it RA triggered instead of possible 5 minute delay waiting for portal timer to trigger.

Re: I can't find the WifiSendAlert() function in the librari

Posted: Sun May 12, 2013 9:21 pm
by mudcat1
Yes, a 5 minute delay, if my sump is overflowing would be tragic.

I can't find the WifiSendAlert() function in the libraries.

Posted: Sun May 12, 2013 9:22 pm
by lnevo
If my sump starts overflowing, I have a float switch activate and turn off return pump... Something to consider :) no need to wait for disaster to strike.

Re: I can't find the WifiSendAlert() function in the librari

Posted: Sun May 12, 2013 9:29 pm
by rimai
How can we restrict this to avoid anyone from maliciously use it to spam email with custom string?

I can't find the WifiSendAlert() function in the libraries.

Posted: Mon May 13, 2013 3:07 am
by lnevo
Portal key?

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 8:41 am
by rimai
Actually, sleeping over the issue, I know what needs to be done.
I can create another page that takes portal username/key instead of email address.
This way, a malicious bot can only spam itself... :twisted: lol

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 8:47 am
by lnevo
Cool. Can we get that WiFiSendAlert() added to the libs then to make it easy :)

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 11:40 am
by rimai
Ok, I created a new webpage wifialert.aspx
It will use the same email address set on your portal notifications.

Parameters:
id - your forum username
key - your portal key (optional)
msg= your custom message

Just be careful not to spam your own mailbox.

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 12:51 pm
by lnevo
Very cool!!! Tested this and it works. Now I can add this to my INO, get rid of my Custom Memory variables for flags and no more internal memory flags either with virtual relays... this will be my 5.x version :) Muahahah

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 12:56 pm
by lnevo
So Roberto,

I can work on a pull request if you want for the WifiSendAlert.. but I'm thinking we should put the portal user and keys in a variable in the ReefAngel class... I guess I'll wrap it in an ifdef to save memory... the function can take a char * as an arg and it will be pretty nice for people I think...

Sound good?

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 12:59 pm
by rimai
It's already there :)
char *portalusername;
Key is not though, but you can use the same thing I did for portalusername

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 1:00 pm
by rimai
The only thing is we need the logic to lock it from being used over and over again and only send once/hour reminders or something, just like in the original code.

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 1:14 pm
by lnevo
Oh cool. Would you want that on your end or in the RA side? I would think on the RA side you'd only want to send if the status changes otherwise you could be calling that URL multiple times per second which would get ugly pretty fast. That part opens up a little can of worms... hmmm

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 1:19 pm
by lnevo
I'm thinking we could create an alert class. This way it could maintain it's state of what the status of the alert is. If the status changes it could trigger the alert and it could have a timer built in...

This way in code safely call the alert function every loop without fear and it would only call the URL when the status changes or the timeout is exceeded.

I'm thinking something along the lines of this.

if (condition is good) then alert(status_good) else alert (status_bad)

Need to think a bit more on this.

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 13, 2013 2:00 pm
by enigma32
Probably best to do it on both sides...that way even if there's a bug one one side or the other there's never a situation where a dozen people get 10,000 alerts...

Re: I can't find the WifiSendAlert() function in the librari

Posted: Tue May 21, 2013 9:43 pm
by mudcat1
Roberto or Lee,
Did you ever finish the coding for WifiSendAlert that will allow me to add a few custom SMS alert messages? If so, will it be released in the next library version? Or is it available for download on github?

I can't find the WifiSendAlert() function in the libraries.

Posted: Wed May 22, 2013 5:23 am
by lnevo
Havent had time to touch it yet, but you should be able to modify the url being called to hit the new page and then send whatever custom message you like :)

Re: I can't find the WifiSendAlert() function in the librari

Posted: Fri May 24, 2013 7:45 pm
by mudcat1
lnevo wrote:Havent had time to touch it yet, but you should be able to modify the url being called to hit the new page and then send whatever custom message you like :)
Sorry Lee, I don't understand what you mean. Do you want me to copy these statements somewhere after my condition that determines when to send the SMS alert?

Serial.print("GET /status/alert.asp?e=314123456@vtext.com&id=");
Serial.println(alert_status,DEC);
Serial.println("\n\n");

I need a little more to go on.
Thanks,
John

I can't find the WifiSendAlert() function in the libraries.

Posted: Sat May 25, 2013 1:12 am
by lnevo
rimai wrote:Ok, I created a new webpage wifialert.aspx
It will use the same email address set on your portal notifications.

Parameters:
id - your forum username
key - your portal key (optional)
msg= your custom message

Just be careful not to spam your own mailbox.

You have to use this new wifialert.aspx

Change the line you have that calls alert.aspx to the new syntax above.

Maybe I'll have some time next week to play with this...

Re: I can't find the WifiSendAlert() function in the librari

Posted: Sat May 25, 2013 10:57 am
by mudcat1
lnevo wrote:
rimai wrote:Ok, I created a new webpage wifialert.aspx
It will use the same email address set on your portal notifications.

Parameters:
id - your forum username
key - your portal key (optional)
msg= your custom message

Just be careful not to spam your own mailbox.

You have to use this new wifialert.aspx

Change the line you have that calls alert.aspx to the new syntax above.

Maybe I'll have some time next week to play with this...
Lee,
Thanks for the clarification.

Re: I can't find the WifiSendAlert() function in the librari

Posted: Sun May 26, 2013 11:05 pm
by mudcat1
I still can't figure out how to use wifialert.aspx. When I compile it says it has not been declared. Can someone please provide an example of how the wifialert.aspx is used in the sketch.

thanks,
John

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 27, 2013 2:02 am
by lnevo
Did you not have it working with the other page before?

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 27, 2013 10:47 am
by mudcat1
lnevo wrote:Did you not have it working with the other page before?
Yes, the WifiSendAlert() function was working, but I am not sure how to pass the parameters that you and Roberto suggested in this section of the code.

Serial.print("GET /status/alert.asp?e=314123456@vtext.com&id=");
Serial.println(alert_status,DEC);
Serial.println("\n\n");

I am assuming that you wanted me to replace "alert.asp?" with "wifialert.aspx", but I am not sure how to specify the ID, Key and Message parameters.

I was hoping that you or Roberto could supply some sample code that I could modify.

Thanks,
John

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 27, 2013 12:58 pm
by lnevo
Try this:

Code: Select all

Serial.print("GET /status/wifialert.aspx?id=mudcat1&msg=ato_alert");

Re: I can't find the WifiSendAlert() function in the librari

Posted: Mon May 27, 2013 1:00 pm
by lnevo
You can comment the second line as well. I'm going to work on this soon where you can pass the alert string to the function.