From d9462735dd9cc5aa7e5568a118a49b88faacc210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Reierstad?= Date: Mon, 20 Jan 2025 11:04:20 +0100 Subject: [PATCH] Bluetooth: Mesh: Fix idx in dtt_srv_get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finds the element index used in `bt_mesh_dtt_srv_get` based on the composition data instead of the runtime address. Previously, the index used to locate the DTT Server was computed based on the runtime address set during provisioning. As the Scene Setup Server extends this model (which isn't necessarily present in the same element), model initialization would fail as the address wasn't yet set. Signed-off-by: HÃ¥vard Reierstad --- subsys/bluetooth/mesh/gen_dtt_srv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/mesh/gen_dtt_srv.c b/subsys/bluetooth/mesh/gen_dtt_srv.c index aebef312b0cc..83ecf99d62e5 100644 --- a/subsys/bluetooth/mesh/gen_dtt_srv.c +++ b/subsys/bluetooth/mesh/gen_dtt_srv.c @@ -195,7 +195,7 @@ struct bt_mesh_dtt_srv *bt_mesh_dtt_srv_get(const struct bt_mesh_elem *elem) const struct bt_mesh_comp *comp = bt_mesh_comp_get(); uint16_t index; - index = elem->rt->addr - comp->elem[0].rt->addr; + index = elem - comp->elem; for (int i = index; i >= 0; --i) { const struct bt_mesh_elem *element = &comp->elem[i];