Photon Soft AP from the Web

We are building a product on top of Photon and are defining the specs for the user experience when used from the Browser. Trying to figure out if the Web App would be able to initiate Photon Soft AP.

Imagine customer boots into their laptop/desktop/mobile phone browser, logs into our site and wants to add a new product and use it. We would like once the product is added that the user gets to pair it to their Wifi network as well, is it possible to trigger Soft AP from the browser. The way i see is the same Soft AP process could guide the user to connect their computer to the Photon’s wifi and then exchange the credentials while being in the browser. Similar to what the SDK’s do, is it possible or planned for the near term? What’s the alternative if this is not supported? We ask customers to setup Soft AP on their own, claim the device and then login to the site?

1 Like

@krazineurons Have you looked at https://github.com/spark/softap-setup-js?

Just found this related reply: Webpages on Photon / SoftAP

This code works great from a server-side nodejs app. However, I’m struggling to get the client (browser) side working.

I’m using Browserify to “flatten” all the required nodejs modules for softap-setup-js into a single client-side javascript file. “nconf” is a known issue with Browserify (which softap-setup uses). I’m having problems trying to use SoftAPSetup using “tcp” (i.e. via the “net” module)… even when using net-browserify. The http protocol doesn’t appear to be available on my Photon… I’ve tried to do a GET on http://192.168.0.1/device-id with Postman but it doesn’t appear to be listening on port 80 (pinging 192.168.0.1 works).

Hopefully these details help flush out some answers.

2 Likes

thanks for finding it @brewnerd! It looks like it could work. Looks like it still is a work in progress, Were you able to get any help from particle for tcp or http to work on your photon?

“tcp” works great but you don’t have direct access to sockets in the browser so you have to use “http”. However, http isn’t implemented yet.

@nexxy Any ETA on softap http support on the Photon?

As an aside, the HTTP API as shown in softap-setup-js looks easy to use.

HTTP support in the firmware will be available in the 0.4.4 release this week.

4 Likes

Awesome to hear @mdma! This feature serves to make the Photon (and Particle) that much more of the killer IoT platform.

@krazineurons I’m working w/ the team to get browser support into softap-setup-js. Here’s the thread on GitHub: https://github.com/spark/softap-setup-js/issues/1#issuecomment-132604279

@mdma I submitted a pull-request for softap-setup-js that allows this library to be used in the browser.

Now I’m working in Sencha Touch, which is a web-based mobile app platform. I’m having cross-domain issues because the browser issues an OPTIONS call prior to doing a POST (see Cross-Origin Resource Sharing)… the Photon never responds to the OPTIONS request with CORS-headers, so the POST never happens. This means I can only make ‘device-id’, ‘scan-ap’, and ‘public-key’ calls (all using GET).

I’ve looked at the Photon firmware… specifically softap.cpp. It looks like you’re using the builtin WICED webserver (wiced_http_server_start).

Question: Is there a way to either:

  1. Enable CORS support, or
  2. Enable JSONP support?

Thanks!