From ce5becf5edbca946e4c84c0430eb4085555e6fb5 Mon Sep 17 00:00:00 2001 From: alperen sener Date: Mon, 31 Mar 2025 08:51:15 +0200 Subject: [PATCH 1/2] [nrf fromlist] Bluetooth: Mesh: Stop Private NID advs upon subnet removal Private Node Identity advertisement on a subnet should stop as soon as the network is removed. Upstream PR #: 87891 Signed-off-by: alperen sener --- subsys/bluetooth/mesh/proxy_srv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) = { From 40d3f2f93ad674ce65d5321a24934cf6b6889df0 Mon Sep 17 00:00:00 2001 From: alperen sener Date: Mon, 31 Mar 2025 11:04:00 +0200 Subject: [PATCH 2/2] [nrf fromlist] tests: bluetooth: tester: Fix MESH/SR/PRB/PNID/BV-02-C test case Private node identity advertisements must stop immediately when ordered by PTS. To do so; adding enabled parameter to btp_priv_node_id_get_cmd. Upstream PR #: 87891 Signed-off-by: alperen sener --- tests/bluetooth/tester/src/btp/btp_mesh.h | 3 +++ tests/bluetooth/tester/src/btp_mesh.c | 30 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) 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)