Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add void* user data to all callbacks (TZ-1394) #504

Open
damian-kurek-wizzdev opened this issue Dec 16, 2024 · 2 comments
Open

Add void* user data to all callbacks (TZ-1394) #504

damian-kurek-wizzdev opened this issue Dec 16, 2024 · 2 comments

Comments

@damian-kurek-wizzdev
Copy link

Is your feature request related to a problem?

I want to pass an object instance that can process incoming calls instead of creating global objects

Describe the solution you'd like.

static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void* message, void userData*)
user data shall be passed when registering a callback
void esp_zb_core_action_handler_register(esp_zb_core_action_callback_t cb, void userData*);

Describe alternatives you've considered.

No response

Additional context.

No response

@github-actions github-actions bot changed the title Add void* user data to all callbacks Add void* user data to all callbacks (TZ-1394) Dec 16, 2024
@xieqinan
Copy link
Contributor

Hi @damian-kurek-wizzdev

Could you provide a more detailed and concrete application case? I believe the feature doesn’t make much sense. The esp_zb_core_action_handler_register() serves as the interface between ZCL and the application. It is triggered by active behaviors (such as a read attribute request that triggers a read attribute response) and passive behaviors (such as a report attribute from a binding device). Typically, it only needs to be registered once before the stack starts. Even if the void *userData parameter is added, the stack would only maintain the pointer and trigger it whenever any callback_id is activated, which is effectively the same as creating a global object in the application.

@damian-kurek-wizzdev
Copy link
Author

It is the same functionality if you create a global instance and call functions, but adding void* userData is the standard solution for libraries that use callbacks including esp idf.
That is a nice-to-have feature and won't break anything.
Examples from esp-idf
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/gpio.html#:~:text=esp_err_t%20gpio_isr_register(,%EF%83%81
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/protocols/mqtt.html#_CPPv430esp_mqtt_client_register_event24esp_mqtt_client_handle_t19esp_mqtt_event_id_t19esp_event_handler_tPv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants