espressif/console_simple_init

uploaded 6 months ago
The component provides helper functions for easy initialization and start of esp console.

readme

# Simple Console Initializer
The component provides a simple api's to initialize and start the esp console.
It also provides an api to register an user provided command.

## 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:
    ```c
    #include "console_simple_init.h"
    ```
3. Ensure NVS flash is initialized and default event loop is created in your app_main():
    ```c
    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:
    ```c
    ESP_ERROR_CHECK(console_cmd_init());     // Initialize console

    // Define the function prototype for do_user_cmd
    // It's a function that takes an integer (argc) and a pointer to a pointer to char (argv)
    int do_user_cmd(int argc, char **argv);

    // Register the do_user_cmd function as a command callback function for "user" command
    // This allows you to execute the do_user_cmd function when the "user" command is invoked
    ESP_ERROR_CHECK(console_cmd_user_register("user", do_user_cmd));


    ESP_ERROR_CHECK(console_cmd_start());    // Start console
    ```

changelog

# Changelog

## [1.0.2](https://github.com/espressif/esp-protocols/commits/console_simple_init-v1.0.2)

### Bug Fixes

- Fixed bump version check in publish-docs yml ([e834d47](https://github.com/espressif/esp-protocols/commit/e834d47))

## [1.0.1](https://github.com/espressif/esp-protocols/commits/console_simple_init-v1.0.1)

### Bug Fixes

- Fixed versioning, publishing and changelog generation ([3081f1a69c](https://github.com/espressif/esp-protocols/commit/3081f1a69c))

## [1.0.0](https://github.com/espressif/esp-protocols/commits/console_simple_init-v1.0.0)


### Features

- [Added simple component for console initialization](https://github.com/espressif/esp-protocols/commit/1ac4e4177128a7b7188babd47d0e2bfa6bbb2517)

Links

Supports all targets

License: Apache-2.0

To add this component to your project, run:

idf.py add-dependency "espressif/console_simple_init^1.0.2"

or download archive

Dependencies

  • ESP-IDF >=5.0
  • Examples:

    console_basic

    To create a project from this example, run:

    idf.py create-project-from-example "espressif/console_simple_init^1.0.2:console_basic"

    or download archive

    Stats

    • Downloaded in total
      Downloaded in total 995 times
    • Downloaded this version
      This version: 81 times

    Badge

    espressif/console_simple_init version: 1.0.2
    |