From ad6f9b15e6fd38243bdfb30b91f7f3855e21b711 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 3 Dec 2017 09:34:15 +0200 Subject: [PATCH] Bluetooth: Mesh: Fix changing Relay state from Not Supported (0x02) If the Relay state is set to Not Supported (0x02) the Config Relay Set message should not change the state, rather just return its current value. Signed-off-by: Johan Hedberg --- subsys/bluetooth/host/mesh/cfg_srv.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/host/mesh/cfg_srv.c b/subsys/bluetooth/host/mesh/cfg_srv.c index 63c3674ce84..8cb8e23759f 100644 --- a/subsys/bluetooth/host/mesh/cfg_srv.c +++ b/subsys/bluetooth/host/mesh/cfg_srv.c @@ -908,14 +908,20 @@ static void relay_set(struct bt_mesh_model *model, if (!cfg) { BT_WARN("No Configuration Server context available"); } else if (buf->data[0] == 0x00 || buf->data[0] == 0x01) { - bool change = (cfg->relay != buf->data[0]); struct bt_mesh_subnet *sub; + bool change; - cfg->relay = buf->data[0]; - cfg->relay_retransmit = buf->data[1]; + if (cfg->relay == BT_MESH_RELAY_NOT_SUPPORTED) { + change = false; + } else { + change = (cfg->relay != buf->data[0]); + cfg->relay = buf->data[0]; + cfg->relay_retransmit = buf->data[1]; + } - BT_DBG("Relay 0x%02x Retransmit 0x%02x (count %u interval %u)", - cfg->relay, cfg->relay_retransmit, + BT_DBG("Relay 0x%02x (%s) xmit 0x%02x (count %u interval %u)", + cfg->relay, change ? "changed" : "not changed", + cfg->relay_retransmit, BT_MESH_TRANSMIT_COUNT(cfg->relay_retransmit), BT_MESH_TRANSMIT_INT(cfg->relay_retransmit))