Configurability of esp-matter examples (how get configured GPIO for button?)

RichPiano
Posts: 123
Joined: Mon May 18, 2020 2:51 pm

Configurability of esp-matter examples (how get configured GPIO for button?)

Postby RichPiano » Mon Apr 03, 2023 1:16 pm

I'm just trying out the button example for esp-matter. I wanted to check which PIN was connected but unfortunately I couldn't figure it out from the source code. The below mentioned app_driver_switch_init() function which supposedly inits the button will pull in the configuration via a call to button_driver_get_config() yet this function is nowhere to be found. I only found some references in the linker scripts and it seemsthat it is linked in statically.

-- app_driver.cpp --

Code: Select all

app_driver_handle_t app_driver_switch_init()
{
    /* Initialize button */
    button_config_t config = button_driver_get_config();
    button_handle_t handle = iot_button_create(&config);
    iot_button_register_cb(handle, BUTTON_PRESS_DOWN, app_driver_button_toggle_cb, NULL);

    /* Other initializations */
#if CONFIG_ENABLE_CHIP_SHELL
    app_driver_register_commands();
#endif // CONFIG_ENABLE_CHIP_SHELL
    client::set_command_callback(app_driver_client_command_callback, app_driver_client_group_command_callback, NULL);

    return (app_driver_handle_t)handle;
}
-- light_switch.map --

Code: Select all

button_driver_get_config                          esp-idf/device/libdevice.a(device.c.obj)
                                                  esp-idf/main/libmain.a(app_driver.cpp.obj)
--> Links to libdevice.a

Code: Select all

 .literal.button_driver_get_config
                0x00000000400d0804        0x0 esp-idf/device/libdevice.a(device.c.obj)
                                          0x4 (size before relaxing)
--> Is this the value?

Sorry I'm not really adept in linker scripts, please enlighten me if you know more :) In any case, this would make it very inconvenient to configure for the end user. Am I missing something?

RichPiano
Posts: 123
Joined: Mon May 18, 2020 2:51 pm

Re: Configurability of esp-matter examples (how get configured GPIO for button?)

Postby RichPiano » Thu Apr 06, 2023 2:30 pm

I figured out through trial and error that the LED glows on GPIO5. I still don't know where to configure it except changing the code.

edleno
Posts: 4
Joined: Sat Mar 27, 2021 2:06 am

Re: Configurability of esp-matter examples (how get configured GPIO for button?)

Postby edleno » Sat Apr 22, 2023 12:14 am

This is an old thread, but I recently ran into the same and wanted to update this with an answer. There are a series of directories under ...esp-matter/device_hal/device that contain the values for the button and the LED for the examples. The main file is device.c which defines the gpio pin. Unfortunately the code does NOT check if the value is already defined, so you can not just define the value in your code. I changed the config.gpio value in the app_driver_light_init to match my DOIT DevkitC which has a built in LED on GPIO 2.

The button is defined as GPIO0 (the boot button, sometimes labeled FLASH on some boards).

To get Intellisense to work in Visual Studio Code I added the path to esp-idf and esp-matter to the c_cpp_properties.json file. For example:
  1. "includePath": [
  2.                 "/root/esp-idf/**",
  3.                 "/root/.espressif/esp-matter/**",
  4.                 "${workspaceFolder}/**"
  5.                  ],

RichPiano
Posts: 123
Joined: Mon May 18, 2020 2:51 pm

Re: Configurability of esp-matter examples (how get configured GPIO for button?)

Postby RichPiano » Wed May 31, 2023 5:38 am

Thank you, we're still in the midst of figuring out the matter mess, so that's certainly still helpful!

Who is online

Users browsing this forum: No registered users and 325 guests