Problem with wifi

Related to the development libraries, released by Curt Binder
savo69
Posts: 4
Joined: Mon Aug 01, 2011 12:56 am

Problem with wifi

Post by savo69 »

Hi to all,
I just configured my wifi attachment but I have a problem during update of the web banner.
I use curt's libraries (.16 release) and I activated #define wifi into reefangel_features.h. The pde is compiled from arduino and uploaded on the RA board. The dimension of pde file is around 29000 bytes.
The problem is this:
When I switch on the RA, the wifi attachment green led flash slow (IP Address recognized from the router).
After 3 minutes the wifi module send the information to the server and the yellow led flash for few seconds.
The web banner is updated and I can see the values for temperature and the status of the relay via web browser.
After that, the yellow led doesn't stop to flash, the green led flash fast, stop to flash, flash fast again, flash slow for few seconds and in absolutely random sequence repeat the flashing slow, fast, stop. The yellow flash do the same (flash, not flash).
I tried to keep switch on the RA for 2 days and I have seen that sometimes the web banner was update (now is monday morning, the last update was done yesterday evening at 8:37 PM, the RA is switch on since saturday evening).

If I check wifi with http://wifiIPaddress:2000/wifi the attachment work and I can see the values update every 5 seconds.

What it can to do? Someone have same problem?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

Green LED flashing fast means something is probably causing the wifi attachment to enter command mode.
Can you attach your PDE file?
Roberto.
savo69
Posts: 4
Joined: Mon Aug 01, 2011 12:56 am

Re: Problem with wifi

Post by savo69 »

Here I am,
this is my pde file

// RAMenus.pde
//
// This version designed for v0.8.5 Beta 10 and later

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
#include <avr/pgmspace.h>
prog_char id_label[] PROGMEM = "savo69";
prog_char probe1_label[] PROGMEM = "Acqua";
prog_char probe2_label[] PROGMEM = "LED";
prog_char probe3_label[] PROGMEM = "Ambiente";
prog_char relay1_label[] PROGMEM = "ATO";
prog_char relay2_label[] PROGMEM = "Actinic";
prog_char relay3_label[] PROGMEM = "Halide";
prog_char relay4_label[] PROGMEM = "Powerhead%202";
prog_char relay5_label[] PROGMEM = "Powerhead%201";
prog_char relay6_label[] PROGMEM = "Chiller";
prog_char relay7_label[] PROGMEM = "Heater";
prog_char relay8_label[] PROGMEM = "Sump";
PROGMEM const char *webbanner_items[] = {
id_label, probe1_label, probe2_label, probe3_label, relay1_label, relay2_label,
relay3_label, relay4_label, relay5_label, relay6_label, relay7_label, relay8_label};


void RitardoSkimmer(byte SKPort, byte SKDelay)
{
unsigned long d = SKDelay;
d *= SECS_PER_MIN;
if (now()-RAStart > d) ReefAngel.Relay.On(SKPort);
}

void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.SetTemperatureUnit(1); // set to Celsius Temperature
if ( RAStart == 0 ) RAStart = now();

ReefAngel.LoadWebBanner(pgm_read_word(&(webbanner_items[0])), SIZE(webbanner_items));
ReefAngel.Timer[4].SetInterval(180); // set interval to 180 seconds
ReefAngel.Timer[4].Start();

// Set the ports that get toggled on & off during the following modes
// To enable a port to be toggled, place a 1 in the appropriate position
// Uncomment and update as needed
// Port 87654321
//ReefAngel.FeedingModePorts = B10011100;
//ReefAngel.WaterChangePorts = B10011100;
//ReefAngel.OverheatShutoffPorts = B00001100;
//ReefAngel.LightsOnPorts = B00000110;

// Ports that are always on
// ReefAngel.Relay.On(Port8);
}

void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.StandardATO(Port1);
ReefAngel.StandardLights(Port2);
ReefAngel.MHLights(Port3);
// ReefAngel.Wavemaker1(Port4);
// ReefAngel.Wavemaker2(Port5);
ReefAngel.StandardFan(Port6);
RitardoSkimmer(Port8, 2); // 2 minute delayed on
ReefAngel.StandardHeater(Port7);
// Web Banner stuff
if(ReefAngel.Timer[4].IsTriggered())
{
ReefAngel.Timer[4].Start();
ReefAngel.WebBanner();
}

}

--------
I hope for some error, but I fear that the module is faulty
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

I have a couple comments, not sure if it will fix anything but here are some comments:

1. If you are using 0.8.5.15 or later, you do not need to use that RitardoSkimmer function. There is a DelayedOn function that is built into the libraries. You use it like this (in the loop function instead of RitardoSkimmer)

Code: Select all

ReefAngel.DelayedOn(Port8, 2);  // Port 8 is on a 2 minute delay
So you can remove the RitardoSkimmer function and reference. Plus, this line can be removed too:

