-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
application softAP http pages #906
Conversation
ff9a548
to
dcc7a43
Compare
f3fe66f
to
c4b0437
Compare
…tom headers to be inserted in the response.
@technobly Please verify SoftAP continues working as normal (with tinker), and then flash the app above and try it out. You should see custom pages for setting up wifi. |
Both WICED and SoftAP changes look good to me. Setting of wifi credentials works with both Particle's mobile app (with tinker flashed) and custom HTTP handler. |
application softAP http pages
@sergeuz, did you managed to get the code above working? I would love to use the softAP page for a project demo but is short of getting the softAP page to work. I needed an extra |
@kennethlimcp Did you try this application when your photon is in listening mode? |
Just tried. Also, the photon exited listening mode and ran user code after i called ``http://192.168.0.1/version`. Not sure if this is the default behavior |
Could you try moving call to
Listening mode might have been enabled before calling |
@sergeuz, yup! That did the trick... But the photon would automatically reboot after the page loads. Seems like more work needs to be done for this to be stable? |
So you were unable to set wifi credentials via custom page due to unexpected reboot? Besides of missing include and SoftAP worked normally in my tests, but I'm going to check it once again if the problem still persists. |
Nope i only added |
I wasn't able to reproduce the problem. What OS do you use? If it's Ubuntu then its automatic modem probing may cause Photon's listening loop to exit early (and shut down SoftAP). |
I'm on Mac OSx |
I'm trying this code (with suggested
How can that be? Nevermind, it was the preprocessor again - |
what version of arm-gcc are you using? a workaround is to include string.h before softap_http.h. |
I just tried it with Particle Build and hence got bitten by the preprocessor. |
@ScruffR I was also getting the same error but when I write |
That was one of the first things I tried too 😉 |
Is this surposed to be working in web ide ? Even with the include softap_http, its missing 3 defs from that file. mysoftap.cpp:3:30: error: 'ResponseCallback' has not been declared |
I've added the necessary changes. The preprocessor is getting in the way. |
right that got it going, and I get the blue start page, then it goes to red SOS. |
I see the same. I don't know what has changed since making this PR but I can confirm the SOS. |
The code works great for me! No problem! Love this! |
@fotoKrille can you complete the scanning in the 192.168.0.1 webpage ? |
It seems that this is browser-specific. It works on Safari but not with Chrome on OSX. |
ahh, it happens when the browser accesses favicon.ico (for the site icon). { "/favicon.ico", "text/html", "" }, Ideally a lightweight particle icon could be used :) Should idx not be a int ?
That also prevents the error. |
I used my Microsoft Lumia 950 Edge browser. |
I'm seeing what looks like a compiler issue. If I build the system firmware locally it works fine, but when I use the one from the cloud it fails. |
Maybe the 2 compilers handle the unsigned issue differently ? idx is declared as an unsigned int (8). Declaring it as int8_t instead solves it on the webide. |
Good ideas, but sadly it's not that - I keep the same application binary but just change the system firmware, and that causes the fault. |
Ok, but the code is wrong anyway, a smal oversight, but enough to make it fail. Setting a unsigned value to -1 (which is not a valid value for unsigned) and then comparing it to -1, will only work if the compiler treats that -1 as a uint8_t also. I just retested the code with web ide, and that small unsigned change is the difference between red sos on unknown page or a working softAP webpage process for me. I am using google android browser, but to test I just accessed favicon.ico directly, when using uint8_t it goes to sos, when using int8_t I get a blank page as expected. |
You're totally right - this is a slur in the example code and definitely needs to be fixed! Thanks for pointing that out - I'll try that again when I circle back later today. |
I changed the uint8_t to int8_t and reflashed from the cloud - now it's working for me. @MORA99 thanks for picking up on that oversight! |
I get the following error when trying to compile this code: |
Please disregard, I had my electron selected instead of photon. |
@m-mcgowan Will your code above work with connecting to unsecured 'free Wi-FI' network (say at coffee shops, airport) that shows confirmation or terms and condition page? |
No sorry, it wouldn't work as is with a captive portal, as it's a different set of technology from what's being presented here. The captive portal is created by the external access point (which then may eventually time out the wifi connection if the user doesn't sign up/login etc..), while the http pages here are provided by the Photon's own internal access point. Buuuut...this got me thinking. In a future update, we could have the photon connect to the open network's captive portal (as a regular WiFi client), and simultaneously route the webpages presented via the SoftAP interface to the device that was already setting up the photon via HTTP. This would then allow the user to complete the signup or whatever is needed by the captive portal in order for it to whitelist the Photon's MAC address. At present the photon doesn't allow it to be both a wifi client and an access point so we can'd do this now. However, I am in the process of making that possible, so this would then be workable in practice! |
@m-mcgowan Thanks for clarifying, it will be huge to include free networks behind captive portals. How about free open networks that doesn't have captive portal, are those accessible using code above? |
Yes, free open networks will be available, just as if you were connecting to your own unsecured network at home. |
Hello @m-mcgowan, Which is this line is added for? #pragma SPARK_NO_PREPROCESSOR Is it necessary to include it ? |
It is necessary (or we wouldn't have added it! ;-)) Please see the docs here https://docs.particle.io/reference/firmware/photon/#preprocessor |
Actually, I take it back. The preprocessor has been updated in recent months to make it not necessary anymore. It was needed at the time the example was written. |
@m-mcgowan Thanks for removing my confusion. |
Allows the application to render HTTP pages in the softAP setup process.
This is the softAP setup app from #582 moved into the application domain: