mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-16 20:52:57 +08:00
86839d6e71
Fixes: * Removed spurious \0 bytes being sent to the client in many cases. * Properly terminated 404 header. * Now including Content-length: header for index.html (including built-in). Clients otherwise had to wait for their own timeout before considering the page load complete, which resulting in an unpleasant sluggish experience. * Switched form submission to GET, as iOS sometimes does not include the body in the same packet as the POST header, which led to the module not finding the form values. * Added redirect after form submission to avoid blank-page-in-browser. * Moved common "enduser_setup" prefix to a lua_pushfstring() to reduce string literal overhead. * Replaced cached lua_State* with calls to lua_getstate(), as in other modules. * Fixed broken appending of MAC to the SSID. * Fixed up macro definitions to not break `if` clauses unintentionally. Enhancements: * Support for scanning for available WiFi networks, and picking from the list. * Support for retrieving the current WiFi station status. * Added "manual" mode, where the module does not (re)configure the AP setup, nor shut down automatically. Default is still automatic, as before. * Updated docs for new `enduser_setup.manual()` function.
65 lines
2.5 KiB
Markdown
65 lines
2.5 KiB
Markdown
# enduser setup Module
|
|
This module provides a simple way of configuring ESP8266 chips without using a serial interface or pre-programming WiFi credentials onto the chip.
|
|
|
|
![enduser setup config dialog](../../img/enduser-setup.jpg "enduser setup config dialog")
|
|
|
|
After running [`enduser_setup.start()`](#enduser_setupstart) a portal like the above can be accessed through a wireless network called SetupGadget_XXXXXX. The portal is used to submit the credentials for the WiFi of the enduser.
|
|
After an IP address has been successfully obtained this module will stop as if [`enduser_setup.stop()`](#enduser_setupstop) had been called.
|
|
|
|
## enduser_setup.manual()
|
|
|
|
Controls whether manual AP configuration is used.
|
|
|
|
By default the `enduser_setup` module automatically configures an open access point when starting, and stops it when the device has been successfully joined to a WiFi network. If manual mode has been enabled, neither of this is done. The device must be manually configured for `wifi.SOFTAP` mode prior to calling `enduser_setup.start()`. Additionally, the portal is not stopped after the device has successfully joined to a WiFi network.
|
|
|
|
Most importantly, *the `onConfigured()` callback is not supported in manual mode*. This limitation may disappear in the future.
|
|
|
|
#### Syntax
|
|
`enduser_setup.manual([on_off])`
|
|
|
|
#### Parameters
|
|
- `on_off` a boolean value indicating whether to use manual mode; if not given, the function only returns the current setting.
|
|
|
|
#### Returns
|
|
The current setting, true if manual mode is enabled, false if it is not.
|
|
|
|
## enduser_setup.start()
|
|
|
|
Starts the captive portal.
|
|
|
|
#### Syntax
|
|
`enduser_setup.start([onConfigured()], [onError(err_num, string)], [onDebug(string)])`
|
|
|
|
#### Parameters
|
|
- `onConfigured()` callback will be fired when an IP-address has been obtained, just before the enduser_setup module will terminate itself
|
|
- `onError()` callback will be fired if an error is encountered. `err_num` is a number describing the error, and `string` contains a description of the error.
|
|
- `onDebug()` callback is disabled by default. It is intended to be used to find internal issues in the module. `string` contains a description of what is going on.
|
|
|
|
#### Returns
|
|
`nil`
|
|
|
|
#### Example
|
|
```lua
|
|
enduser_setup.start(
|
|
function()
|
|
print("Connected to wifi as:" .. wifi.sta.getip())
|
|
end,
|
|
function(err, str)
|
|
print("enduser_setup: Err #" .. err .. ": " .. str)
|
|
end
|
|
);
|
|
```
|
|
|
|
## enduser_setup.stop()
|
|
|
|
Stops the captive portal.
|
|
|
|
#### Syntax
|
|
`enduser_setup.stop()`
|
|
|
|
#### Parameters
|
|
none
|
|
|
|
#### Returns
|
|
`nil`
|