Webpages on Photon / SoftAP

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.

6 Likes

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

@peekay123 So do the Rest and Setup buttons on the Photon have to accessible and pushed to get the Photon into listen mode?

WiFi.listen() is the answer to that question :wink:

Is there documentation for a /signup hook on the firmware? Or are you referring to sending to REST api over the web?

@ScruffR Thanks! I got the example code up and working :smile: 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 :smiley: 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;
    }
2 Likes

@mdma - Iā€™ve added the ability to set the claim code on my softap setup pages via the query param claim_code. e.g. http://mebrunet.github.io/softap-setup-page/src/?claim_code=1234 This allows Customer and claim code creation followed by a redirect to the WiFi setup pages.

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.

1 Like

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?

1 Like

Currently not, but thatā€™s planned for one of the next releases
Currently milestoned for 0.8.0

1 Like

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 :smile:

Sorry for kicking this up. However I did an example on how to control the build in RGB led from a SoftAP webpage. Maybe it comes in handy:

3 Likes

Hi @mdma, @ScruffR, @kasper In milestoned 0.8.0 it will be possible to use tcp/udp in AP Mode?