esp-protocols/components/console_cmd_wifi
Abhik Roy 5d43f9660f bump(console): 1.0.1 -> 1.1.0
1.1.0
Features
- Added support to join pre-configured network (bdbf16c1)
2024-06-11 20:50:49 +10:00
..
examples/wifi-basic feat(console): Console for runtime wifi configuration 2023-12-22 23:44:16 +11:00
include feat(console): Added support to join pre-configured network 2024-06-11 20:34:01 +10:00
.cz.yaml bump(console): 1.0.1 -> 1.1.0 2024-06-11 20:50:49 +10:00
CHANGELOG.md bump(console): 1.0.1 -> 1.1.0 2024-06-11 20:50:49 +10:00
CMakeLists.txt feat(console): Added support to join pre-configured network 2024-06-11 20:34:01 +10:00
console_wifi.c feat(console): Added support to join pre-configured network 2024-06-11 20:34:01 +10:00
idf_component.yml bump(console): 1.0.1 -> 1.1.0 2024-06-11 20:50:49 +10:00
Kconfig.projbuild feat(console): Added support to join pre-configured network 2024-06-11 20:34:01 +10:00
LICENSE fix(console): Fixed license file for console_cmd_wifi 2023-12-23 21:19:30 +11:00
README.md feat(console): Added support to join pre-configured network 2024-06-11 20:34:01 +10:00

Console command wifi

The component offers a console with a command that enables runtime wifi configuration for any example project.

API

Steps to enable console in an example code:

  1. Add this component to your project using idf.py add-dependency command.
  2. In the main file of the example, add the following line:
    #include "console_wifi.h"
    
  3. Ensure esp-netif and NVS flash is initialized and default event loop is created in your app_main():
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    esp_err_t ret = nvs_flash_init();   //Initialize NVS
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);
    
  4. In your app_main() function, add the following line as the last line:
    ESP_ERROR_CHECK(console_cmd_init());     // Initialize console
    
    // Register all plugin command added to your project
    ESP_ERROR_CHECK(console_cmd_all_register());
    
    // To register only wifi command skip calling console_cmd_all_register()
    ESP_ERROR_CHECK(console_cmd_wifi_register());
    
    ESP_ERROR_CHECK(console_cmd_start());    // Start console
    

Note: Auto-registration of a specific plugin command can be disabled from menuconfig.

Suported command:

wifi:

 wifi help: Prints the help text for all wifi commands
 wifi show network/sta: Scans and displays all available wifi APs./ Shows the details of wifi station.
 wifi sta join <network ssid> <password>: Station joins the given wifi network.
 wifi sta join <network ssid>: Station joins the given unsecured wifi network.
 wifi sta join: Station joins the pre-configured wifi network.
 wifi sta leave: Station leaves the wifi network.