Skip to content
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

Add support for open networks to enduser_setup #3392

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

blobule
Copy link
Contributor

@blobule blobule commented Jan 31, 2021

Fixes #3374.

  • This PR is for the dev branch rather than for the release branch.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

I fixed the bug, making sure an open network (without password) is handled correctly.
I tested it and it works perfectly.

@blobule
Copy link
Contributor Author

blobule commented Jan 31, 2021

I compiled nodemcu for the first time to fix this bug, and it was a great experience. Congratulation for such a nice compiling setup.
I've been using nodemcu for years, but this is a first for me.
I hope this PR is satisfactory.

Should we add in the docs of enduser_setup a complete example of an adequate boot process (init.lua)?
Something like this...

print("Wating 10 seconds. Use t:stop() to cancel the init process...")
t=tmr.create()
t:alarm(10000,tmr.ALARM_SINGLE,function ()
	if wifi.sta.getip() then
		print("Wifi activated",wifi.sta.getip())
		dofile("go.lua")
	else
		print("No Wifi. Starting portal...")
		enduser_setup.start(
		  "Nodemcu setup",
		  function()
			wifi.sta.autoconnect(1)
			print("Wifi activated",wifi.sta.getip())
			dofile("go.lua")
		  end,
		  function(err, str)
		    print("enduser_setup: Err #" .. err .. ": " .. str)
		    -- schedule reboot?
		  end
		)
	end
end)

It would be nice to have such an example chunk for init.lua

@blobule blobule closed this Jan 31, 2021
@blobule blobule reopened this Jan 31, 2021
@marcelstoer marcelstoer changed the title solved open network issue3374 Add support for open networks to enduser_setup Feb 1, 2021
Copy link
Member

@HHHartmann HHHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest looks good.

if (name_str == NULL || pwd_str == NULL)

// in case we dont get a passwd (for open networks)
if (pwd_str == NULL) { pwd_str="wifi_password="; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an ENDUSER_SETUP_DEBUG note about this.
Maybe

ENDUSER_SETUP_DEBUG("Password string not found. Setting to empty");

// in case we dont get a passwd (for open networks)
if (pwd_str == NULL) { pwd_str="wifi_password="; }

if (name_str == NULL)
{
ENDUSER_SETUP_DEBUG("Password or SSID string not found");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adapt the Message. "SSID string not found"

@HHHartmann
Copy link
Member

I compiled nodemcu for the first time to fix this bug, and it was a great experience. Congratulation for such a nice compiling setup.

Wellcome to the club!

Should we add in the docs of enduser_setup a complete example of an adequate boot process (init.lua)?
Something like this...

print("Wating 10 seconds. Use t:stop() to cancel the init process...")
t=tmr.create()
t:alarm(10000,tmr.ALARM_SINGLE,function ()
	if wifi.sta.getip() then
		print("Wifi activated",wifi.sta.getip())
		dofile("go.lua")
	else
		print("No Wifi. Starting portal...")
		enduser_setup.start(
		  "Nodemcu setup",
		  function()
			wifi.sta.autoconnect(1)
			print("Wifi activated",wifi.sta.getip())
			dofile("go.lua")
		  end,
		  function(err, str)
		    print("enduser_setup: Err #" .. err .. ": " .. str)
		    -- schedule reboot?
		  end
		)
	end
end)

It would be nice to have such an example chunk for init.lua

The lua_examples folder would be a nice place for that. Maybe write a comment about what go.lua is (I can guess, but just to be clear)
Also set t=nil at the end
Maybe have some emphasis on waiting for Wifi too.

I think a different PR would be good for that.

@marcelstoer
Copy link
Member

The lua_examples folder would be a nice place for that....
I think a different PR would be good for that.

Yes, and then link to it from the docs.

@marcelstoer
Copy link
Member

Oh, it's already here: #3395

@marcelstoer marcelstoer added this to the Next release milestone Feb 2, 2021
@marcelstoer
Copy link
Member

marcelstoer commented Mar 12, 2021

@blobule could you please address Gregor's comments?

@marcelstoer marcelstoer removed this from the Next release milestone Nov 19, 2021
@marcelstoer marcelstoer merged commit 604bca0 into nodemcu:dev Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants