Skip to content

Commit 88aa141

Browse files
authored
Update README.md
1 parent 082cd0c commit 88aa141

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Configuring the Wifi Manager](#configuring-the-wifi-manager)
2020
- [Adding esp32-wifi-manager to your code](#adding-esp32-wifi-manager-to-your-code)
2121
- [Interacting with the manager](#interacting-with-the-manager)
22+
- [Interacting with the http server](#interacting-with-the-http-server)
2223
- [License](#license)
2324

2425

@@ -146,10 +147,46 @@ void cb_connection_ok(void *pvParameter){
146147
Then just register it by calling:
147148
148149
```c
149-
wifi_manager_set_callback(EVENT_STA_GOT_IP, &cb_connection_ok);
150+
wifi_manager_set_callback(WM_EVENT_STA_GOT_IP, &cb_connection_ok);
150151
```
151152

152153
That's it! Now everytime the event is triggered it will call this function. The [examples/default_demo](examples/default_demo) contains sample code using callbacks.
153154

155+
### List of events
156+
157+
The list of possible events you can add a callback to are defined by message_code_t in wifi_manager.h. They are as following:
158+
159+
* WM_ORDER_START_HTTP_SERVER
160+
* WM_ORDER_STOP_HTTP_SERVER
161+
* WM_ORDER_START_DNS_SERVICE
162+
* WM_ORDER_STOP_DNS_SERVICE
163+
* WM_ORDER_START_WIFI_SCAN
164+
* WM_ORDER_LOAD_AND_RESTORE_STA
165+
* WM_ORDER_CONNECT_STA
166+
* WM_ORDER_DISCONNECT_STA
167+
* WM_ORDER_START_AP
168+
* WM_EVENT_STA_DISCONNECTED
169+
* WM_EVENT_SCAN_DONE
170+
* WM_EVENT_STA_GOT_IP
171+
* WM_ORDER_STOP_AP
172+
173+
In practice, keeping track of WM_EVENT_STA_GOT_IP and WM_EVENT_STA_DISCONNECTED is key to know whether or not your esp32 has a connection. The other messages can mostly be ignored in a typical applicationn using esp32-wifi-manager.
174+
175+
## Interacting with the http server
176+
177+
Because esp32-wifi-manager spawns its own http server, you might want to extend this server to serve your own pages in your application. It is possible to do so by registering your own URL handler using the standard esp_http_server signature:
178+
179+
```c
180+
esp_err_t my_custom_handler(httpd_req_t *req){
181+
```
182+
183+
And then registering the handler by doing
184+
185+
```c
186+
http_app_set_handler_hook(HTTP_GET, &my_custom_handler);
187+
```
188+
189+
The [examples/http_hook](examples/http_hook) contains an example where a web page is registered at /helloworld
190+
154191
# License
155192
*esp32-wifi-manager* is MIT licensed. As such, it can be included in any project, commercial or not, as long as you retain original copyright. Please make sure to read the license file.

0 commit comments

Comments
 (0)