Skip to content

Commit 5bf8ecb

Browse files
committed
Merge branch 'fix_rmaker_cluster' into 'main'
rmaker: Fix the size of char attributes and use the non deleted method See merge request app-frameworks/esp-matter!658
2 parents 55c48ca + 9bfc429 commit 5bf8ecb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

components/esp_matter_rainmaker/esp_matter_rainmaker.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,18 @@ static esp_err_t custom_cluster_create()
377377
/* Update the value of the attribute after esp_rmaker_node_init() is done */
378378
char rmaker_node_id[ESP_MATTER_RAINMAKER_MAX_NODE_ID_LEN] = {0};
379379
attribute::create(cluster, cluster::rainmaker::attribute::rmaker_node_id::Id, ATTRIBUTE_FLAG_NONE,
380-
esp_matter_char_str(rmaker_node_id, sizeof(rmaker_node_id)));
380+
esp_matter_char_str(rmaker_node_id, strlen(rmaker_node_id)), sizeof(rmaker_node_id));
381381

382382
/* Create custom challenge_response attribute */
383383
/* Update the value of the attribute after sign_data command is called */
384384
char challenge_response[ESP_MATTER_RAINMAKER_MAX_CHALLENGE_RESPONSE_LEN] = {0};
385385
attribute::create(cluster, cluster::rainmaker::attribute::challenge_response::Id, ATTRIBUTE_FLAG_NONE,
386-
esp_matter_char_str(challenge_response, sizeof(challenge_response)));
386+
esp_matter_char_str(challenge_response, strlen(challenge_response)), sizeof(challenge_response));
387387

388388
/* Create custom challenge attribute */
389389
char challenge[ESP_MATTER_RAINMAKER_MAX_CHALLENGE_LEN] = {0};
390390
attribute::create(cluster, cluster::rainmaker::attribute::challenge::Id, ATTRIBUTE_FLAG_WRITABLE,
391-
esp_matter_char_str(challenge, sizeof(challenge)));
391+
esp_matter_char_str(challenge, strlen(challenge)), sizeof(challenge));
392392

393393
/* Create custom configuration command */
394394
command::create(cluster, cluster::rainmaker::command::configuration::Id,
@@ -415,7 +415,10 @@ class RainmakerAttrAccess : public AttributeAccessInterface
415415

416416
CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override
417417
{
418-
if (aPath == ConcreteDataAttributePath(cluster::rainmaker::endpoint_id, cluster::rainmaker::Id, cluster::rainmaker::attribute::challenge::Id))
418+
ConcreteDataAttributePath challengeAttrPath(cluster::rainmaker::endpoint_id, cluster::rainmaker::Id,
419+
cluster::rainmaker::attribute::challenge::Id);
420+
421+
if (challengeAttrPath.MatchesConcreteAttributePath(aPath))
419422
{
420423
chip::CharSpan challenge;
421424
CHIP_ERROR c_err = aDecoder.Decode(challenge);
@@ -427,10 +430,8 @@ class RainmakerAttrAccess : public AttributeAccessInterface
427430

428431
return (ESP_OK == sign_and_update_challenge_response(challenge)) ? CHIP_NO_ERROR : CHIP_ERROR_INCORRECT_STATE;
429432
}
430-
else
431-
{
432-
return CHIP_NO_ERROR;
433-
}
433+
434+
return CHIP_NO_ERROR;
434435
}
435436
};
436437

0 commit comments

Comments
 (0)