Skip to content

Commit 7ba5a90

Browse files
authored
Feature: Change callback in a command
1 parent dad9050 commit 7ba5a90

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

components/esp_matter/esp_matter_core.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,17 @@ uint32_t get_id(command_t *command)
13131313
return current_command->command_id;
13141314
}
13151315

1316+
esp_err_t set_callback(command_t *command, callback_t callback)
1317+
{
1318+
if (!command) {
1319+
ESP_LOGE(TAG, "Command cannot be NULL");
1320+
return ESP_ERR_INVALID_ARG;
1321+
}
1322+
_command_t *current_command = (_command_t *)command;
1323+
current_command->callback = callback;
1324+
return ESP_OK;
1325+
}
1326+
13161327
callback_t get_callback(command_t *command)
13171328
{
13181329
if (!command) {

components/esp_matter/esp_matter_core.h

+12
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,18 @@ command_t *get_next(command_t *command);
679679
*/
680680
uint32_t get_id(command_t *command);
681681

682+
/** Set command callback
683+
*
684+
* Set the command callback for the command.
685+
*
686+
* @param[in] command Command handle.
687+
* @param[in] callback Command callback.
688+
*
689+
* @return ESP_OK on success.
690+
* @return error in case of failure.
691+
*/
692+
esp_err_t set_callback(command_t *command, callback_t callback);
693+
682694
/** Get command callback
683695
*
684696
* Get the command callback for the command.

0 commit comments

Comments
 (0)