Skip to content

Conversation

@finger563
Copy link
Contributor

@finger563 finger563 commented Jan 24, 2026

Description

  • Add Provisioning component example that demonstrates WiFi provisioning using the HTTP server method with both AP and STA modes.
  • Update Wifi component to better support AP, STA, APSTA, and handle better scanning for networks before, during, and after STA connection to remote AP.

Motivation and Context

WiFi provisioning is a common requirement for IoT devices. This example demonstrates how to implement WiFi provisioning using the HTTP server method, allowing users to easily connect their devices to a WiFi network.

Additionally, better support for scanning -> connect the STA to one of the found remote APs streamlines the process for both provisioning as well as programmatic execution.

How has this been tested?

  • Ran provisioning/example on QtPy ESP32-S3 board and ensured that the device can be provisioned to connect to a WiFi network using the HTTP server method.
  • Ran wifi/example on QtPy ESP32-S3 board and ensured that the tests all passed (using the new summary for clarity)

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Provisioning

Scanning for network and connecting:

scan image enter password image
connecting image connected image
provisioning completed image

Managing saved networks:

view image connect image
connected image delete image
I (415) main_task: Calling app_main()
[Provisioning Example/I][0.415]: Starting WiFi Provisioning Example
[Provisioning Example/I][0.415]: Initializing NVS...
[Provisioning/I][0.465]: Initialized with AP SSID: ESP-Prov-8590
[Provisioning Example/I][0.465]: Existing provisioned network SSID: HouseOfBoo
[WifiAp/I][0.465]: Creating network interface and ensuring WiFi stack is initialized
I (475) pp: pp rom version: e7ae62f
I (475) net80211: net80211 rom version: e7ae62f
I (495) wifi:wifi driver task: 3fcedc7c, prio:23, stack:6656, core=0
I (505) wifi:wifi firmware version: ee91c8c
I (505) wifi:wifi certification version: v7.0
I (505) wifi:config NVS flash: enabled
I (505) wifi:config nano formatting: disabled
I (505) wifi:Init data frame dynamic rx buffer num: 32
I (515) wifi:Init static rx mgmt buffer num: 5
I (515) wifi:Init management short buffer num: 32
I (525) wifi:Init dynamic tx buffer num: 32
I (525) wifi:Init static tx FG buffer num: 2
I (535) wifi:Init static rx buffer size: 1600
I (535) wifi:Init static rx buffer num: 10
I (535) wifi:Init dynamic rx buffer num: 32
I (545) wifi_init: rx ba win: 6
I (545) wifi_init: accept mbox: 6
I (545) wifi_init: tcpip mbox: 32
I (555) wifi_init: udp mbox: 6
I (555) wifi_init: tcp mbox: 6
I (555) wifi_init: tcp tx win: 5760
I (565) wifi_init: tcp rx win: 5760
I (565) wifi_init: tcp mss: 1440
I (565) wifi_init: WiFi IRAM OP enabled
I (575) wifi_init: WiFi RX IRAM OP enabled
[WifiAp/I][0.575]: Reconfiguring WiFi AP
[WifiAp/I][0.575]: WiFi AP stopped
I (585) phy_init: phy_version 711,97bcf0a2,Aug 25 2025,19:04:10
I (625) wifi:mode : softAP (f4:12:fa:5a:85:91)
I (625) wifi:Total power save buffer number: 16
I (625) wifi:Init max length of beacon: 752/752
I (625) wifi:Init max length of beacon: 752/752
I (635) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.4.1
[WifiAp/I][0.635]: WiFi AP started
[WifiAp/I][0.645]: WiFi AP started
[WifiAp/I][0.645]: WiFi AP started, SSID: 'ESP-Prov-8590'
[Provisioning/I][0.655]: Provisioning started at http://192.168.4.1
[Provisioning Example/I][0.655]: Provisioning started
[Provisioning Example/I][0.665]: Connect to WiFi network: ESP-Prov-8590
[Provisioning Example/I][0.675]: Open browser to: http://192.168.4.1
I (7265) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1, snd_ch_cfg:0x0
I (7265) wifi:station: a2:51:f2:06:a8:34 join, AID=1, bgn, 20
[WifiAp/I][7.265]: Station join, AID=1
I (7475) wifi:<ba-add>idx:2 (ifx:1, a2:51:f2:06:a8:34), tid:0, ssn:643, winSize:64
I (7695) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
I (7935) wifi:<ba-add>idx:3 (ifx:1, a2:51:f2:06:a8:34), tid:6, ssn:2922, winSize:64
[WifiAp/I][15.025]: Station leave, AID=1
I (15035) wifi:<ba-del>idx:2, tid:0
I (15035) wifi:<ba-del>idx:3, tid:6
I (15035) wifi:new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1, snd_ch_cfg:0x0
I (15035) wifi:station: a2:51:f2:06:a8:34 join, AID=1, bgn, 20
[WifiAp/I][15.045]: Station join, AID=1
I (15205) wifi:<ba-add>idx:2 (ifx:1, a2:51:f2:06:a8:34), tid:0, ssn:2714, winSize:64
I (15345) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.4.2
I (15655) wifi:<ba-add>idx:3 (ifx:1, a2:51:f2:06:a8:34), tid:6, ssn:3177, winSize:64
[Provisioning/I][17.785]: Starting WiFi scan...
I (17795) wifi:mode : sta (f4:12:fa:5a:85:90) + softAP (f4:12:fa:5a:85:91)
I (17795) wifi:enable tsf
I (20705) wifi:mode : softAP (f4:12:fa:5a:85:91)
[Provisioning/I][20.715]: Found 3 networks
[Provisioning/I][34.945]: Testing connection to: HouseOfBoo
[Provisioning/I][34.955]: Creating test WiFi STA instance
[WifiSta/I][34.955]: Creating network interface and ensuring WiFi stack is initialized
[WifiSta/D][34.965]: Adding event handler for WIFI_EVENT(s)
[WifiSta/D][34.965]: Adding IP event handler for IP_EVENT_STA_GOT_IP
[WifiSta/I][34.975]: Reconfiguring WiFi STA
[WifiSta/D][34.975]: Setting WiFi SSID to 'HouseOfBoo'
[WifiSta/D][34.985]: AP mode already active, setting mode to APSTA
[WifiSta/D][34.995]: Setting WiFi mode to WIFI_MODE_APSTA
I (35005) wifi:mode : sta (f4:12:fa:5a:85:90) + softAP (f4:12:fa:5a:85:91)
I (35005) wifi:enable tsf
[WifiSta/D][35.025]: Setting WiFi config
W (35025) wifi:Password length matches WPA2 standards, authmode threshold changes from OPEN to WPA2
[WifiSta/D][35.025]: WIFI_EVENT_STA_START - initiating connection
[WifiSta/D][35.035]: Setting WiFi PHY rate to MCS0_LGI (6.5-13.5 Mbps)
I (35045) wifi:primary chan differ, old=1, new=9, start CSA timer
[WifiSta/I][35.045]: WiFi STA reconfigured successfully
[WifiSta/D][35.055]: Starting WiFi
[WifiSta/I][35.055]: WiFi started
[WifiSta/I][35.065]: WiFi STA started, SSID: 'HouseOfBoo'
[Provisioning/I][35.065]: Waiting for connection (max 15 seconds)...
I (35445) wifi:switch to channel 9
I (35445) wifi:ap channel adjust o:1,1 n:9,2
I (35445) wifi:new:<9,0>, old:<1,0>, ap:<9,2>, sta:<0,0>, prof:1, snd_ch_cfg:0x0
I (35455) wifi:new:<9,2>, old:<9,0>, ap:<9,2>, sta:<9,0>, prof:1, snd_ch_cfg:0x0
I (35455) wifi:state: init -> auth (0xb0)
I (35475) wifi:state: auth -> assoc (0x0)
I (35495) wifi:state: assoc -> run (0x10)
I (35525) wifi:connected with HouseOfBoo, aid = 7, channel 9, BW20, bssid = 08:02:8e:8a:54:73
I (35525) wifi:security: WPA2-PSK, phy: bgn, rssi: -55
I (35525) wifi:pm start, type: 1

