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

Feature: Change callback in a command (CON-730) #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/esp_matter/esp_matter_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,17 @@ uint32_t get_id(command_t *command)
return current_command->command_id;
}

esp_err_t set_callback(command_t *command, callback_t callback)
{
if (!command) {
ESP_LOGE(TAG, "Command cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
_command_t *current_command = (_command_t *)command;
current_command->callback = callback;
return ESP_OK;
}

callback_t get_callback(command_t *command)
{
if (!command) {
Expand Down
12 changes: 12 additions & 0 deletions components/esp_matter/esp_matter_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,18 @@ command_t *get_next(command_t *command);
*/
uint32_t get_id(command_t *command);

/** Set command callback
*
* Set the command callback for the command.
*
* @param[in] command Command handle.
* @param[in] callback Command callback.
*
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t set_callback(command_t *command, callback_t callback);

/** Get command callback
*
* Get the command callback for the command.
Expand Down