Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maximkulkin/esp-wifi-config
Library to bootstrap WiFi-enabled accessories WiFi config
https://github.com/maximkulkin/esp-wifi-config
configuration esp-open-rtos esp8266 wifi
Last synced: 3 months ago
JSON representation
Library to bootstrap WiFi-enabled accessories WiFi config
- Host: GitHub
- URL: https://github.com/maximkulkin/esp-wifi-config
- Owner: maximkulkin
- License: mit
- Created: 2018-01-05T01:06:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-08T03:14:04.000Z (over 2 years ago)
- Last Synced: 2024-10-11T15:09:43.731Z (3 months ago)
- Topics: configuration, esp-open-rtos, esp8266, wifi
- Language: C
- Size: 33.2 KB
- Stars: 54
- Watchers: 9
- Forks: 30
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esp-wifi-config
Library for esp-open-rtos to bootstrap WiFi-enabled accessories WiFi configLibrary uses sysparams to store configuration. When you initialize it
it tries to connect to configured WiFi network. If no configuration exists or
network is not available, it starts it's own WiFi AP (with given name and
optional password). AP runs a captive portal, so when user connects to it a
popup window is displayed asking user to select one of WiFi networks that are
present in that location (and a password if network is secured) and configures
device to connect to that network.After successful connection it calls provided callback so you can continue
accessory initializiation.# Example: ::
```c
#include
#include#include "wifi_config.h"
void on_wifi_event(wifi_config_event_t event) {
if (event == WIFI_CONFIG_CONNECTED) {
printf("Connected to WiFi\n");
} else if (event == WIFI_CONFIG_DISCONNECTED) {
printf("Disconnected from WiFi\n");
}
}void user_init(void) {
uart_set_baud(0, 115200);wifi_config_init2("my-accessory", "my-password", on_wifi_event);
}
```# Custom HTML
If you want a custom look, you can provide your own HTML for WiFi settings page.
To do that, in your project's Makefile define variable WIFI_CONFIG_INDEX_HTML with
path to your custom HTML file.# UI Development
UI content is located in content/index.html (which is actually Jinja2 template).
To simplify UI development this there is a simple server you can use to see
how HTML will be rendered. To run it, you will need Python runtime and Flask python
package.pip install flask
Then run server with
tools/server.py
and connect to http://localhost:5000/settings with your browser. That URL shows
how settings page will look like with some combination of secure & unsecure
networks. http://localhost:5000/settings0 URL shows page when no WiFi networks
could be found.On build template code will be split into parts (marked with `` comments). In all parts all Jinja code blocks (`{% %}`) are removed and all
output blocks (`{{ }}`) are replaced with `%s`. HTML_SETTINGS_HEADER and
HTML_SETTINGS_FOOTER parts are output as-is while HTML_NETWORK_ITEM is assumed to
have two `%s` placeholders, first of which will be "secure" or "unsecure" and
second one - name of a WiFi network.To run server against your custom HTML, set environment variable
WIFI_CONFIG_INDEX_HTML before your run tools/server.py:export WIFI_CONFIG_INDEX_HTML=my_wifi_config.html
path/to/your/wifi-config/tools/server.py