Code: Select all

if ( RAStart == 0 ) RAStart = now();
This will free up some memory for you.

2. If you have the web banner enabled, you will want to use caution when browsing the internal web page. You could find that the controller will also send the banner information out while viewing and it "could" cause a problem. It's unlikely but the possibility does exist.

3. It sounds like there is an issue with your routing capability with your network. The wifi module has to send the data to reefangel.com. If there is a slow network connection (meaning you are doing a lot of web browsing, downloading, etc), your data might not get updated quickly or there could be a timeout reaching reefangel.com. Could you post the configuration values from the wifi module? Specifically from the routing command (get i).
Make sure that you configured your wifi module like it is supposed to be to work with the web banner, this screenshot is what the commands should be to enable it:
Image

You might also want to run a traceroute command to see how well your network can get to reefangel.com
If you are running windows, try this command from a command window:

Code: Select all

tracert 198.171.134.6
This will tell you if your computer is having problems connecting to reefangel.com

This is a start of things to try. It sounds like the wifi module is working properly if you can connect to it on your own network.

curt
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

I have good news and bad news.
Good news is that I don't think there's nothing wrong with your stuff or code.
The bad news is that I don't think it can be solved easily and will require more investigation and troubleshooting.
It's actually a bug in the libraries that will need to be fixed.
Basically here is what's happening:
At the first attempt to send data, the controller is a default state and there is no communication whatsoever.
When the timer expires, the controller sends data to reefangel.com and thus the 1st update shows up on your banner.
Here is the request that goes on:

Code: Select all

GET /status/submit.asp?t1=248&t2=248&t3=248&ph=1054&relaydata=64&id=savo69&t1n=Acqua&t2n=LED&t3n=Ambiente&r1n=ATO&r2n=Actinic&r3n=Halide&r4n=Powerhead%202&r5n=Powerhead%201&r6n=Chiller&r7n=Heater&r8n=Sump
At this point, the server responds back to the controller with this:

Code: Select all

HTTP/1.1 200 OK
Date: Tue, 02 Aug 2011 19:49:29 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Content-Type: text/html
Cache-control: private
Transfer-Encoding: chunked

5
Done.
0
With the way the libraries are setup right now, I'm assuming the incoming data is treated as a new request to the built-in server instead of a response from the reefangel.com server. Curt can confirm this.
Then, the built-in server doesn't actually recognize this request, which in reality is not really a request, but a response to your original request to reefangel.com.
I think in the latest update, we had a check added to the code for proper requests to the built-in webserver. This check is returning this back to reefangel.com:

Code: Select all

HTTP/1.1 200 OK
Server: ReefAngel
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/html
Content-Length: 24

<h1>Unknown Request</h1>
In turn, the reefangel.com server also does not recognize this request and sends back another reponse that it didn't recognize the request and they keep exchanging data in a vicious cycle that never ends.
I think we'll need to come up with different type of check for unknown request by the built-in server.
Let me work with Curt to try to get this bug fixed.
I don't think there are many users using the WebBanner() function like you are using. I think most are using the Client 2.2 for banner updates. That's why it wasn't reported before.
Thanks for identifying it.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

Yep, that's exactly what would be happening. The 2 will be in this continuous "loop" going back and forth. I wonder if it all stems from me adding in that "Unknown Request" option. It probably does. A simple test for you Roberto would to just simply comment out the default case of sending back the WebResponse in the wifi.cpp file. This way that unknown requests are "acknowledged" by the controller as being unknown but it simply just ignores the request and keeps on going.

I never gave it a thought about any response coming from the server once it got a request sent to it.

try what i suggested above and let me know. if it works, then i'll remove that unknown request from the libraries.

curt
savo69
Posts: 4
Joined: Mon Aug 01, 2011 12:56 am

Re: Problem with wifi

Post by savo69 »

If the problem is the last issue of the curt's library, I can try to use del version .14 and let you know if something will change or not.
I'm using the web banner function because I use an Apple iMac and I not found the Dave Molton client for Mac.
Can you suggest me some other client for mac that update web banner?

Many thanks for you help
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

Pretty sure earlier versions of the dev libriaries would solve your problem.
Roberto.
savo69
Posts: 4
Joined: Mon Aug 01, 2011 12:56 am

Re: Problem with wifi

Post by savo69 »

With release .14 of curt's libraries the wifi attachment is working good :-)

I hope Curt solve the problem soon in order to use the last libraries.

Thank you very much to all
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

I need some more time to test things out. But should be simple to do. I don't see why not.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

savo69 wrote:With release .14 of curt's libraries the wifi attachment is working good :-)

I hope Curt solve the problem soon in order to use the last libraries.

Thank you very much to all
Once Roberto tests things out more and lets me know what he finds out then I can fix up the issue. Like he said, it should be a pretty simple fix. I've got a few more things to add in to make a .17 release.

curt
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

