diff --git a/subsys/bluetooth/mesh/proxy_srv.c b/subsys/bluetooth/mesh/proxy_srv.c index 7d16a42a86e3..7894ef8d6089 100644 --- a/subsys/bluetooth/mesh/proxy_srv.c +++ b/subsys/bluetooth/mesh/proxy_srv.c @@ -897,10 +897,13 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) if (sub == beacon_sub) { beacon_sub = NULL; } + + bt_mesh_proxy_identity_stop(sub); } else { bt_mesh_proxy_beacon_send(sub); - bt_mesh_adv_gatt_update(); } + + bt_mesh_adv_gatt_update(); } BT_MESH_SUBNET_CB_DEFINE(gatt_services) = { diff --git a/tests/bluetooth/tester/src/btp/btp_mesh.h b/tests/bluetooth/tester/src/btp/btp_mesh.h index 17f49e4927ed..6a8e54f9f141 100644 --- a/tests/bluetooth/tester/src/btp/btp_mesh.h +++ b/tests/bluetooth/tester/src/btp/btp_mesh.h @@ -1060,6 +1060,9 @@ struct btp_priv_node_id_set_cmd { } __packed; #define BTP_MESH_PROXY_PRIVATE_IDENTITY 0x72 +struct btp_proxy_priv_identity_cmd { + uint8_t enabled; +} __packed; #define BTP_MESH_OD_PRIV_PROXY_GET 0x73 struct btp_od_priv_proxy_get_cmd { diff --git a/tests/bluetooth/tester/src/btp_mesh.c b/tests/bluetooth/tester/src/btp_mesh.c index acc97d5dda7c..1633fae0c349 100644 --- a/tests/bluetooth/tester/src/btp_mesh.c +++ b/tests/bluetooth/tester/src/btp_mesh.c @@ -899,20 +899,40 @@ static uint8_t priv_node_id_set(const void *cmd, uint16_t cmd_len, return BTP_STATUS_SUCCESS; } +#endif +#ifdef CONFIG_BT_MESH_PRIV_BEACON_SRV static uint8_t proxy_private_identity_enable(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len) { + const struct btp_proxy_priv_identity_cmd *cp = cmd; + uint16_t net_idx[CONFIG_BT_MESH_SUBNET_COUNT]; + enum bt_mesh_feat_state priv_node_id = BT_MESH_FEATURE_DISABLED; + ssize_t count; int err; LOG_DBG(""); - err = bt_mesh_proxy_private_identity_enable(); - if (err) { - LOG_ERR("Failed to enable proxy private identity (err %d)", err); + count = bt_mesh_subnets_get(net_idx, ARRAY_SIZE(net_idx), 0); + + if (count <= 0) { + LOG_ERR("No subnet (err:%i)", count); return BTP_STATUS_FAILED; } + if (cp->enabled) { + priv_node_id = BT_MESH_FEATURE_ENABLED; + } + + for (int i = 0; i < count; i++) { + err = bt_mesh_subnet_priv_node_id_set(net_idx[i], priv_node_id); + if (err) { + LOG_ERR("Failed to %s proxy private identity for net idx:%x (err %d)", + cp->enabled ? "enable" : "disable", net_idx[i], err); + return BTP_STATUS_FAILED; + } + } + return BTP_STATUS_SUCCESS; } #endif @@ -5251,8 +5271,10 @@ static const struct btp_handler handlers[] = { {.opcode = BTP_MESH_PRIV_NODE_ID_SET, .expect_len = sizeof(struct btp_priv_node_id_set_cmd), .func = priv_node_id_set}, +#endif +#ifdef CONFIG_BT_MESH_PRIV_BEACON_SRV {.opcode = BTP_MESH_PROXY_PRIVATE_IDENTITY, - .expect_len = 0, + .expect_len = sizeof(struct btp_proxy_priv_identity_cmd), .func = proxy_private_identity_enable}, #endif #if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)