Network status calls and SYSTEM_THREAD issues

Currently the hasCredentials() call is a synchronous call on the system thread since we want to avoid data races (the test for credentials examines shared data in flash so needs to be done only on a single thread or guarded with a mutex.)

There are two approaches to making hasCredentials() non blocking:

  • use a mutex and allow hasCredentials() to execute on any thread. This will mean the application can execute hasCredentials() so long as the system isn’t also modifying wifi data (which it isn’t most of the time.)

  • use a flag that is updated by the system to indicate if WiFi credentials are present. The main concern here is what is the value of the flag before the system has determined if WiFi credentials are present? To avoid that tricky situation, we could force the system to check for WiFi credentials before starting the application thread.

That’s my current thoughts on this - open to comments and suggestions!