Photon softAP usage?

I agree - it’s a great contribution! We’re discussing this internally in the team and weighing it up with our planned solution of having the webapp hosted outside the device. We’ll post back once a decision is made.

4 Likes

Just FYI: Content-Type: text/plain didn’t fix the CORS issue for me… Content-Type: multipart/form-data did work, as @mebrunet pointed out.

I’m developing in Sencha Touch in Firefox.

is this now part of the 0.4.4 firmware or do I have to build and flash the firmware here?

Great work thanks for the effort!!

getting an error while compiling @mebrunet 's firmware. This is my 1st time to compile a Particle firmware.

I downloaded the firmware from the website not from Git. I go into the modules folder and I am getting the following error

C:\Photon\modules>make clean all PLATFORM=photon -s program-dfu
"C:/Photon Programs/Git/bin/sh.exe": line 1: stat: command not found
head: -38: invalid number of bytes
make[1]: *** […/…/…/build/target/system-part1/platform-6-m-lto/system-part1.bin] Error 1
make: *** [C:/Photon/modules/photon/system-part1/makefile] Error 2

I have added all the paths to the environment variable, I confirmed that they are working and also confirmed the C:/Photon Programs/Git/bin/sh.exe is there.

What am i missing?

Thank you for your help

@mrabie

A couple questions to help you.

  1. When you say:

I downloaded the firmware from the website not from Git

What website do you mean? Please link to the download.

  1. Were you able to build the "vanilla" v0.4.4 or develop versions of the firmware? i.e. those version before they were modified to serve a SoftAP page? If not, I'd recommend doing that first. Also if you have questions about how to do that I'd recommend asking them on a different thread for clarity. (Feel free to tag me nonetheless).

The error is mentioned here:

See:

1 Like

Thank you for the replies and help.
@kennethlimcp it worked following your tutorial.
@mebrunet I wasn’t clear I downloaded the firmware here. Now I am able to build and flash the firmware(s).

There’s a problem with Safari on iPhone. When pointing the Safari browser to 192.168.0.1/ it keeps loading and then comes back with can’t open page error. Tried it on Chrome on iPhone it works perfectly.

Thank you

Does flashing my my WebIDE firmware breaks the functionality?

  1. Setup my Photon WiFi through SoftAP page
  2. Wrote my app on WebIDE
  3. Flashed my app to the Photon
  4. Put Photon in Listening Mode
  5. Connected to Photon WiFi
  6. Tried opening the SoftAP page again, now I am getting page can’t be loaded.

My understanding is that the WiFi setup doesn’t get wiped when I flash my custom app. Sorry for my confusion.

Thank you for your help

That download is out of date as is builds the SoftAP page with v0.4.3. It is preferable that you download from here (Download Zip link lower right) which builds it with develop.

@anthonywebb has also noticed the code not working with Safari. See bug here. We’re not sure why yet…

@mebrunet,

Thanks so much… this works like a champ on the first go! Just tried it out by compiling locally on a OSX with instructions on your github page.

Thanks once again. Awesome job!

btw, is this expected to be merged to develop branch on particle’s firmware repo?

@mebrunet in your README you mention that there is a limit on the size of any given file. I do not quite understand where this limit is coming from. So what if the const char [] has 5000+ bytes? I don’t see the compiler complaining about that. On the other hand, I did try to serve a 20k file and the browser does not receive it. I tried making a curl request for that specific file and I can see that the receiving speed drops to 0 not even half way into the file. And it seemed curl always received the same amount of bytes before stopping, however, that number of bytes was different when I tried getting another/different larger file.

I then tried to return a large response from a WICED_RAW_DYNAMIC_URL_CONTENT handler that I added. Once again, the browser could not receive the full response, but this time it was inconsistent. Sometimes the browser/curl WOULD receive the whole response (this time it was 8k long) and often times it would only receive a partial response as was the case earlier with the static resource.

fyi I’ve been tinkering with the develop branch.

Any ideas why I am only receiving partial responses? Where is the limit on the size of static resources coming from? Where is the limit on the size of the response from a dynamic handler coming from?

Thank you all for reading this! :smile: Hope someone has the answer…

@mebrunet
Thanks for the update. Used the new code and it works gr8 now.

I’m not sure if this is possible, but can’t you serve a REST API to do the same functionality as the SoftAP page? This way device builders can incorporate the functionality into their own apps, and fully customize the experience.

@shrike I had similar issues with loading inconsistencies, haha, that’s why I got a little hand-wavy when describing the file “size limit”. While @mdma should be able to answer this from a point of deeper understanding, I assumed that the device (or HTTP server running on the device) was just running out of memory while working with such large char arrays.

While digging deeper into the Broadcom WICED documentation and examples I noticed you could also serve sizable html/js/css resources from files (which could even be stored off-chip in separate flash memory), but they really didn’t make it clear how to do that…

@mrabie the SoftAP page is built on top of a HTTP API. See these docs.

has anyone tried softAP Page from a PC? I connected to the Photon AP and tried going to 192.168.0.1/ from Chrome and Edge and both are getting page can’t be loaded error. Still working good from iOS Chrome and Android Chrome.

I know someone already asked, but having access to this skeleton app would be wonderful :slight_smile:

If you’re looking for an entirely in-browser SoftAP app for the Photon, you can try one out here.

I made the interface using Meteor, but it all depends on a single JavaScript file (applied @brewnerd’s work in browserification, PR here) and so can be implemented using whatever JS framework you want (including none: just vanilla JS). More notes and a guide behind the implementation of this app can be found in my repo here.

Interestingly, Meteor also allows you to trivially generate Android and iOS PhoneGap apps from the existing HTML & JS, similar to what @nexxy was describing above. While I have not done so with this project, if you want to clone the repo it could immediately be used for such a purpose. It’s only a matter of using the meteor command line. You don’t even have to write any additional code! (maybe like a configuration file but I don’t think JSON counts as code).

4 Likes

@msolters have you tried this in safari yet? I have one as well, but it will only work in chrome, which means iPhone, iPad, etc isnt capable of configuring the unit without first downloading chrome.

– Edit 1 –

  • Yeah, Safari throws a bunch of XHR errors that I don’t see on Chrome, and the .configure and .connect calls never seem to even get called. Everything works right up through obtaining (or re-obtaining) the AP scan results, though.

– Edit 2 –

  • Firefox works fine.
  • Microsoft Edge (yes) works fine on the surface (no pun intended) and throws no errors, but it’s as though the .configure() and/or .connect() steps don’t actually do anything when they execute. The Photon, when power cycled, goes back to listening mode as if it never received anything despite the fact the scan results were all valid, and the configuration and connection steps both completed successfully in the JS.

Of note is the fact that all the browsers mentioned above got at least through the returning of successful scan results. I would hazard a guess that the compatibility issue with SoftAP as it stands is localized to the invocation of .configure() and/or .connect().

– Original –
Unfortunately not. I’m not sure what’s up with Safari. In my experience, Safari has some weird allergies where CORS is concerned. Once I wrangle up a Safari I will try it out. Do you see the same sort of SoftAP failure when you use @mebrunet’s approach, either served from the Photon or from a remote server?

Okay, at least now I know it’s not my JS. I’m getting a ERR_CONNECTION_REFUSED in the Chrome console when trying to get the deviceInfo.

I thought I remembered something about having to flash the firmware on the Photon but I don’t remember if that was before or after an official fix went out (after reading ~120 comments on this thread, things get a little hazy.

Anyone know if there’s a specific version/branch of firmware that the Photon needs to be running?