Skip to content

Commit 51a9842

Browse files
committed
Feature: Change callback in a command
1 parent 83fec9a commit 51a9842

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
@@ -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

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

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

0 commit comments

Comments
 (0)