Can a P1 be setup to connect to the internet without claiming it?

Let me poke at this problem again. I’ve discussed this before, but since @dheerajdake has the exactly same problem that I have and the thread offers no solution, I’ll revive this rather than starting a separate thread. I have discussed this before, but I eventually had to register all the units in my first batch of P1 based custom boards. Now I’ve just received another batch of 60 units and can do more testing on this.

My ideal setup is to flash a single -bin file via Serial to the device that will set default Wifi credentials as soon as the software runs. After some physical tests of the PCB, the firmware will then register itself with a special endpoint on our cloud service and write the returned config to the P1 external Flash memory so it’s always there upon startup. Ideally, I could also make the board claim itself to our account, but for now I’m just having it print the claim-command to serial so the operator can cut and paste this. It’s not ideal, but it works.

I’ve tried making such automated setups before without success and I’ve now also tried what @ScruffR suggested above without success. Just as the others, I cannot prevent the board from entering Setup Mode. It seems the reason is that even before any user code is executed, there is a check in the Particle Firmware that says something like “if you don’t have wifi credentials, don’t try to execute the user software”.

We do not want to set up many hundred boards manually, so using the app or CLI to set up wifi is out of the question.

Here’s what I’ve tried:

  • Just checking with WiFi.hasCredentials() has no effect since it won’t be executed unless there already are some credentials set.
  • Using SYSTEM_THREAD(ENABLED) has no effect. User code is still not executed.
  • Setting SYSTEM_MODE(SEMI_AUTOMATIC) (or setting it to anything else) has no effect. User code is still not executed.
  • Using STARTUP(WiFi.off()) has no effect. User code is still not executed and as far as I can see, you cannot use WiFi.setCredentials unless Wifi is operating.

Ideas:

  • If the Particle CLI supported setting wifi credentials as a one-liner, I could easily make a script that first set the credentials and then flashed the setup firmware. The likely candidate in CLI is the “particle serial wifi” command, but according to the docs it does not seem to offer any options? https://docs.particle.io/reference/cli/#particle-serial-wifi It basically does exactly the same as “particle setup”, but ignores the login check.

  • wifitester.cpp is a file in the firmware. It looks like this is a way to test wifi setups and that it’s included in the firmware? Is this something that’s available from the command line? Looking at this Particle Firmware Updates Thread it might be code used by the Tinker software?