logo elektroda
logo elektroda
X
logo elektroda

Creating a web page on the ESP32 as a softAP with POST and GET methods - IDF

dondu 2436 12
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19187525
    dondu
    VIP Meritorious for electroda.pl
    Posts: 13906
    Help: 1292
    Rate: 809
    Hi,

    I don't work much on ESP32, but I have a project behind me working as a web page controlling relays. The ESP32 is connected via wifi to a router.

    I have also run the softAP example, it works, you can connect to it.

    Now I need to put up a softAP that generates its own web page, which I can connect to via Wifi and pass it data via POST or GET methods and get a response.

    I can't find an example of such a solution for IDF, hence the request for hints.

    For the uninitiated in IDF ... it is not about Arduino examples :) .
  • ADVERTISEMENT
  • #3 19187967
    dondu
    VIP Meritorious for electroda.pl
    Posts: 13906
    Help: 1292
    Rate: 809
    Thank you, but I have a problem.
    There are softAP and station folders in the esp-idf\exampleswifigetting_started folder.
    I copied the softAP to the softAP_dd folder and in the esp-idf\examples\wifigetting_started\softAP_dd\main_softap_example_main.c file
    I have replaced the program code with the one indicated by you.

    Unfortunately at compile time I get, the error I have included in the attachment (the electrode form does not want to accept it). What could be the cause?
    Attachments:
    • log.txt (945 Bytes) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #4 19188010
    Anonymous
    Level 1  
  • Helpful post
    #5 19192052
    faber
    Level 24  
    Posts: 701
    Help: 49
    Rate: 36
    Or this change to softAP_dd messed up the paths.
    Makefile: PROJECT_NAME := wifi_softAP ?? to wifi_softAP_dd ??
  • ADVERTISEMENT
  • #6 19192477
    dondu
    VIP Meritorious for electroda.pl
    Posts: 13906
    Help: 1292
    Rate: 809
    faber wrote:
    Or this change to softAP_dd messed up the paths.
    Makefile: PROJECT_NAME := wifi_softAP ?? to wifi_softAP_dd ??
    .
    Yes, I think that was the problem, although the swap itself didn't help. But when I made a new folder again with the contents of the example and renamed the project in the makefiles, this time it compiled correctly.

    However, there are warnings about outdated functions used in the example pointed out by khoam. I will check in the documentation.
    Attachments:
    • log.txt (2.12 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #8 19192674
    Anonymous
    Level 1  
  • #9 19192890
    dondu
    VIP Meritorious for electroda.pl
    Posts: 13906
    Help: 1292
    Rate: 809
    Note on arduino to sift out such hints.

    Actually I did not specify - installed about 2 months ago + Visual Studio Code. How do you check the version after installation?
  • Helpful post
    #10 19192912
    Anonymous
    Level 1  
  • #11 19192972
    dondu
    VIP Meritorious for electroda.pl
    Posts: 13906
    Help: 1292
    Rate: 809
    Thanks. 4.3.0
    I will write when I have problems with the change to ESP-NETIF.
  • #13 19193072
    dondu
    VIP Meritorious for electroda.pl
    Posts: 13906
    Help: 1292
    Rate: 809
    OK, I wasn't the one installing on this computer. Thanks for pointing it out.

Topic summary

✨ The discussion revolves around creating a web page on the ESP32 configured as a softAP, allowing data transmission via POST and GET methods using the ESP-IDF framework. The user initially faced issues compiling a modified example from the ESP-IDF softAP directory. Suggestions included removing the static qualifier from the launchSoftAp() function and ensuring the Makefile project name was correctly updated. The user later resolved compilation issues by creating a new folder and renaming the project in the Makefiles. They also encountered warnings regarding outdated functions and were directed to the ESP-IDF documentation for updates. The user confirmed using ESP-IDF version 4.3.0, which is not yet stable, while the last official release is version 4.2.
Generated by the language model.

FAQ

TL;DR: Build an ESP32 softAP web UI with POST/GET in ESP‑IDF. Since v4.1, "ESP‑NETIF replaces TCP/IP Adapter", so update APIs and examples before compiling. Use esp_http_server for handlers. ["TCP/IP Adapter Migration (ESP‑IDF)"]

Why it matters: It avoids deprecation warnings and link errors while enabling a clean POST/GET workflow in ESP‑IDF.

For: ESP‑IDF users who want a softAP-hosted web page with form/JSON exchange, without Arduino.

Quick Facts

  • ESP‑IDF v4.1+ adopts ESP‑NETIF; legacy tcpip_adapter APIs are deprecated and require migration. ["TCP/IP Adapter Migration (ESP‑IDF)"]
  • ESP32 SoftAP supports up to 10 client stations; default max_connection is typically 4. Tune for memory. ["ESP‑IDF Wi‑Fi API"]
  • Check your ESP‑IDF version in components/esp_common/include/esp_idf_version.h. [Elektroda, khoam, post #19192912]
  • If you copy an example, update PROJECT_NAME in build files to match the new folder to prevent path errors. [Elektroda, dondu, post #19192477]
  • During the referenced thread, v4.2 was the latest stable release; prefer a tagged release over master. ["ESP‑IDF v4.2 Release"]

How do I create an ESP32 softAP that serves a web page with POST and GET in ESP‑IDF?

Configure Wi‑Fi in AP mode, then start the HTTP server and register URI handlers. Use esp_http_server for lightweight endpoints. Keep handlers small and non‑blocking. How‑To: 1. Start Wi‑Fi AP, then httpd_start(). 2. Register /get and /post with httpd_register_uri_handler(). 3. Parse query or body, respond with httpd_resp_send(). ["ESP‑IDF HTTP Server"]

Which ESP‑IDF changes break older softAP examples, and how do I update them?

ESP‑IDF v4.1 transitioned networking glue to ESP‑NETIF. Replace tcpip_adapter calls with esp_netif APIs. Initialize with esp_netif_init, then create the default AP netif. Expert note: "ESP‑NETIF replaces the legacy TCP/IP Adapter." Update includes and function names, then rebuild. ["TCP/IP Adapter Migration (ESP‑IDF)"]

Why does the softAP example fail after I copy it to a new folder?

A mismatched PROJECT_NAME can break build paths. Fix by aligning the project name with the new folder. How‑To: 1. Set PROJECT_NAME in your build file (CMake/Make). 2. Clean the build directory. 3. Reconfigure and compile. [Elektroda, dondu, post #19192477]

How do I check my ESP‑IDF version?

Open components/esp_common/include/esp_idf_version.h in your ESP‑IDF tree. Inspect the version macros for MAJOR, MINOR, and PATCH numbers. This verifies if you use a stable tag or a development branch. [Elektroda, khoam, post #19192912]

Is ESP‑IDF v4.3 stable? Which release should I target?

During the referenced discussion, v4.2 was the latest stable release. Use tagged releases for production instead of master. Check the release notes and tag your toolchain to match. This minimizes unexpected API drift and warnings. ["ESP‑IDF v4.2 Release"]

I get deprecation warnings about tcpip_adapter. What should I change?

Replace tcpip_adapter_init and friends with esp_netif_init and esp_netif_create_default_wifi_ap. Update event and DHCP handling through ESP‑NETIF. Maintain the same Wi‑Fi stack calls around the new netif layer. This clears deprecation messages in v4.1+. ["TCP/IP Adapter Migration (ESP‑IDF)"]

What’s the maximum number of clients my ESP32 SoftAP can accept?

ESP32 SoftAP supports up to 10 stations. The default max_connection is typically 4. Increase it in wifi_config_t.ap.max_connection if RAM and throughput allow. Higher counts can reduce throughput and stability on heavy traffic. ["ESP‑IDF Wi‑Fi API"]

I get "undefined reference" when calling launchSoftAp() from another file. Why?

The function is likely declared static, which limits linkage to one translation unit. Remove static or declare the prototype in a header included by the caller. Rebuild after cleaning. This resolves the undefined symbol during linking. [Elektroda, khoam, post #19188010]

How do I set the SoftAP network interface and IP using ESP‑NETIF?

Initialize ESP‑NETIF and create the default AP netif. Stop the DHCP server, set your desired IP/netmask/gateway, then restart DHCP. This approach replaces old tcpip_adapter calls and keeps your configuration forward‑compatible. ["TCP/IP Adapter Migration (ESP‑IDF)"]

How do I register GET and POST handlers correctly with esp_http_server?

Create httpd_uri_t entries with .method = HTTP_GET or HTTP_POST. In POST handlers, read the body with httpd_req_recv. Parse key‑value or JSON, then reply using httpd_resp_send or chunked responses. Keep handlers short to avoid watchdog resets. ["ESP‑IDF HTTP Server"]

What’s the quickest way to verify my SoftAP works before adding HTTP?

Flash the Wi‑Fi getting_started SoftAP example. Connect a phone or laptop to the SSID and confirm DHCP assignment. Watch the serial log for connection events and assigned IP. Then add the HTTP server once Wi‑Fi is stable. ["ESP‑IDF Wi‑Fi Example: SoftAP"]

Can I implement this without Arduino libraries?

Yes. Use native ESP‑IDF components: Wi‑Fi, ESP‑NETIF, and esp_http_server. They provide full control of AP mode and HTTP endpoints. This avoids Arduino wrappers and aligns with Espressif’s recommended APIs for v4.1+. ["ESP‑IDF HTTP Server"]
Generated by the language model.
ADVERTISEMENT