I installed the softAP example wifi setup code as outlined in the new softAP documentation. This was in addition to my own code running with SYSTEM_THREAD(ENABLED) and SYSTEM_MODE(SEMI_AUTOMATIC).
When I put the photon in listen mode, I was able to connect and configure wifi credentials really easily so thank you to all who have worked on this! This allowed me to ship a prototype with no wifi credentials but that I wanted to remain on my account during testing.
Caveat: I found that with threading enabled, user code runs even in Listen mode so I added if (!WiFi.listening()) code to skip loop code which uses TCPClient and Particle.publish() in order prevent an SOS condition while in listening mode.
I dont think you can intercept that call, what I meant was you could make a second call either using AJAX or with an actual form, so you submit your extra data to /signup before calling connect
@ScruffR Thanks! I got the example code up and working This is great!
Now I just need to figure out how to modify the look of the wifi page which shouldn't be very hard to do.
So I guess this is not something that you want to have happen every time setup runs so it has to be called from some sort of function triggered by an event like a button press or something.
This sure does solve a problem that many people have been asking about since the Spark Core It's nice to see all this being polished out.
The /signup was just a name I made up, it could also be /banana or /gru.
My idea is that the myPage function is called whenever the photon softAP needs to serve a page, and its up to that function to handle it.
In the demo code the only pages it can serve are the ones relating to softAP, the rest gets a 404.
So if we look for /banana and extract the data we need and save that in eeprom, then we can send it to the server once the wifi config is done.
Untested code just to show the ideaā¦
if (strcmp(url,"/banana")==0) {
char* data = body->read_as_string();
EEPROM.put(1000, data);
cb(cbArg, 0, 200, "text/plain", "OK");
return;
}
It might be interesting to incorporate to the āon deviceā pages as well. Itās a stranger use caseā¦ Presumably somebody who can configure a Customer creation server should also be able to host static softap pagesā¦ but ya never know. Happy to update files / docs if you point me to them.
Can the http server also be used outside of the listen mode (with SoftAP), so when the Photon is actually connected to WiFi?
Iād like to make a configuration page myself like mentioned here. So people can manipulate variables themselves without connecting the device to WiFi.
However Iād like to keep using this page even if they have connected the Photon to WiFi. For this I could use the webduino implemenation (like in this tutorial).
Both Webduino and SoftAP implement an http server, so it seems an overkill to include them both?
Maybe someone can give a starting point how I could use the SoftAP http server?
Iām aware of that (and waiting already for a while). I was just thinking that since http functions are already included I might be able to use them as well.
Iāll go the double include road then or I might try to stretch my patience a bit more