mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: stack: Add a check if the appkey is bound to the model.
For case MESH/NODE/CFG/MP/BI-03-C
This commit is contained in:
parent
a53ebdf8a3
commit
6b3c88873e
@ -197,6 +197,21 @@ static bool app_key_is_valid(uint16_t app_idx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool mod_pub_app_key_bound(struct bt_mesh_model *model,
|
||||||
|
uint16_t app_idx)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
|
||||||
|
if (model->keys[i] == app_idx) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BT_ERR("Appkey(0x%02x) not bound to this model.", app_idx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
||||||
uint16_t app_idx, uint8_t cred_flag, uint8_t ttl, uint8_t period,
|
uint16_t app_idx, uint8_t cred_flag, uint8_t ttl, uint8_t period,
|
||||||
uint8_t retransmit, bool store)
|
uint8_t retransmit, bool store)
|
||||||
@ -237,7 +252,11 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
|||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bt_mesh_app_key_find(app_idx)) {
|
/* For case MESH/NODE/CFG/MP/BI-03-C, need to check if appkey
|
||||||
|
* is bound to model identified by the ModelIdentifier.
|
||||||
|
*/
|
||||||
|
if (!bt_mesh_app_key_find(app_idx) ||
|
||||||
|
!mod_pub_app_key_bound(model, app_idx)) {
|
||||||
return STATUS_INVALID_APPKEY;
|
return STATUS_INVALID_APPKEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user