harlequin-tech / WiFlyHQ

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

Fix failing to reboot on 'Wifly has crashed and will reboot...' #47

Open duhovny opened 8 years ago

duhovny commented 8 years ago

'while (1)' didn't reboot on some Arduino models, replaced with more reliable solution.

chrwei commented 8 years ago

the while(1) will only reboot the microcontroller if there's a watchdog configured, and this usually isn't the case in Arduino stuff.

it's also not necessary to reboot the microcontroller when the WiFly reboots since it'll usually auto-reconnect and keep most of the same config, especially for use cases where you use open(). in my branch I have replaced the while(1) with a delay(2000) and return false. this gives a little time for the reconnect and lets the calling code decide what to do next.

additionally, the jmp 0 may not work on non-AVR platforms. the library is otherwise microcontroller agnostic and it would be nice to keep it that way.

harlequin-tech commented 8 years ago

The reboot (reset) was actually being triggered by the XBee carrier connected back to the Arduino when the WiFly rebooted. Not all of the carrier boards do this, so yes this is not a general solution.

harlequin-tech commented 8 years ago

Also, I would think the firmware bug in the WiFly that was causing the it to reboot is fixed by now? Haven't been testing new firmware for quite a while...

chrwei commented 8 years ago

I think I managed to trigger this code, but it wasn't a firmware bug, it was something else doing the wrong thing and getting to that getprompt when it should have backed out earlier, or something. I don't recall now, I've actually fixed a ton of things recently in my branch, pull req coming soon.

duhovny commented 8 years ago

@chrwei I agree, there should be a proper fix — I just fixed existing hack.