I (35525) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (35535) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 25000, mt_pti: 0, mt_time: 10000
I (35545) wifi:dp: 2, bi: 102400, li: 4, scale listen interval from 307200 us to 409600 us
I (35555) wifi:AP's beacon interval = 102400 us, DTIM period = 2
[WifiSta/D][35.565]: WIFI_EVENT_STA_CONNECTED - waiting for IP
I (36905) wifi:<ba-add>idx:0 (ifx:0, 08:02:8e:8a:54:73), tid:6, ssn:4, winSize:64
I (37905) esp_netif_handlers: sta ip: 192.168.1.25, mask: 255.255.255.0, gw: 192.168.1.1
[WifiSta/I][37.905]: got ip: 192.168.1.25
[Provisioning/I][37.905]: Connection callback - connected to AP
[Provisioning/I][37.905]: Got IP callback - 192.168.1.25
[Provisioning/I][38.015]: Connection test result: true (got_ip=true, failed=false)
[Provisioning/I][38.015]: Cleaning up test STA
[WifiSta/D][38.015]: Destroying WiFiSta
[WifiSta/D][38.015]: Unregistering event handlers
[WifiSta/D][38.025]: Unregistering any wifi event handler
[WifiSta/D][38.035]: Unregistering got ip event handler
[WifiSta/D][38.035]: In APSTA mode, disconnecting STA interface
I (38045) wifi:state: run -> init (0x0)
I (38065) wifi:pm stop, total sleep time: 1777943 us / 2533745 us

