harlequin-tech / WiFlyHQ

WiFly RN-XV Arduino Library
Other
110 stars 68 forks source link

Once 'Failed to exit', never able to get in commandMode again #12

Open ricdijk opened 12 years ago

ricdijk commented 12 years ago

I'm using the library for a temperature sensor of my solar boiler system, it works great, thanks for the good work!

When WiFly::exitCommandMode() does not get 'EXIT\r\n' from the wifly it raises an error (correct) and leaves the variable inCommandMode as it is (= true). Most probably the wifly did not return 'EXIT\r\n' because it somehow already left command mode.

WiFly::startCommand() first checks 'inCommandmode == true', thinks the wifly is still in commandmode and does not execute a '$$$' command. Because WiFly will not get in command mode, WiFly::exitCommandMode() will never get an 'EXIT\r\n' and doesn't change anything. Even a WiFly::reboot() won't work (because it uses WiFly::startCommand()). The way it is working right now, to me it seems impossible to get out of this situation.

A solution for this might be to assume the wifly is not in command mode when WiFly::exitCommandMode() doesn't get an 'EXIT\r\n'. In that situation still raise an error, but set inCommandMode false anyway.

harlequin-tech commented 12 years ago

Great that its mostly working for you.

The exit problem sounds like a symptom of a comms problem. If you make the change you've suggested, does your WiFly respond to further commands (i.e. does the next enterCommandMode() work?).

ricdijk commented 12 years ago

Yes, I made the change in my own local library and since then the wifly continues working after a ‘Failed to exit’. The Wifly gets into command mode again and any command that is send after the ‘Failed to Exit’ is processed OK.

marcosmoura91 commented 11 years ago

What changes have you made ???

Sometimes mine also fails and i keep getting failed to get prompt and failed to echo something

And it just keeps reporting those failures.

i edited the exitCommand so it sets the inCommandMode to false everytime even if it finds the 'EXIT\r\n' or not. I hope it works.