Skip to content

Commit f7693b1

Browse files
committed
Feature: Change callback in a command
1 parent 3bffdb5 commit f7693b1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

components/esp_matter/esp_matter_core.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,17 @@ uint32_t get_id(command_t *command)
12341234
return current_command->command_id;
12351235
}
12361236

1237+
esp_err_t set_callback(command_t *command, callback_t callback)
1238+
{
1239+
if (!command) {
1240+
ESP_LOGE(TAG, "Command cannot be NULL");
1241+
return ESP_ERR_INVALID_ARG;
1242+
}
1243+
_command_t *current_command = (_command_t *)command;
1244+
current_command->callback = callback;
1245+
return ESP_OK;
1246+
}
1247+
12371248
callback_t get_callback(command_t *command)
12381249
{
12391250
if (!command) {

components/esp_matter/esp_matter_core.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,18 @@ command_t *get_next(command_t *command);
664664
*/
665665
uint32_t get_id(command_t *command);
666666

667+
/** Set command callback
668+
*
669+
* Set the command callback for the command.
670+
*
671+
* @param[in] command Command handle.
672+
* @param[in] callback Command callback.
673+
*
674+
* @return ESP_OK on success.
675+
* @return error in case of failure.
676+
*/
677+
esp_err_t set_callback(command_t *command, callback_t callback);
678+
667679
/** Get command callback
668680
*
669681
* Get the command callback for the command.

0 commit comments

Comments
 (0)