Pull requested on your master branch.
Take a look at it and let me know if you find any problems.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

i did find some problems...it appears that you have included the entire features file inside the wifi.h file. plus i did not see where the RES_HTTP was defined at.

my solution to the "bug" was to just not have the controller send out anything on an unknown request. the only difference i had was that the serial line was not being flushed, which it probably should be like you are doing. i think i should add the flush on the default case.

curt
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

OMG...
I must have messed up before the commit....
I'll fix tomorrow... sorry about the confusion.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

rimai wrote:OMG...
I must have messed up before the commit....
I'll fix tomorrow... sorry about the confusion.
haha...it's ok. i think i know what you were getting at. i haven't pushed my changes to my main branch because i know your library updater utility works on my main branch. (which is totally cool and you don't need to change your library update utility).

curt
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

Ok. I fixed the screw up.
Try it again now.
Roberto.
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

Hi, i think to have the same problem, i uploaded libraries to lastest version (...16) and updated ReefAngel_wifi.h and .cpp with the fix but the controller doesn't send params... in many hours sent only 2 times...
Can you help me?
TNX
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

pasqualevg wrote:Hi, i think to have the same problem, i uploaded libraries to lastest version (...16) and updated ReefAngel_wifi.h and .cpp with the fix but the controller doesn't send params... in many hours sent only 2 times...
Can you help me?
TNX
Please read the thread above.
Roberto.
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

i read, but don't understand what i have to do...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Problem with wifi

Post by rimai »

Nothing. There is no solution for it yet, except downgrade to .14 like savo69 did.
I just pushed a bug fix to Curt and he'll include in his next release.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

rimai wrote:Nothing. There is no solution for it yet, except downgrade to .14 like savo69 did.
I just pushed a bug fix to Curt and he'll include in his next release.
I'm almost ready to release my next version which will have this fix in it. Just have to add one more function/feature and do some more testing.

curt
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

If anybody wants to test out the fix before my next release, it is inside my DEV branch on my github account.

https://github.com/curtbinder/ReefAngel/tree/dev

You don't have to. You can always wait until the next release but for those that wanted to test it out they can.

curt
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

i will test it... i have only to replace wifi files, right?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

pasqualevg wrote:i will test it... i have only to replace wifi files, right?
I would suggest replacing the:

Globals.h & .cpp
Wifi.h & .cpp
NokiaLCD.h & .cpp
ReefAngel.h & .cpp

Just to be on the safe side. There have been a couple other changes made too.

You can try just the wifi.h & .cpp files, but if that doesn't work properly and you get some unusual activity then I'd recommend replacing what I mentioned above.

curt
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

i tried also replacing global, wifi, nokia lcd and reefangel, the controller works but don't send params, i also try to stop listener & logger and use the browser (http://192.168.xxx.xxx:2000/wifi) but i only see the image without params... on the wifi attachment 1- low green pulse 2- few orange pulse 3- green always on... i don't know wat's the problem... in any cases i will wait for the next libraries release...
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

If you are using the Client Suite (listener and logger), then you cannot have the controller also update your web banner. That will simply not work.

You need to do 1 of the following:

1. Have the controller update the web banner. The controller sends the values to ra.com. You must have your wifi module programmed to send to ra.com. The controller will send the values at specified intervals.

2. Have the Client Suite update the web banner. The client suite will monitor the controller (listener & logger services) and then it updates the values on ra.com for your web banner.

If you do both you will have problems.

curt
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

ok, i want to use the client, i don't remember il i programmed the attachment to send directly to reefangel.com what i have to do to know where's the problem?
i'm sorry for my many question but i don't read very well and probably if you treated the problem i didn't understend... sorry
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Problem with wifi

Post by binder »

pasqualevg wrote:ok, i want to use the client, i don't remember il i programmed the attachment to send directly to reefangel.com what i have to do to know where's the problem?
i'm sorry for my many question but i don't read very well and probably if you treated the problem i didn't understend... sorry
That's ok. What you can do is attach your PDE file to this thread and we can look and see if your PDE file needs modified.

Next, follow this topic on enabling the Client Suite:

http://forum.reefangel.com/viewtopic.php?f=8&t=175

That will be a good start. Read the document and watch the video. It's straight forward and you should be up and running. If not, create a new topic about what problem you are encountering.

curt
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

Finally i understand the problem... when i programmed wifi i make it send params directly to ra.com...
i re-programmed it and now all is OK.
I don't understend why with previus libraries and client in works...
In any case thanks...
You're really a great team
pasqualevg
Posts: 13
Joined: Fri May 13, 2011 12:27 pm
Location: Italy

Re: Problem with wifi

Post by pasqualevg »

A little note:
Probably something in the libraries is blocking the sending of memory params of Heater & Chiller on & off in °C, probably is set to °F and if it read f.e. 255 think that's wrong.
I don't know if the problem is in the libraries or in the client...
Post Reply