We are troubleshooting an issue where we are unable to connect to a new WiFi network using SoftAP with our P1’s that have been updated to system firmware 0.7.
This only happens when our application binary is loaded. If we are running tinker, it takes the new wifi credentials normally (using softap or the CLI tool). Our application binary appears to run normally otherwise.
There are two cases, but I think it’s really the same root cause of the new credentials not being saved:
Case 1: No credentials previously saved
P1 boots into listening mode, LED starts flashing dark blue
Connect using SoftAP, send in the desired credentials
P1 restarts, goes immediately into listening mode again with dark blue flashing LED
Case 2: Credentials previously saved (for a network that is not visible)
P1 boots into flashing green mode, trying to connect to the old WiFi network
Put the P1 into listening mode, LED starts flashing dark blue
Connect using SoftAP, send in desired credentials
P1 restarts, goes into flashing green again, still trying to connect to old WiFi network
listening to the device over USB serial connection, when we save the credentials we do get a system message saying it saved the new credentials before it resets.
Any clues as to what could be going wrong? This seems somewhat related to the issue discussed here: Update to 0.7.0 goes wrong however it does appear that the upgrade to 0.7 went well. If we set the wifi credentials while the P1 is running tinker, it can connect to the wifi and cloud no problem. The only issue as far as I can tell is the failure to save new credentials.
Thanks for the reply @ScruffR . In our normal application, we typically have around 32K of free memory prior to engaging listening mode. After listening mode is engaged, it looks like free memory drops to around 15k. Then when the soft AP client connects it drops further.
When you say SoftAP requires 21K free memory, are you referring to before the WiFi listening mode is enaged, or after it’s already engaged and before the softap client connects?
I made a branch of our code and went through and turned off / commented out as much as I could and was able to get it to take the new credentials. In this case, I started out with 37488 free memory prior to listening mode, it dropped to 17120 after the client connected, and then dropped to 12936 when the credentials were passed in. It then connected to the new network immediately without restarting.
The problem of course is that I’ve removed all the guts of my application! About all that’s left is the Soft AP controller and some output log messages. I had issues with memory usage in 0.6.x, but I was able to run my entire app including some large statically allocated struct buffers. Does 0.7 just require a lot more memory for the system code?
If that’s the case we will probably have to downgrade to 0.6.2.
Thanks. We aren’t using any custom softap pages, we just put the P1 into listening mode and use the softap-setup-js library to connect via our mobile app. So it’s all using the HTTP API and our custom UI.
I tried downgrading to 0.6.3 and things are working great again. With the same user application, I have about 40k free memory prior to listening mode, 23k available after entering listening mode, and the credentials save correctly.
Due to the residual effects of SoftAP (which should be addressed by Particle IMO) it might be best to finish the process with a System.reset() call to properly free up the memory occupied by SoftAP.
I've read another thread where a subsequent SoftAP attempt crashes - probably due to SoftAP not reusing the allocated memory but rather acquiring new space.
@andrewa@scruffR I can confirm that repeated use of SoftAP with 0.8.0-RC.10 will drop the free memory to a level that causes a photon to hang when trying to save the credentials - my watchdog logged the freememory as around 17300 bytes at this point. Typically when running the free memory is around 43000.