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

Requests for new functions or software apps
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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/
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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...
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post by mudcat1 »

Yes, a 5 minute delay, if my sump is overflowing would be tragic.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

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

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

Post by rimai »

How can we restrict this to avoid anyone from maliciously use it to spam email with custom string?
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post by lnevo »

Portal key?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

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

Post 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
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post by lnevo »

Cool. Can we get that WiFiSendAlert() added to the libs then to make it easy :)
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

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

Post 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.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

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

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

Post by rimai »

It's already there :)
char *portalusername;
Key is not though, but you can use the same thing I did for portalusername
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

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

Post 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.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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.
enigma32
Posts: 74
Joined: Fri Apr 26, 2013 11:48 am
Location: Los Angeles and NYC

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

Post 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...
Current setup:
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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 :)
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post 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...
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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.
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post by lnevo »

Did you not have it working with the other page before?
mudcat1
Posts: 133
Joined: Sun Dec 09, 2012 7:23 pm

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

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

Post by lnevo »

Try this:

Code: Select all

Serial.print("GET /status/wifialert.aspx?id=mudcat1&msg=ato_alert");
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

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

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