### Navigate to BLE Example Directory Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/ble/get-started/ble-introduction.html Change your current directory to the NimBLE_GATT_Server example project within your ESP-IDF installation. ```bash $ cd /examples/bluetooth/ble_get_started/nimble/NimBLE_GATT_Server ``` -------------------------------- ### Navigate to ESP-IDF Example Directory Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/ble/get-started/ble-connection.html Change your current directory to the NimBLE_Connection example within your local ESP-IDF installation. ```bash cd /examples/bluetooth/ble_get_started/nimble/NimBLE_Connection ``` -------------------------------- ### OpenOCD Version Output Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/jtag-debugging/index.html This is an example of the expected output when verifying the OpenOCD installation. ```text Open On-Chip Debugger v0.12.0-esp32-20240318 (2024-03-18-18:25) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html ``` -------------------------------- ### Copy Example Project Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/linux-macos-start-project.html Copies the 'hello_world' example project from the ESP-IDF examples directory to your local workspace. ```bash cd ~/esp cp -r $IDF_PATH/examples/get-started/hello_world . ``` -------------------------------- ### Get Partition Info Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/partition-tables.html Command to retrieve specific information, such as size, about a default boot partition. ```bash # Print the size of default boot partition parttool.py --port "/dev/ttyUSB1" get_partition_info --partition-boot-default --info size ``` -------------------------------- ### Starting the Web Server Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/protocols/esp_http_server.html Starts an instance of the HTTP server with default configuration and registers URI handlers. Returns a handle to the server or NULL if it fails to start. ```c //Function for starting the webserver httpd_handle_t start_webserver(void) { // Generate default configuration httpd_config_t config = HTTPD_DEFAULT_CONFIG(); // Empty handle to http_server httpd_handle_t server = NULL; // Start the httpd server if (httpd_start(&server, &config) == ESP_OK) { // Register URI handlers httpd_register_uri_handler(server, &uri_get); httpd_register_uri_handler(server, &uri_post); } // If server failed to start, handle will be NULL return server; } ``` -------------------------------- ### Create and Start GPTimer Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/peripherals/gptimer.html Demonstrates how to create, enable, and start a GPTimer with a specified resolution. Ensure the timer is enabled before starting. ```c gptimer_handle_t gptimer = NULL; gptimer_config_t timer_config = { .clk_src = GPTIMER_CLK_SRC_DEFAULT, // Select the default clock source .direction = GPTIMER_COUNT_UP, // Counting direction is up .resolution_hz = 1 * 1000 * 1000, // Resolution is 1 MHz, i.e., 1 tick equals 1 microsecond }; // Create a timer instance ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &gptimer)); // Enable the timer ESP_ERROR_CHECK(gptimer_enable(gptimer)); // Start the timer ESP_ERROR_CHECK(gptimer_start(gptimer)); ``` -------------------------------- ### Example Post-Attach Callback Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/network/esp_netif_driver.html An example of a post-attach callback function for an I/O driver. It sets the driver configuration, including callbacks for buffer freeing and transmission, and starts the driver. ```c static esp_err_t my_post_attach_start(esp_netif_t * esp_netif, void * args) { my_netif_driver_t *driver = args; const esp_netif_driver_ifconfig_t driver_ifconfig = { .driver_free_rx_buffer = my_free_rx_buf, .transmit = my_transmit, .handle = driver->driver_impl }; driver->base.netif = esp_netif; ESP_ERROR_CHECK(esp_netif_set_driver_config(esp_netif, &driver_ifconfig)); my_driver_start(driver->driver_impl); return ESP_OK; } ``` -------------------------------- ### Install All Required Tools Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/idf-tools.html Use the 'install' command of idf_tools.py to download and extract all required tools. The 'all' argument installs all tools, including optional ones. ```shell python tools/idf_tools.py install all ``` -------------------------------- ### Starting Remote Provisioning Parameters Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/bluetooth/esp-ble-mesh.html Parameters for starting remote provisioning. ```APIDOC ## struct esp_ble_mesh_rpr_client_start_rpr_t ### Description Parameters of starting remote provisioning. ### Public Members - **model** (esp_ble_mesh_model_t *) - Pointer of Remote Provisioning Client. - **rpr_srv_addr** (uint16_t) - Unicast address of Remote Provisioning Server. ``` -------------------------------- ### Install esp-idf-sbom Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/idf-sbom.html Install the esp-idf-sbom tool from PyPI using pip. ```bash pip install esp-idf-sbom ``` -------------------------------- ### Install ESP-IDF Tools using install.bat Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/windows-setup-update-legacy.html Run this command from the Windows Command Prompt to download and install necessary ESP-IDF tools. If a tool is already installed, no action is taken. ```batch install.bat ``` -------------------------------- ### Install ESP-IDF Tools using install.ps1 Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/windows-setup-update-legacy.html Execute this command in PowerShell to download and install required ESP-IDF tools. The installation only proceeds if the specific tool version is not already present. ```powershell install.ps1 ``` -------------------------------- ### Copy Example Project using xcopy Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/windows-start-project.html Use the xcopy command to copy the 'hello_world' example project to your desired directory. Ensure there are no spaces in the paths to ESP-IDF or your project. ```batch cd %userprofile%\esp xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world ``` -------------------------------- ### Build Documentation Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/contribute/documenting-code.html Navigate to the 'docs' folder and execute this command to build the entire documentation set. ```bash build-docs build ``` -------------------------------- ### Start Ethernet Driver Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/network/esp_eth.html Starts the Ethernet driver state machine after installation. This is a fundamental step to enable Ethernet functionality. ```c esp_eth_start(eth_handle); // start Ethernet driver state machine ``` -------------------------------- ### Navigate to NimBLE_Beacon Example Directory Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/ble/get-started/ble-device-discovery.html Use this command to change your current directory to the NimBLE_Beacon example folder within your ESP-IDF installation. ```bash cd /examples/bluetooth/ble_get_started/nimble/NimBLE_Beacon ``` -------------------------------- ### httpd_start Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/protocols/esp_http_server.html Starts the web server by creating an instance and allocating resources based on the provided configuration. ```APIDOC ## httpd_start ### Description Starts the web server. Create an instance of HTTP server and allocate memory/resources for it depending upon the specified configuration. ### Method httpd_start ### Parameters #### Input Parameters * **handle** (httpd_handle_t *) - Output parameter to store the handle to the newly created server instance. NULL on error. * **config** (const httpd_config_t *) - Input parameter for the configuration of the new server instance. ### Returns * **ESP_OK** : Instance created successfully * **ESP_ERR_INVALID_ARG** : Null argument(s) * **ESP_ERR_HTTPD_ALLOC_MEM** : Failed to allocate memory for instance * **ESP_ERR_HTTPD_TASK** : Failed to launch server task ### Example Usage ```c //Function for starting the webserver httpd_handle_t start_webserver(void) { // Generate default configuration httpd_config_t config = HTTPD_DEFAULT_CONFIG(); // Empty handle to http_server httpd_handle_t server = NULL; // Start the httpd server if (httpd_start(&server, &config) == ESP_OK) { // Register URI handlers httpd_register_uri_handler(server, &uri_get); httpd_register_uri_handler(server, &uri_post); } // If server failed to start, handle will be NULL return server; } ``` ``` -------------------------------- ### Example Build Directory Structure Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/contribute/esp-idf-tests-with-pytest.html Illustrates the directory structure for built binaries in CI, organized by target and configuration (e.g., history or no history). ```text . ├── build_esp32_history/ │ └── ... ├── build_esp32_nohistory/ │ └── ... ├── build_esp32s2_history/ │ └── ... ├── ... ├── main/ ├── CMakeLists.txt ├── sdkconfig.ci.history ├── sdkconfig.ci.nohistory └── ... ``` -------------------------------- ### Generic Client Properties Get Parameters Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/bluetooth/esp-ble-mesh.html Parameter for getting Generic Client Properties. This structure specifies a starting Client Property ID. ```APIDOC ## struct esp_ble_mesh_gen_client_properties_get_t ### Description Parameter of Generic Client Properties Get. ### Public Members - **property_id** (uint16_t) - A starting Client Property ID present within an element. ``` -------------------------------- ### Get Current Deep Sleep Wake Stub Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/sleep_modes.html Retrieve the currently installed wake-from-deep-sleep stub. Returns NULL if no stub is currently installed. ```c esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void); ``` -------------------------------- ### Example Monitor Output Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/ble/get-started/ble-introduction.html This output shows that the application has started, exited the main function, and is updating heart rate data, which is typical for the NimBLE_GATT_Server example. ```text ... main_task: Returned from app_main() NimBLE_GATT_Server: Heart rate updated to 70 ``` -------------------------------- ### LittleFS Filesystem Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/storage/index.html Shows the use of the LittleFS component to initialize the filesystem and work with a file using POSIX functions. ```c littlefs ``` -------------------------------- ### Generic Client Properties Get Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/bluetooth/esp-ble-mesh.html Context of the received Generic Client Properties Get message. It includes a starting Client Property ID present within an element. ```APIDOC ## struct esp_ble_mesh_server_recv_gen_onoff_set_t ### Description Context of the received Generic OnOff Set message. ### Public Members * **bool op_en** Indicate if optional parameters are included. * **uint8_t onoff** Target value of Generic OnOff state. * **uint8_t tid** Transaction ID. * **uint8_t trans_time** Time to complete state transition (optional). * **uint8_t delay** Indicate message execution delay (C.1). ``` -------------------------------- ### Install QEMU Binaries Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/qemu.html Installs the pre-built QEMU binaries for ESP32-S3 and RISC-V from ESP-IDF tools. ```bash python $IDF_PATH/tools/idf_tools.py install qemu-xtensa qemu-riscv32 ``` -------------------------------- ### Basic USB Host Client and Class Driver Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/peripherals/usb_host.html Demonstrates the fundamental structure of a USB host client and a simple class driver. It includes registering a client, handling new device and device gone events, opening and closing devices, claiming and releasing interfaces, and submitting data transfers. This example is suitable for understanding the event-driven nature of the USB host library. ```c #include #include "usb/usb_host.h" #define CLASS_DRIVER_ACTION_OPEN_DEV 0x01 #define CLASS_DRIVER_ACTION_TRANSFER 0x02 #define CLASS_DRIVER_ACTION_CLOSE_DEV 0x03 struct class_driver_control { uint32_t actions; uint8_t dev_addr; usb_host_client_handle_t client_hdl; usb_device_handle_t dev_hdl; }; static void client_event_cb(const usb_host_client_event_msg_t *event_msg, void *arg) { // This function is called from within usb_host_client_handle_events(). Do not block and try to keep it short struct class_driver_control *class_driver_obj = (struct class_driver_control *)arg; switch (event_msg->event) { case USB_HOST_CLIENT_EVENT_NEW_DEV: class_driver_obj->actions |= CLASS_DRIVER_ACTION_OPEN_DEV; class_driver_obj->dev_addr = event_msg->new_dev.address; //Store the address of the new device break; case USB_HOST_CLIENT_EVENT_DEV_GONE: class_driver_obj->actions |= CLASS_DRIVER_ACTION_CLOSE_DEV; break; default: break; } } static void transfer_cb(usb_transfer_t *transfer) { // This function is called from within usb_host_client_handle_events(). Do not block and try to keep it short struct class_driver_control *class_driver_obj = (struct class_driver_control *)transfer->context; printf("Transfer status %d, actual number of bytes transferred %d\n", transfer->status, transfer->actual_num_bytes); class_driver_obj->actions |= CLASS_DRIVER_ACTION_CLOSE_DEV; } void client_task(void *arg) { ... // Wait until Host Library is installed // Initialize class driver objects struct class_driver_control class_driver_obj = {0}; // Register the client usb_host_client_config_t client_config = { .is_synchronous = false, .max_num_event_msg = 5, .async = { .client_event_callback = client_event_cb, .callback_arg = &class_driver_obj, } }; usb_host_client_register(&client_config, &class_driver_obj.client_hdl); //Allocate a USB transfer usb_transfer_t *transfer; usb_host_transfer_alloc(1024, 0, &transfer); //Event handling loop bool exit = false; while (!exit) { // Call the client event handler function usb_host_client_handle_events(class_driver_obj.client_hdl, portMAX_DELAY); // Execute pending class driver actions if (class_driver_obj.actions & CLASS_DRIVER_ACTION_OPEN_DEV) { // Open the device and claim interface 1 usb_host_device_open(class_driver_obj.client_hdl, class_driver_obj.dev_addr, &class_driver_obj.dev_hdl); usb_host_interface_claim(class_driver_obj.client_hdl, class_driver_obj.dev_hdl, 1, 0); } if (class_driver_obj.actions & CLASS_DRIVER_ACTION_TRANSFER) { // Send an OUT transfer to EP1 memset(transfer->data_buffer, 0xAA, 1024); transfer->num_bytes = 1024; transfer->device_handle = class_driver_obj.dev_hdl; transfer->bEndpointAddress = 0x01; transfer->callback = transfer_cb; transfer->context = (void *)&class_driver_obj; usb_host_transfer_submit(transfer); } if (class_driver_obj.actions & CLASS_DRIVER_ACTION_CLOSE_DEV) { // Release the interface and close the device usb_host_interface_release(class_driver_obj.client_hdl, class_driver_obj.dev_hdl, 1); usb_host_device_close(class_driver_obj.client_hdl, class_driver_obj.dev_hdl); exit = true; } ... // Handle any other actions required by the class driver } // Cleanup class driver usb_host_transfer_free(transfer); usb_host_client_deregister(class_driver_obj.client_hdl); ... // Delete the client task. Signal the Daemon Task if necessary. } ``` -------------------------------- ### Get FreeRTOS Tick Count Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/freertos_idf.html Returns the count of system ticks since the scheduler was started. ```c TickType_t xTaskGetTickCount(void) ``` -------------------------------- ### Start MCP Server with eim run Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/idf-py.html Recommended method to start the MCP server using the ESP-IDF Installation Manager (EIM). Ensures an active ESP-IDF environment without manual activation. ```bash eim run "idf.py mcp-server" ``` -------------------------------- ### Basic Host Class Driver and Client Task Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/peripherals/usb_host.html Demonstrates a simple host class driver and its client task. Includes a client task function, event callback implementations, and a state machine for device handling. ```c #define EXAMPLE_TAG "EXAMPLE_HOST" static void usb_host_client_event_callback(const usb_host_client_event_t event, void *arg) { // Handle client events like device connection/disconnection // ... } static void usb_transfer_callback(usb_transfer_t *transfer) { // Handle USB transfer completion // ... } static void client_task(void *arg) { esp_err_t ret; usb_host_client_handle_events_param_t param = { .callback = usb_host_client_event_callback, .context = NULL, }; // Open the USB host client usb_host_client_handle_t client_hdl; ESP_ERROR_CHECK(usb_host_client_open(NULL, &client_hdl)); // Register client events ESP_ERROR_CHECK(usb_host_client_register_events(client_hdl, USB_HOST_CLIENT_EVENT_DEVICE_CONNECTED | USB_HOST_CLIENT_EVENT_DEVICE_DISCONNECTED, ¶m)); while (1) { // Handle client events ESP_ERROR_CHECK(usb_host_client_handle_events(client_hdl, portMAX_DELAY)); } } void app_main(void) { // Initialize USB host controller usb_host_controller_config_t host_config = { .host_controller_driver = USB_HOST_CONTROLLER_DRIVER_ESP32S3_USB_OTG, }; ESP_ERROR_CHECK(usb_host_init(&host_config)); // Create client task xTaskCreate(client_task, "client_task", 4096, NULL, 5, NULL); } ``` -------------------------------- ### Open Project in VSCode Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/ble/get-started/ble-connection.html Open the NimBLE_Connection example directory in VSCode from the command line. ```bash code . ``` -------------------------------- ### Start Timer from ISR Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/freertos_idf.html This example demonstrates how to start or restart a FreeRTOS timer from an interrupt service routine. It's crucial for scenarios where timer events need to be managed in response to hardware interrupts, such as user input. ```c * // This scenario assumes xBacklightTimer has already been created. When a * // key is pressed, an LCD back-light is switched on. If 5 seconds pass * // without a key being pressed, then the LCD back-light is switched off. In * // this case, the timer is a one-shot timer, and unlike the example given for * // the xTimerReset() function, the key press event handler is an interrupt * // service routine. * * // The callback function assigned to the one-shot timer. In this case the * // parameter is not used. * void vBacklightTimerCallback( TimerHandle_t pxTimer ) * { * // The timer expired, therefore 5 seconds must have passed since a key * // was pressed. Switch off the LCD back-light. * vSetBacklightState( BACKLIGHT_OFF ); * } * * // The key press interrupt service routine. * void vKeyPressEventInterruptHandler( void ) * { * BaseType_t xHigherPriorityTaskWoken = pdFALSE; * * // Ensure the LCD back-light is on, then restart the timer that is * // responsible for turning the back-light off after 5 seconds of * // key inactivity. This is an interrupt service routine so can only * // call FreeRTOS API functions that end in "FromISR". * vSetBacklightState( BACKLIGHT_ON ); * * // xTimerStartFromISR() or xTimerResetFromISR() could be called here * // as both cause the timer to re-calculate its expiry time. * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was * // declared (in this function). * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS ) * { * // The start command was not executed successfully. Take appropriate * // action here. * } * * // Perform the rest of the key processing here. * * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch * // should be performed. The syntax required to perform a context switch * // from inside an ISR varies from port to port, and from compiler to * // compiler. Inspect the demos for the port you are using to find the * // actual syntax required. * if( xHigherPriorityTaskWoken != pdFALSE ) * { * // Call the interrupt safe yield function here (actual function * // depends on the FreeRTOS port being used). * } * } * ``` -------------------------------- ### Configure Project Target and Menuconfig Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/linux-macos-start-project.html Navigates to the project directory, sets the target chip to ESP32-S3, and launches the project configuration utility. ```bash cd ~/esp/hello_world idf.py set-target esp32s3 idf.py menuconfig ``` -------------------------------- ### Get Node Table Entry Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/bluetooth/esp-ble-mesh.html Retrieves a pointer to the start of the node table, allowing iteration through all provisioned nodes. ```APIDOC ## esp_ble_mesh_provisioner_get_node_table_entry ### Description Gets the entry of the node table. ### Note After invoking the function to get the entry of nodes, users can use the "for" loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's information. Before trying to read the node's information, users need to check if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL. For example: ` const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry(); for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) { const esp_ble_mesh_node_t *node = entry[i]; if (node) { ...... } } ` ### Returns Pointer to the start of the node table. ``` -------------------------------- ### OpenOCD Output Example for ESP32-S3 Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/jtag-debugging/index.html This log shows the typical output when OpenOCD successfully starts with the ESP32-S3 target. ```text user-name@computer-name:~/esp/esp-idf$ openocd -f board/esp32s3-builtin.cfg Open On-Chip Debugger v0.10.0-esp32-20210902 (2021-10-05-23:44) Licensed under GNU GPL v2 For bug reports, read https://openocd.org/doc/doxygen/bugs.html debug_level: 2 Info : only one transport option; autoselect 'jtag' Warn : Transport "jtag" was already selected Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255 Info : clock speed 40000 kHz Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : esp32s3.cpu0: Debug controller was reset. Info : esp32s3.cpu0: Core was reset. Info : esp32s3.cpu1: Debug controller was reset. Info : esp32s3.cpu1: Core was reset. Info : Listening on port 3333 for gdb connections ``` -------------------------------- ### Get Minimum Free Heap Size Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/misc_system_api.html Retrieves the minimum amount of free heap memory that has been available since the system started. ```c uint32_t esp_get_minimum_free_heap_size(void) ``` -------------------------------- ### Example Build Output Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/linux-macos-start-project.html This is an example of the output you might see during the build process, including CMake execution and final binary generation. ```bash $ idf.py build Running cmake in directory /path/to/hello_world/build Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"... Warn about uninitialized values. -- Found Git: /usr/bin/git (found version "2.17.0") -- Building empty aws_iot component due to configuration -- Component names: ... -- Component paths: ... ... (more lines of build system output) [527/527] Generating hello_world.bin esptool v5.0.2 Project build complete. To flash, run: idf.py flash or idf.py -p PORT flash or esptool -p (PORT) -b 921600 write-flash --flash-mode dio --flash-size detect --flash-freq 40m --flash-mode dio --flash-size detect --flash-freq 40m 0x10000 build/hello_world.bin build 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin ``` -------------------------------- ### Build, Flash, and Monitor ESP-IDF Project Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/ble/get-started/ble-connection.html Build the firmware, flash it to the development board, and monitor the serial output. ```bash idf.py flash monitor ``` -------------------------------- ### Default Async Memcpy Configuration Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/async_memcpy.html Get the default configuration for the asynchronous memcpy driver. This provides a starting point for custom configurations. ```c ASYNC_MEMCPY_DEFAULT_CONFIG() ``` -------------------------------- ### Default Ping Configuration Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/protocols/icmp_echo.html Provides a macro to get the default configuration for a ping session. This can be used as a starting point for custom configurations. ```c ESP_PING_DEFAULT_CONFIG() ``` -------------------------------- ### FatFS Partition Size Configuration Examples Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/storage/fatfs.html Examples demonstrating how to define partition sizes for FatFS. Sizes can be specified as percentages of the total drive space or as sector counts. The partition map is terminated by a zero or when no space remains. ```c {100, 0, 0, 0} ``` ```c {50, 50, 0, 0} ``` ```c {0x10000000, 0x10000000, 0x10000000, 0} ``` -------------------------------- ### Multi-Stage Test Sub-Menu Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/unit-tests.html Example of a sub-menu for multi-stage tests, guiding the user through sequential test stages, each requiring DUT reboots. ```text Running reset reason check for deepsleep... reset reason check for deepsleep (1) "trigger_deepsleep" (2) "check_deepsleep_reset_reason" ``` -------------------------------- ### Launch Interactive ESP-IDF Installation Wizard (CLI) Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/get-started/macos-setup.html Launch the interactive installation wizard using the EIM CLI if you need to customize installation path, select ESP-IDF versions, or modify other options. ```bash eim wizard ``` -------------------------------- ### Get Temperature Value Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/peripherals/temp_sensor.html Enables the temperature sensor, retrieves the current temperature in Celsius, and then disables the sensor. Ensure the sensor is installed before enabling. ```c // Enable temperature sensor ESP_ERROR_CHECK(temperature_sensor_enable(temp_handle)); // Get converted sensor data float tsens_out; ESP_ERROR_CHECK(temperature_sensor_get_celsius(temp_handle, &tsens_out)); printf("Temperature in %f °C\n", tsens_out); // Disable the temperature sensor if it is not needed and save the power ESP_ERROR_CHECK(temperature_sensor_disable(temp_handle)); ``` -------------------------------- ### Open Graphical Configuration Tool Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/idf-py.html Launches the menuconfig graphical interface for project configuration. ```bash idf.py menuconfig ``` -------------------------------- ### Initialize TCP/IP Stack and Event Loop Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/network/esp_netif.html This snippet shows the initial steps required to set up the TCP/IP stack and the default event loop. These must be performed before creating any network interfaces. ```c esp_netif_init(); esp_event_loop_create_default(); ``` -------------------------------- ### Get Default Pthread Configuration Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/pthread.html Retrieve the default configuration for pthreads, which is based on menuconfig settings. This function provides a starting point for thread configuration. ```c esp_pthread_cfg_t config = esp_pthread_get_default_config(); ``` -------------------------------- ### Create and Start a Software Timer Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/freertos_idf.html Demonstrates the creation of a software timer with a specified period and callback function, and then starts it. The timer is configured for auto-reloading. ```c void vApplicationMallocFailedHook( void ) { /* vApplicationMallocFailedHook() will only be called if configUSE_MALLOC_FAILED_HOOK is set to 1. It is a hook function that will get called if a call to pvPortMalloc() fails. pvPortMalloc() is called internally by the FreeRTOS and is the memory management that the kernel itself uses. */ taskDISABLE_INTERRUPTS(); for( ;; ); } void vApplicationIdleHook( void ) { /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1. It will be called on each iteration of the idle task. It is recommended that code run from the idle task does not use any APIs that require the scheduler to be running. */ volatile uint32_t ulLoop; for( ulLoop = 0; ulLoop < ulHighFrequencyTimerTicks; ulLoop++ ) { portNOP(); } } void vApplicationTickHook( void ) { /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set to 1. Tick hooks are called from the tick interrupt at a rate defined by configTICK_RATE_HZ. It is not recommended to use most FreeRTOS APIs from a tick hook. */ } void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) { /* vApplicationStackOverflowHook() will only be called if configCHECK_FOR_STACK_OVERFLOW is set to 1. This hook function is called if a stack overflow is detected. */ ( void ) pcTaskName; ( void ) pxTask; taskDISABLE_INTERRUPTS(); for( ;; ); } void vApplicationAssert( const char *pcFile, uint32_t ulLine ) { /* Assertions are described in the FreeRTOS reference manual. https://www.freertos.org/a00110.html#assert */ taskDISABLE_INTERRUPTS(); for( ;; ); } /* Define the function that is called when the timer expires. */ void prvTimerCallback( TimerHandle_t xTimer ) { volatile uint32_t ulDummy; /* Suppress unused parameter warning. */ ( void ) xTimer; /* The string to print is generated dynamically. */ ulDummy = ulTaskNotifyTake( pdFALSE, portMAX_DELAY ); if( ulDummy != 0 ) { /* The timer has expired. The callback function is executed in an ISR context so FreeRTOS functions that are not inclusive of calling from an ISR must not be called here. */ } } void main_freertos( void ) { TimerHandle_t xTimer; BaseType_t xTimer1Started, xTimer2Started; /* Create the software timer. The timer is created in a dormant state. The timer will expire every 200ms. The timer is auto-reloaded so it will expire repeatedly. The timer is given a name for debugging purposes. */ xTimer = xTimerCreate( /* Just a text name, not used by the RTOS kernel. */ "MyTimer", /* The timer period in ticks. */ pdMS_TO_TICKS( 200 ), /* Auto-reload the timer, so it expires repeatedly. */ pdTRUE, /* No timer ID is required. */ 0, /* The callback function to execute when the timer expires. */ prvTimerCallback ); /* Check that the timer was created successfully. */ if( xTimer != NULL ) { /* Start the software timer. The timer is now in the active state. */ xTimer1Started = xTimerStart( xTimer, 0 ); /* Was the timer started successfully? */ if( xTimer1Started != pdPASS ) { /* The timer could not be set into the active state, because there was no room in the RTOS's timer command queue. 500ms should be plenty of time. */ xTimer = NULL; } } /* ... */ /* Create tasks here. */ /* ... */ /* Starting the scheduler will start the timers running as they have already been set into the active state. */ vTaskStartScheduler(); /* Should not reach here. */ for( ;; ); } ``` -------------------------------- ### Get Idle Task Handle Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/freertos_idf.html Returns the handle of the idle task for the current core. This function is only available if INCLUDE_xTaskGetIdleTaskHandle is set to 1 and is not valid before the scheduler has started. ```c TaskHandle_t xTaskGetIdleTaskHandle(void) ``` -------------------------------- ### Start GDBGUI with idf.py Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/jtag-debugging/using-debugger.html Launches the GDBGUI debugger frontend, which opens an interactive debugging interface in a web browser. Requires prior installation via pipx. ```bash idf.py gdbgui ``` -------------------------------- ### Generic Power OnOff Setup Server Model Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/bluetooth/esp-ble-mesh.html User data structure for the Generic Power OnOff Setup Server Model. ```APIDOC ## Generic Power OnOff Setup Server Model ### Description Contains user-definable data for the Generic Power OnOff Setup Server Model, including its associated model, response control, and state parameters. ### Parameters #### Public Members - **model** (esp_ble_mesh_model_t *) - Pointer to the Generic Power OnOff Setup Server Model. Initialized internally. - **rsp_ctrl** (esp_ble_mesh_server_rsp_ctrl_t) - Response control of the server model received messages. - **state** (esp_ble_mesh_gen_onpowerup_state_t *) - Parameters of the Generic OnPowerUp state. ``` -------------------------------- ### Example Task Using Queues Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/freertos_idf.html Demonstrates the creation of queues and their usage within a task context. This example shows how to define a message structure and create two queues. ```c struct AMessage { char ucMessageID; char ucData[ 20 ]; }; void vATask( void *pvParameters ) { QueueHandle_t xQueue1, xQueue2; xQueue1 = xQueueCreate( 10, sizeof( struct AMessage ) ); xQueue2 = xQueueCreate( 5, sizeof( struct AMessage ) ); if( ( xQueue1 != NULL ) && ( xQueue2 != NULL ) ) { // ... FreeRTOS task code would continue here ... } else { // The queue could not be created. } // Tasks in most applications will do the following: for( ;; ) { // ... pass messages ... } } ``` -------------------------------- ### esp_console_new_repl_uart Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/console.html Establishes a console REPL environment over UART. This is a convenience function for examples and includes UART driver installation, stdin/stdout configuration, linenoise initialization, and REPL thread spawning. ```APIDOC ## esp_console_new_repl_uart ### Description Establish a console REPL environment over UART driver. This function is meant to be used in the examples to make the code more compact. Applications which use console functionality should be based on the underlying linenoise and esp_console functions. This is an all-in-one function to establish the environment needed for REPL, includes: Install the UART driver on the console UART (8n1, 115200, REF_TICK clock source), Configures the stdin/stdout to go through the UART driver, Initializes linenoise, Spawn new thread to run REPL in the background. ### Parameters #### Path Parameters - **dev_config** (const esp_console_dev_uart_config_t *) - **[in]** UART device configuration - **repl_config** (const esp_console_repl_config_t *) - **[in]** REPL configuration - **ret_repl** (esp_console_repl_t **) - **[out]** return REPL handle after initialization succeed, return NULL otherwise ### Returns - ESP_OK on success - ESP_FAIL Parameter error ``` -------------------------------- ### eFuse Record Format Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/efuse.html Defines the basic structure for an eFuse record in a CSV file, specifying field name, block, bit start, bit count, and an optional comment. ```csv # field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK10), bit_start(0..255), bit_count(1..256), comment ``` -------------------------------- ### Get Ethernet MAC Address and PHY Address Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/network/esp_eth.html Retrieves the MAC address and PHY address of the Ethernet interface using esp_eth_ioctl(). Ensure the Ethernet driver is installed before invoking these commands. ```c /* get MAC address */ uint8_t mac_addr[6]; memset(mac_addr, 0, sizeof(mac_addr)); esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr); ESP_LOGI(TAG, "Ethernet MAC Address: %02x:%02x:%02x:%02x:%02x:%02x", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); /* get PHY address */ int phy_addr = -1; esp_eth_ioctl(eth_handle, ETH_CMD_G_PHY_ADDR, &phy_addr); ESP_LOGI(TAG, "Ethernet PHY Address: %d", phy_addr); ``` -------------------------------- ### Install Basic ESP-IDF Dependencies Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/contribute/esp-idf-tests-with-pytest.html Installs all basic dependencies required for ESP-IDF development and testing. Use this command to set up the core environment. ```bash $ install.sh --enable-ci ``` -------------------------------- ### Change Timer Period Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/freertos_idf.html Demonstrates how to change the period of a FreeRTOS timer. If the timer is active, it's deleted; otherwise, its period is updated and it's started. Includes error handling for sending the command. ```c /* // This function assumes xTimer has already been created. If the timer * // referenced by xTimer is already active when it is called, then the timer * // is deleted. If the timer referenced by xTimer is not active when it is * // called, then the period of the timer is set to 500ms and the timer is * // started. */ void vAFunction( TimerHandle_t xTimer ) { if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" { // xTimer is already active - delete it. xTimerDelete( xTimer ); } else { // xTimer is not active, change its period to 500ms. This will also // cause the timer to start. Block for a maximum of 100 ticks if the // change period command cannot immediately be sent to the timer // command queue. if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS ) { // The command was successfully sent. } else { // The command could not be sent, even after waiting for 100 ticks // to pass. Take appropriate action here. } } } ``` -------------------------------- ### Install QEMU System Dependencies (Ubuntu/Debian) Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/qemu.html Installs necessary system libraries for QEMU on Ubuntu and Debian-based systems. ```bash sudo apt-get install -y libgcrypt20 libglib2.0-0 libpixman-1-0 libsdl2-2.0-0 libslirp0 ``` -------------------------------- ### Send ODP Client Message Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/bluetooth/esp-ble-mesh.html Sends a message from the On-Demand Private Proxy Config Client model. This is used to interact with the server model, for example, to get or set the On-Demand Private Proxy state. ```APIDOC ## esp_ble_mesh_odp_client_send ### Description Sends a message from the On-Demand Private Proxy Config Client model. This is used to interact with the server model, for example, to get or set the On-Demand Private Proxy state. ### Method ```APIDOC esp_err_t esp_ble_mesh_odp_client_send(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_odp_client_msg_t *msg) ``` ### Parameters #### Path Parameters - **params** (esp_ble_mesh_client_common_param_t *) - [in] Pointer to BLE Mesh common client parameters. - **msg** (esp_ble_mesh_odp_client_msg_t *) - [in] Pointer to On-Demand Private Proxy Config Client message. ### Returns - ESP_OK on success or an error code otherwise. ``` -------------------------------- ### Get Blob (Binary Data) from NVS Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/storage/nvs_flash.html Retrieves binary data for a given key. This example shows retrieving a MAC address into a static array. Ensure the handle is valid and the key constraints are met. ```c // Example (without error checking) of using nvs_get_blob to get a binary data // into a static array: uint8_t mac_addr[6]; size_t size = sizeof(mac_addr); nvs_get_blob(my_handle, "dst_mac_addr", mac_addr, &size); ``` -------------------------------- ### SPIFFS API Example Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/storage/index.html Shows the use of the SPIFFS API to initialize the filesystem and work with files using POSIX functions. ```c spiffs ``` -------------------------------- ### Implement Property Get Handler for Timestamp Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/protocols/esp_local_ctrl.html Handles requests to retrieve property values. This example specifically retrieves a timestamp, using the `ctx` pointer to call a time-getting function and storing the value in a static variable. ```c static esp_err_t get_property_values(size_t props_count, const esp_local_ctrl_prop_t *props, esp_local_ctrl_prop_val_t *prop_values, void *usr_ctx) { for (uint32_t i = 0; i < props_count; i++) { ESP_LOGI(TAG, "Reading %s", props[i].name); if (props[i].type == TYPE_TIMESTAMP) { /* Obtain the timer function from ctx */ int32_t (*func_get_time)(void) = props[i].ctx; /* Use static variable for saving the value. This is essential because the value has to be valid even after this function returns. Alternative is to use dynamic allocation and set the free_fn field */ static int32_t ts = func_get_time(); prop_values[i].data = &ts; } } return ESP_OK; } ``` -------------------------------- ### GPTimer Creation and Configuration Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/peripherals/gptimer.html Demonstrates how to create a GPTimer instance with specified configuration, enable it, and start its operation. ```APIDOC ## GPTimer Creation and Configuration ### Description This section covers the process of initializing and starting a General Purpose Timer (GPTimer). ### Functions - `gptimer_new_timer(const gptimer_config_t *config, gptimer_handle_t *timer)`: Creates a new GPTimer instance. - `gptimer_enable(gptimer_handle_t timer)`: Enables the GPTimer, switching its state machine to active. - `gptimer_start(gptimer_handle_t timer)`: Starts the GPTimer counting. ### Configuration (`gptimer_config_t`) - `clk_src` (gptimer_clock_source_t): Selects the clock source for the timer. - `direction` (gptimer_count_direction_t): Sets the counting direction (up or down). - `resolution_hz` (uint32_t): Sets the resolution of the internal counter in Hz. - `intr_priority` (uint8_t): Sets the interrupt priority. Use 0 for default. - `flags` (uint32_t): Fine-tunes driver behavior, e.g., `allow_pd` for power down in sleep mode. ### Example Usage ```c gptimer_handle_t gptimer = NULL; gptimer_config_t timer_config = { .clk_src = GPTIMER_CLK_SRC_DEFAULT, .direction = GPTIMER_COUNT_UP, .resolution_hz = 1000000, // 1 MHz resolution }; // Create a timer instance ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &gptimer)); // Enable the timer ESP_ERROR_CHECK(gptimer_enable(gptimer)); // Start the timer ESP_ERROR_CHECK(gptimer_start(gptimer)); ``` ### Notes - If all hardware timers are allocated, `gptimer_new_timer` returns `ESP_ERR_NOT_FOUND`. - `gptimer_enable` and `gptimer_disable` must be called in pairs. - `gptimer_start` and `gptimer_stop` are idempotent, but calling them during an intermediate state of starting/stopping can result in `ESP_ERR_INVALID_STATE`. ``` -------------------------------- ### esp_set_deep_sleep_wake_stub Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/system/sleep_modes.html Installs a new stub function to be executed immediately upon waking from deep sleep. This allows custom code to run before the main application or bootloader starts. The stub function must be marked with RTC_IRAM_ATTR. ```APIDOC ## esp_set_deep_sleep_wake_stub ### Description Install a new stub at runtime to run on wake from deep sleep. If implementing `esp_wake_deep_sleep()` then it is not necessary to call this function. However, it is possible to call this function to substitute a different deep sleep stub. Any function used as a deep sleep stub must be marked RTC_IRAM_ATTR, and must obey the same rules given for `esp_wake_deep_sleep()`. ### Method void ### Parameters * **new_stub** (`esp_deep_sleep_wake_stub_fn_t`) - The new wake stub function to install. ``` -------------------------------- ### esp_supp_dpp_init Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/network/esp_dpp.html Initializes the DPP Supplicant, starting the service and setting up necessary data structures. ```APIDOC ## esp_supp_dpp_init ### Description Initializes the DPP Supplicant and related data structures. ### Function Signature ```c esp_err_t esp_supp_dpp_init(void) ``` ### Return Values * **ESP_OK**: Success * **ESP_FAIL**: Failure ``` -------------------------------- ### Change PWM Duty Cycle Using Hardware Fading Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/peripherals/ledc.html Utilize the LEDC hardware to gradually transition between duty cycle values. This involves installing the fade function, configuring fading parameters, and starting the fade operation. ```APIDOC ## Change PWM Duty Cycle Using Hardware The LEDC hardware provides the means to gradually transition from one duty cycle value to another. To use this functionality, enable fading with `ledc_fade_func_install()` and then configure it by calling one of the available fading functions: * `ledc_set_fade_with_time()` * `ledc_set_fade_with_step()` * `ledc_set_fade()` Start fading with `ledc_fade_start()`. A fade can be operated in blocking or non-blocking mode, please check `ledc_fade_mode_t` for the difference between the two available fade modes. To get a notification about the completion of a fade operation, a fade end callback function can be registered for each channel by calling `ledc_cb_register()` after the fade service being installed. If not required anymore, fading and an associated interrupt can be disabled with `ledc_fade_func_uninstall()`. ``` -------------------------------- ### Initialize HTTP Server Configuration with Defaults Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-reference/api-conventions.html Shows how to use the HTTPD_DEFAULT_CONFIG macro to initialize an httpd_config_t structure with default values, allowing for subsequent modifications. ```c httpd_config_t config = HTTPD_DEFAULT_CONFIG(); /* HTTPD_DEFAULT_CONFIG expands to a designated initializer. Now all fields are set to the default values, and any field can still be modified: */ config.server_port = 8081; httpd_handle_t server; esp_err_t err = httpd_start(&server, &config); ``` -------------------------------- ### Provide Extension via Python Package Entry Point Source: https://docs.espressif.com/projects/esp-idf/en/v6.0.1/esp32s3/api-guides/tools/idf-py.html Example of how to define an extension in a Python package's pyproject.toml file using the 'idf_extension' entry point group. This allows the extension to be discovered and loaded by idf.py when the package is installed. ```toml [project] name = "my_comp" version = "0.1.0" [project.entry-points.idf_extension] my_pkg_ext = "my_component.my_ext:action_extensions" ```