wifi-connect icon indicating copy to clipboard operation
wifi-connect copied to clipboard

Adding new forms to index.html

Open koosthoe opened this issue 6 years ago • 19 comments

I am trying to add a new form to the index.html file. I need to be able to take this form data and save it to a text file for use in another script. Do I have to do this before I install wifi-connect? I cant find any other files other then those in the UI directory to send this new form data to.

koosthoe avatar Apr 03 '18 19:04 koosthoe

@koosthoe very sorry for the late response.

I opened now a separate related issue, since this is a common request: https://github.com/resin-io/resin-wifi-connect/issues/203

The idea is to make the listening port configurable, so that you can run your own web application using a forked version of our UI. This way you will be able to run a simple web application listening on port 80, that may handle the form data, and then direct only the needed information to our JSON API, so that the network connectivity is established.

I am going to PR the other issue now. Please let me know if you have any questions.

majorz avatar Apr 06 '18 10:04 majorz

so do I have to reinstall wifi-connect? Could you give me a step by step on how to establish this connection? Thank you

koosthoe avatar Apr 06 '18 13:04 koosthoe

@koosthoe hopefully by the end of the week I will have documentation and a working example for this. I will ping you once ready so that you may try it out.

majorz avatar Apr 10 '18 07:04 majorz

Thank you. Much appreciation

koosthoe avatar Apr 10 '18 13:04 koosthoe

any updates?

koosthoe avatar Apr 18 '18 18:04 koosthoe

I will work today on this one. I was busy with another project and could not get anything done. I will update you by the end of today. Cheers!

majorz avatar Apr 19 '18 06:04 majorz

I created an example repository here that you may check out: https://github.com/resin-io-projects/resin-wifi-connect-api

I am awaiting for this PR so that the example above can work: https://github.com/resin-io/resin-wifi-connect/pull/209

I will post more information once the PR is merged and there is a new release.

majorz avatar Apr 19 '18 15:04 majorz

any update on this?

koosthoe avatar Jun 04 '18 20:06 koosthoe

@koosthoe the https://github.com/resin-io-projects/resin-wifi-connect-api is functioning properly since that PR was merged a while ago. I had to work on a different project in the past weeks, but now I am back on WiFi Connect. Currently working on enterprise authentication. For now you may use the above project as a reference (it is not documented unfortunately, but the code is simple). After I am done with enterprise I will get back to working on the WiFi Connect API and everything will be documented well after the first version of the API is finalized.

majorz avatar Jun 06 '18 06:06 majorz

@majorz It seems like the functionality is already in place for an end-user-defined web server to listen on port 80, is that correct? From the example, as long as the --portal-listening-port 45454 is set, then any web traffic to port 80 should be available for a custom processing (please correct me if I'm wrong!).

Is the issue still open because of pending documentation updates?

charliesneath avatar Feb 05 '19 02:02 charliesneath

hey @charliesneath ! Quick question - did you make a miracle happen and get this working? I'm trying to insert additional fields as well and would love your POV on how it went for you (and how/if you used the python API @majorz published).

Thanks man!

electric1490 avatar Mar 23 '19 18:03 electric1490

@electric1490 I haven't investigated any further, but it as long as you have wifi-connect configured to use port 45454 and the Flask server is running on port 80, then responding to any web traffic should be possible.

charliesneath avatar Mar 23 '19 18:03 charliesneath

@charliesneath thanks for the lightning fast response. I'm going to play around with it today and let you know if I need any other pointers. Caution, there might be another dumb one. Either way, I'll post my results for anyone else working this as well. Thanks!

electric1490 avatar Mar 23 '19 18:03 electric1490

okay - after playing with it, here's the latest update. @majorz , would you be able to do me a huge favor and let me know if I'm on the right track or smoking something fierce?

  1. Installed Wifi-Connect. Works great as designed (running it on a Raspberry Pi). Can connect no problem at all. Bing bam boom.

However, my main goal is to add a custom field to index.html, take that custom field and write that value string to a file on the local machine. With that, below is the latest:

  1. Using the terminal, I start up wifi-connect using the following command: pi@raspberrypi: $ wifi-connect --portal-listening-port 45454
  2. Quickly thereafter, start up wifi-connect-api (with adjusted index.html) using the following command: pi@raspberrypi: $ ~/wifi-connect-api/web-app $ sudo python web-app.py

From there, access point pops online successfully. When I connect to the WiFi Connect access point, I get the adjusted index.html portal. Good news there. However, when I fill out the field in the adjusted index.html and hit submit, I get the error [wifi_connect::server:ERROR] ''ssid' not found int he request params: {"custom": "user generated entry""} For the sake of clarity, I uploaded an image of the methodology/output here: https://imgur.com/a/aucxPii

Overarching question: am I going about this the correct way? Is this how to properly secure that custom field? I feel like I'm close but also could be way far away.

Any insight or next step guidance would be amazing. Thanks so much!

electric1490 avatar Mar 23 '19 20:03 electric1490

hey @majorz !

would be able to lend your point of view on the above? I keep trying to find a solve for this (even going thru CircleCI to adjust server.rs and index.html) but I'm not having any luck. Would be amazing to get a point in the right direction.

Thanks so much!

electric1490 avatar Mar 30 '19 23:03 electric1490

@electric1490 sorry for the late response. I have not seen the last message on my email :/ Thanks for the ping.

I am actually reworking right now the API example code so that the above error is handled, and also I am working on spawning wifi-connect as a subprocess to the example web server. I will should have it ready in the following days this week. I am going to post a response here once done.

majorz avatar Apr 01 '19 08:04 majorz

@majorz Perfect! No worries at all. Any insight here is hugely appreciated :)! I'll hang tight as you work thru the details.

I'd actually be happy to help compile a quick RPi "how-to" documentation for the API Example Code if you think that might be helpful. It seems like this is a popular ask and would love to help where possible. Not sure if balena is cool w/that. No worries either way.

Thanks, chat soon!

electric1490 avatar Apr 01 '19 23:04 electric1490

@electric1490 I made the changes to the API example repo. Now it runs in a single-container application and wifi-connect is spawned as a subprocess. Also latest wifi-connect is used.

However I still need to connected the stdout of wifi-connect to the web application. I tried this, but I will need some more time to get it right.

Afterwards I will start documenting all the steps and you may help me out with a review.

majorz avatar Apr 04 '19 11:04 majorz

Hi @majorz ! I would just like to ask if by any chance you guys have documentation available for this for those who aren't using a docker setup?

FaitAccompli avatar Aug 28 '20 04:08 FaitAccompli