-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
End User Setup: Save the post data in a file on the filesystem #2493
Conversation
- make the scanning work - since we now use a POST, we need to redirect to the same page with a specific mode (trying=true) so that the page displays the "wait for it" message
Yes, I took up his branch and actualy ended up rewriting the entirety of the patch to be able to use POST instead of GET. Sorry for the acronym, I'm not that good in Lua.. :) |
I have the feeling that the method "eus.start()" should allow to enable/disable the write to file, otherwise we well always write them out, which might not be necessary. |
Thanks @Gui13. I like the way you laid the code out. Glad someone was able to come in and complete the code. When I finally get back around to my project I'll attempt it off your code. |
I agree @Gui13 do you have plans to address this before we merge? |
This is great I have been waiting for this for a long time. Is there any documentation on how to access this e.g. modify the web page to add custom fields to be collected during the AP sign in/set up process and also how to access them once AP setup is completed? I would really like to do some testing before this is merged possibly give some additional feedback. |
Great! If you look at the files this PR changes (tab at the top) you'll also find the updated documentation: https://github.com/nodemcu/nodemcu-firmware/blob/95c07234f1eae1d43eb46541cfa55b6c0f0c25ec/docs/en/modules/enduser-setup.md |
Thanks! perfect exactly what I was looking for. I'll let you know how it goes. |
@marcelstoer I can look into adding a function parameter, indeed. Give me a couple of days (this is a week end project..) |
I need to create my firmware build from the dev branch correct? Sorry if this is stupid question I've been away for a while. |
I've been stressing for a while now that "Host name" should be part of the default along with SSID and PW. Hostname is a critical part of any device setup in my opinion. It should automatically be stored so the device can be accessed as 'http://kitchen:1234' It would save a step for certain otherwise one has to go into their router and/or hosts file to set this up. My particular router has the capability of doing the DNS as long as the host name is set. |
The code will only be on |
Is there any ETA on when the merge will be done to dev? |
As soon as you're done testing 😜 Seriously, I take it building your own firmware is too much of an obstacle; no problem. I built a binary from that branch and attached it as ZIP here:
|
Bless you. ha..... I'll admit I had no idea how to do that thanks for building this for me. I'm going to flash this, this afternoon, and begin doing some testing hopefully |
Marcel, Thanks very much for the bin file. I flashed it could I ask you to create a new one and include SNTP? My project includes that and getting errors because it is missing. Despite that there appears to be issues with the web page/module itself I think. I think there is a problem with the wifi scanner drop down I want to research. |
I found a couple of issues with the stock web page enduser_setup.html
Opps must not have tested with IE this won't work in IE (at least not IE 11. Chrome seemed fine It also fails to return anything when you save the parms. They do actually save and I've confirmed and eus_parms.lua file contains the values I have selected along with the new "hostname" field I added. |
Since all browsers don't support URLSearchParams API I've updated and added a routine to properly parse those. I've also update the items I mentioned with regards to the ID's
however this reports back an error instead of showing the IP address assigned. Also it does not show "Success" on the AP setup web page. Not sure if that is something in the module itself or the web page enduser_setup: Err #3: 1693: dns_recv_callback failed. Send UDP data failed |
It appears to be something tied to the enduser_setup(true) which I did so I could set up a specific SSID to make it easy for the end user in my application and documentation.
However when this is commented out it falls back on the SSID as being "SetupGadgetxxxxx" |
Another feature consideration fetch any of the parms set in eus parm file created from the post. This would allow us to populate additional div elements other than
and possibly the SSID and PW as well to insure that what was stored was correct. Obviously if it connects and we get success we know but it would still be nice to be able to see this information as an option. |
It drove crazy for about a day and a half. I managed to get the pamrs from the eus_params.lua file for ssid, password and hostname. I was able to parse out the file to parms array so
hostname happened to be last in the file and contained a line feed that sethostname would not accept and threw an error. Once I striped the line feed it worked fine. Not sure if that is something that the code should do when writing the file and/or it should be documented in the command. |
the other thing I just noticed that needs stripped for this to work properly is the data is stored in the file with double quotes and line feeds. |
Hi @davidcbittner, would you share the code you used to make the JS "UrlSearchParam" work on IE? Otherwise, the dofile("eus_params.lua")
-- use parameters by their names (wifi_ssid, wifi_password etc.)
print("wifi_ssid=" .. wifi_ssid )
print("wifi_password=" .. wifi_password ) |
Also, you were right about the missing 'id'. I had it lingering on my local changes.. sorry. |
Gui13, I don't know what I was thinking but you are correct dofile("eus_params.lua") I went crazy there for a bit and wrote a bunch of code that I didn't need to.. thanks. Here is what I did to the web page to parse out the parms for the callback to it. a simple regular expression to pull those out works in both IE and Chrome... probably safari as well but I didn't test it. I also have the entire web page as a txt file above. Also I was going to do a validate on form submit because the hostname has some constraints:
|
General note... @Gui13 it would be great if you could verify if/that David's comments and questions are addressed in the module documentation. I consider it likely that if things are unclear for David they are unclear for others as well 😄Same goes vice-versa for David: I invite you to propose changes to the documentation to enhance their expressiveness. |
Ok I'll add some doc on how to use the file. Regarding the IE compatibility, I have found the "polyfill" for it in a few lines, I have added it. |
@marcelstoer should be good now. @davidcbittner if you would like to test again with this version, be my guest! |
Thanks but that's not necessary. GitHub allows us to squash & merge with a single click. |
marcel could you build a new firmware for me and include the sntp this time? I will test this starting today if you can. |
David, I can't verify the firmware I just built for you atm but here it is: https://transfer.sh/wHpPy/nodemcu_float_eus_params_post_20181130-1048.bin |
hi david and marcel, sadly there is a problem within the "enduser_setup_http_handle_credentials" function: nodemcu-firmware/app/modules/enduser_setup.c Line 809 in 2c49558
|
marcel, thanks I got sidetracked with my day job yesterday. I will give this a try today. |
I think that this module should be divide to captive portal and set wifi. developer can implement other interesting web application the help of the captive portal |
I agree with @hanfengcan, the captive portal should be a module to upload configuration or any application required data to a JSON SPIFFS file that can then be used by the Lua application for anything. |
@hanfengcan, @NicolSpies I tend to agree with you but this is the wrong place for such a fundamental proposal IMO. We're trying to get this PR to a ready-for-merging state. Regardless of the issues this module has the features in this PR are a significant step forward. Feel free to propose this in a new feature but keep #1010 in mind. |
@marcelstoer I am so sorry. I am just trying to express myself. maybe I can divide the module and push a new PR. of course, I am looking forward to this merger. |
so looking forward to this feature. Are all form values double-quoted in eus_params.lua making them strings? I am not fluent in Lua, but is it expected that numeric values will need to be cast before usage? |
Superseded by #2810. |
Possibly Fixes #1302, and is a follow up on #2132 .
dev
branch rather than formaster
.docs/en/*
.Several PR have tried to implement this, and I took to myself to try and finish this.
The idea is to save the parameters that the user sent in his EndUser setup into a file on the ESP filesystem.
Once we have that, you can modify the eus HTML file and add several fields that will be sent along with the wifi credentials. These fields and values will be saved in a LUA file on the filesystem, that you can now load when needed to access it.
I implemented several things:
I have tested the code in a separate standalon project with Valgrind for the parsing/fill up of the struct part, and I'm fairly confident that it should be leak free.
As an MVP2, we could also pass the onConnected callback a structured LUA table which contains all the variables set in the POST.
Please, feel free to suggest code enhancements, my C is a bit rusty.