I (38065) wifi:<ba-del>idx:0, tid:6
I (38065) wifi:new:<9,0>, old:<9,2>, ap:<9,2>, sta:<9,0>, prof:1, snd_ch_cfg:0x0
I (38065) wifi:mode : softAP (f4:12:fa:5a:85:91)
[WifiSta/I][38.075]: WiFi STA disconnected, AP still running
[Provisioning/I][38.285]: Saving credentials for: HouseOfBoo
[Provisioning Example/I][40.965]: Provisioned successfully!
[Provisioning Example/I][40.965]:   SSID: HouseOfBoo
[Provisioning Example/I][40.965]:   Password: ********
[Provisioning Example/I][40.965]: Credentials saved to NVS
[Provisioning Example/I][41.085]: Provisioning completed by user, stopping service
I (41185) wifi:station: a2:51:f2:06:a8:34 leave, AID = 1, reason = 2, bss_flags is 33721443, bss:0x3fcb5a9c
I (41185) wifi:new:<9,0>, old:<9,0>, ap:<9,2>, sta:<255,255>, prof:1, snd_ch_cfg:0x0
I (41185) wifi:<ba-del>idx:2, tid:0
I (41195) wifi:<ba-del>idx:3, tid:6
I (41195) wifi:new:<9,2>, old:<9,0>, ap:<9,2>, sta:<255,255>, prof:1, snd_ch_cfg:0x0
I (41255) wifi:flush txq
I (41255) wifi:stop sw txq
I (41255) wifi:lmac stop hw txq
[WifiAp/I][41.255]: WiFi AP stopped
[Provisioning/I][41.255]: Provisioning stopped
[Provisioning Example/I][41.255]: Provisioning example finished

Wifi

==========================================================
[wifi_example/I][67.154]:                     TEST SUMMARY
[wifi_example/I][67.154]: ==========================================================
[wifi_example/I][67.154]: ✓ PASS: Scan before STA connect - Connected, IP: 192.168.1.25
[wifi_example/I][67.154]: ✓ PASS: Switch to AP - AP ready, IP: 192.168.4.1
[wifi_example/I][67.164]: ✓ PASS: Switch to STA - Connected, IP: 192.168.1.25
[wifi_example/I][67.164]: ✓ PASS: Switch back to AP - AP ready, IP: 192.168.4.1
[wifi_example/I][67.164]: ✓ PASS: Stop WiFi - WiFi stopped successfully
[wifi_example/I][67.164]: ==========================================================
[wifi_example/I][67.164]: Total: 5 | Passed: 5 | Failed: 0
[wifi_example/I][67.174]: ==========================================================

[wifi_example/I][67.174]: WiFi example complete!

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Copilot AI review requested due to automatic review settings January 24, 2026 22:26
@github-actions
Copy link

github-actions bot commented Jan 24, 2026

✅Static analysis result - no issues found! ✅

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Provisioning component and example that implement web-based WiFi provisioning over an embedded HTTP server (AP + STA scanning/connection test), along with supporting documentation and build configuration.

Changes:

  • Introduces espp::Provisioning component (HTTP server + HTML UI) with scan/connect/complete endpoints and basic credential persistence.
  • Adds a provisioning example project (CMake, partitions, sdkconfig defaults, Kconfig, README).
  • Adds component metadata/manifests and README documentation for the new component.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
components/provisioning/src/provisioning.cpp Implements HTTP server handlers, web UI generation, WiFi scan/connect test flow, and NVS-based saved-network storage.
components/provisioning/include/provisioning.hpp Declares the Provisioning API/config and handler/helper methods.
components/provisioning/idf_component.yml Component-manager manifest for the new component.
components/provisioning/CMakeLists.txt Build registration for the new component.
components/provisioning/README.md Component usage documentation and example snippet.
components/provisioning/example/CMakeLists.txt Example project build configuration.
components/provisioning/example/README.md Example usage documentation and configuration guidance.
components/provisioning/example/sdkconfig.defaults Default sdkconfig settings for the example build.
components/provisioning/example/partitions.csv Partition table for the example (NVS + factory app).
components/provisioning/example/main/CMakeLists.txt Example main component build configuration.
components/provisioning/example/main/Kconfig.projbuild Adds menuconfig options for the example.
components/provisioning/example/main/provisioning_example.cpp Example app demonstrating provisioning flow and saving credentials.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@finger563 finger563 merged commit 0dc9540 into main Jan 25, 2026
102 of 103 checks passed
@finger563 finger563 deleted the feat/provisioning branch January 25, 2026 17:03
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.

2 participants