My results are far from scientific. This exercise has involved a lot of trial-and-error, some shotgun approaches, finger-crossing, and several desperate prayers to Binarius, the Greek god of bits.
But upon the very valid request to know which commands were causing the issue, I've pared the code down, and removed most of the delays, and got it reliably working. In my rigorous testing (by that I mean 6 times), I found that I only needed to delay starting the WiFi AP and Station a second after the SPI device.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
My results are far from scientific. This exercise has involved a lot of trial-and-error, some shotgun approaches, finger-crossing, and several desperate prayers to Binarius, the Greek god of bits.
But upon the very valid request to know which commands were causing the issue, I've pared the code down, and removed most of the delays, and got it reliably working. In my rigorous testing (by that I mean 6 times), I found that I only needed to delay starting the WiFi AP and Station a second after the SPI device.
This makes the relevant code now look like this:
Why? I dunno, but without the delay on the 'startApAndStation' I get the Uncaught CWMODE failed: Timeout error nearly every time.