Bluetooth: Mesh: add extension config server by private beacon server

Commit add extension of configuration server by private
beacon server.
Mesh Protocol v1.1 specification
4.4.11.1
The Mesh Private Beacon Server model is a main model
that extends the Configuration Server model.

Configuration server and private beacon server shall always
exist together since they have bound states.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This commit is contained in:
Aleksandr Khromykh 2024-06-20 08:50:49 +02:00 committed by Alberto Escolar
commit 3e2b44a5dd
3 changed files with 19 additions and 13 deletions

View file

@ -1175,6 +1175,7 @@ if BT_MESH_PRIV_BEACONS
config BT_MESH_PRIV_BEACON_SRV config BT_MESH_PRIV_BEACON_SRV
bool "Support for Private Beacon Server Model" bool "Support for Private Beacon Server Model"
depends on BT_MESH_MODEL_EXTENSIONS
help help
Enable support for the Private Beacon Server model. Enable support for the Private Beacon Server model.

View file

@ -83,26 +83,26 @@ static int od_priv_proxy_srv_init(const struct bt_mesh_model *mod)
{ {
od_priv_proxy_srv = mod; od_priv_proxy_srv = mod;
const struct bt_mesh_model *priv_beacon_srv = bt_mesh_model_find( const struct bt_mesh_model *priv_beacon_srv =
bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_PRIV_BEACON_SRV); bt_mesh_model_find(bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_PRIV_BEACON_SRV);
const struct bt_mesh_model *sol_pdu_rpl_srv = bt_mesh_model_find( const struct bt_mesh_model *sol_pdu_rpl_srv =
bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV); bt_mesh_model_find(bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV);
if (priv_beacon_srv == NULL) { if (priv_beacon_srv == NULL) {
return -EINVAL; LOG_ERR("On-Demand Private Proxy server cannot extend Private Beacon server");
}
if (!bt_mesh_model_in_primary(mod)) {
LOG_ERR("On-Demand Private Proxy server not in primary element");
return -EINVAL; return -EINVAL;
} }
mod->keys[0] = BT_MESH_KEY_DEV_LOCAL; mod->keys[0] = BT_MESH_KEY_DEV_LOCAL;
mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY;
if (IS_ENABLED(CONFIG_BT_MESH_MODEL_EXTENSIONS)) { bt_mesh_model_extend(mod, priv_beacon_srv);
bt_mesh_model_extend(mod, priv_beacon_srv);
if (sol_pdu_rpl_srv != NULL) {
bt_mesh_model_correspond(mod, sol_pdu_rpl_srv); bt_mesh_model_correspond(mod, sol_pdu_rpl_srv);
} else {
LOG_WRN("On-Demand Private Proxy server cannot be corresponded by Solicitation PDU "
"RPL Configuration server");
} }
return 0; return 0;

View file

@ -195,14 +195,19 @@ const struct bt_mesh_model_op bt_mesh_priv_beacon_srv_op[] = {
static int priv_beacon_srv_init(const struct bt_mesh_model *mod) static int priv_beacon_srv_init(const struct bt_mesh_model *mod)
{ {
if (!bt_mesh_model_in_primary(mod)) { const struct bt_mesh_model *config_srv =
LOG_ERR("Priv beacon server not in primary element"); bt_mesh_model_find(bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_CFG_SRV);
if (config_srv == NULL) {
LOG_ERR("Private Beacon server cannot extend Configuration server");
return -EINVAL; return -EINVAL;
} }
priv_beacon_srv = mod; priv_beacon_srv = mod;
mod->keys[0] = BT_MESH_KEY_DEV_LOCAL; mod->keys[0] = BT_MESH_KEY_DEV_LOCAL;
bt_mesh_model_extend(mod, config_srv);
return 0; return 0;
} }