Skip to content

No API to override command callback (CON-853) #704

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

Closed
jonsmirl opened this issue Oct 29, 2023 · 3 comments
Closed

No API to override command callback (CON-853) #704

jonsmirl opened this issue Oct 29, 2023 · 3 comments

Comments

@jonsmirl
Copy link
Contributor

jonsmirl commented Oct 29, 2023

Attributes have:

esp_err_t set_override_callback(attribute_t *attribute, callback_t callback)

There is no parallel API for commands.

When implementing a bridge you have to be able to override the commands too.

When fixing this, consider if you need two callbacks (original and override) or if the new callback could simply replace the old one saving memory. If you replace the old one be sure and cleanup all of the previously allocated memory.

@github-actions github-actions bot changed the title No API to override command callback No API to override command callback (CON-853) Oct 29, 2023
@jonsmirl
Copy link
Contributor Author

Temporarily, I used some casting to get to the callback

typedef struct _command {
    uint32_t command_id;
    uint16_t flags;
    command::callback_t callback;
    struct _command *next;
} _command2_t;

cluster = cluster::get(ep, OnOff::Id);
_command2_t *command = (_command2_t *)command::get(cluster, OnOff::Commands::Toggle::Id, COMMAND_FLAG_ACCEPTED);
command->callback = lp_command_callback_toggle;

@jonsmirl
Copy link
Contributor Author

jonsmirl commented Nov 14, 2023

I created a PR to enable this behavior
#734

@dhrishi
Copy link
Collaborator

dhrishi commented Jan 24, 2024

PR #734 is merged.

@dhrishi dhrishi closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants