PeteBa / OpenSprinkler-Remote

An ESP8266 based Remote Station unit for the OpenSprinkler system
3 stars 2 forks source link

Received badly formed command #1

Closed crossmax closed 7 years ago

crossmax commented 7 years ago

Hi Peter, My warm thanks to you for your open source code. Very helpful for me.

But I've getting a bit trouble. I added a remote station in OpenSprinkler configuration, with ESP8266 IP and port 80. When I open or close the valve with OpenSprinkler app, I get this debug message from ESP8266: ERROR: Received badly formed command: GET /cm sid=0 en=1 t=65535

Do you know why I'm getting this long duration?

OpenSprinkler version 2.1.7 OSPi-AC

PeteBa commented 7 years ago

Hey Pablo,

OpenSprinker should default to use a "send and refresh" strategy with Remote Stations. If for example you wanted the program to run for 30 minutes then OSPi would send an "on" command with a very short duration but then repeatedly send that same command periodically before sending an "off" command at the end of the run. In effect, OSPi continuously refreshes the Remote Station to reduce the risk of getting out of sync. OSPi uses a default of 112 seconds duration and repeats the "on" command every 60 seconds. This is the same logic as the RF Station code where messages can frequently get lost.

Following the approach above, my Remote Station program uses the duration to set a timer to turn the valve off after the specified period. In normal operation, OSPi will repeat the "on" command before the timer gets triggered and thus you get the continuous operation but with the safety of the timer if you miss the "off" command. So I trap any long duration commands as they would represent an error in this approach.

However, recently, Ray added the ability to turn-off the "send and refresh" approach and introduced a standard single "on" followed by single "off" sequence as some users had asked for this as well.. In order for this to be backward compatible, he uses an infinite "on" duration ie 65535 and trusts that the "off" command gets received. So there are now two ways that the Remote Station can be used.

Now the original "send and refresh" approach should be the default but there is an option in the OSPi User Interface under the Advanced Setting section called "Special Station Auto Refresh" to control this. Can you should make sure this option is selected.

Sorry for the long winded answer but wanted to explain that there is some logic here and why you are seeing the "infinite" duration that OSPi is sending.

So try selecting that option and let me know if that works.

Cheers, Pete

PeteBa commented 7 years ago

Crossmax, just wanted to see how you were getting on. Did you manage to get the software/hardware working? Happy to help if any questions. Also, be good to know if this issue can be closed. Cheers, Pete

crossmax commented 7 years ago

Hi Pete! Sorry for the delay reply. You just asked me when I was testing the changes done on your code. I took this picture when I saw your message https://drive.google.com/file/d/0B064N1T8BwAMUU1GMWRhVlA3eDQ/view?usp=drivesdk

And the good news are all opensprinkler system work perfect! Because my motor drive is different I had to make a small change with VALVE_A_CONTROL_PIN variable.

Thank you very much for sharing your work and for being so willing to help me. Now, in the little free time I have, I will try to integrate some sensors (rain, soil moisture and detection of irrigation water with another rain sensor).

See you soon

PeteBa commented 7 years ago

Excellent stuff. Glad you got it working. Good luck with the extensions!