Skip to content

Commit ef4f383

Browse files
alxelaxanangl
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit 3e2b44a)
1 parent 9e770fa commit ef4f383

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

subsys/bluetooth/mesh/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ if BT_MESH_PRIV_BEACONS
11901190

11911191
config BT_MESH_PRIV_BEACON_SRV
11921192
bool "Support for Private Beacon Server Model"
1193+
depends on BT_MESH_MODEL_EXTENSIONS
11931194
help
11941195
Enable support for the Private Beacon Server model.
11951196

subsys/bluetooth/mesh/od_priv_proxy_srv.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,26 @@ static int od_priv_proxy_srv_init(const struct bt_mesh_model *mod)
8383
{
8484
od_priv_proxy_srv = mod;
8585

86-
const struct bt_mesh_model *priv_beacon_srv = bt_mesh_model_find(
87-
bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_PRIV_BEACON_SRV);
88-
const struct bt_mesh_model *sol_pdu_rpl_srv = bt_mesh_model_find(
89-
bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV);
86+
const struct bt_mesh_model *priv_beacon_srv =
87+
bt_mesh_model_find(bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_PRIV_BEACON_SRV);
88+
const struct bt_mesh_model *sol_pdu_rpl_srv =
89+
bt_mesh_model_find(bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV);
9090

9191
if (priv_beacon_srv == NULL) {
92-
return -EINVAL;
93-
}
94-
95-
if (!bt_mesh_model_in_primary(mod)) {
96-
LOG_ERR("On-Demand Private Proxy server not in primary element");
92+
LOG_ERR("On-Demand Private Proxy server cannot extend Private Beacon server");
9793
return -EINVAL;
9894
}
9995

10096
mod->keys[0] = BT_MESH_KEY_DEV_LOCAL;
10197
mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY;
10298

103-
if (IS_ENABLED(CONFIG_BT_MESH_MODEL_EXTENSIONS)) {
104-
bt_mesh_model_extend(mod, priv_beacon_srv);
99+
bt_mesh_model_extend(mod, priv_beacon_srv);
100+
101+
if (sol_pdu_rpl_srv != NULL) {
105102
bt_mesh_model_correspond(mod, sol_pdu_rpl_srv);
103+
} else {
104+
LOG_WRN("On-Demand Private Proxy server cannot be corresponded by Solicitation PDU "
105+
"RPL Configuration server");
106106
}
107107

108108
return 0;

subsys/bluetooth/mesh/priv_beacon_srv.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,19 @@ const struct bt_mesh_model_op bt_mesh_priv_beacon_srv_op[] = {
195195

196196
static int priv_beacon_srv_init(const struct bt_mesh_model *mod)
197197
{
198-
if (!bt_mesh_model_in_primary(mod)) {
199-
LOG_ERR("Priv beacon server not in primary element");
198+
const struct bt_mesh_model *config_srv =
199+
bt_mesh_model_find(bt_mesh_model_elem(mod), BT_MESH_MODEL_ID_CFG_SRV);
200+
201+
if (config_srv == NULL) {
202+
LOG_ERR("Private Beacon server cannot extend Configuration server");
200203
return -EINVAL;
201204
}
202205

203206
priv_beacon_srv = mod;
204207
mod->keys[0] = BT_MESH_KEY_DEV_LOCAL;
205208

209+
bt_mesh_model_extend(mod, config_srv);
210+
206211
return 0;
207212
}
208213

0 commit comments

Comments
 (0)