From 2d88e3934f590405e13e6122c324e69f6a0dab07 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Tue, 28 Jun 2022 17:37:43 +0200 Subject: [PATCH] Bluetooth: has: Fix sending invalid opcode error If preset synchronization is not supported, Preset Sync Not Supported (0x82) shall be sent in error response. Fixes: HAS/SR/SPE/BI-04-C, HAS/SR/SPE/BI-05-C, HAS/SR/SPE/BI-06-C Signed-off-by: Mariusz Skamra --- subsys/bluetooth/audio/has.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c index efae8ce05b1..eb3cb1e6fe7 100644 --- a/subsys/bluetooth/audio/has.c +++ b/subsys/bluetooth/audio/has.c @@ -701,14 +701,24 @@ static uint8_t handle_control_point_op(struct bt_conn *conn, struct net_buf_simp return handle_set_next_preset(false); case BT_HAS_OP_SET_PREV_PRESET: return handle_set_prev_preset(false); -#if defined(CONFIG_BT_HAS_PRESET_SYNC_SUPPORT) case BT_HAS_OP_SET_ACTIVE_PRESET_SYNC: - return handle_set_active_preset(buf, true); + if (IS_ENABLED(CONFIG_BT_HAS_PRESET_SYNC_SUPPORT)) { + return handle_set_active_preset(buf, true); + } else { + return BT_HAS_ERR_PRESET_SYNC_NOT_SUPP; + } case BT_HAS_OP_SET_NEXT_PRESET_SYNC: - return handle_set_next_preset(true); + if (IS_ENABLED(CONFIG_BT_HAS_PRESET_SYNC_SUPPORT)) { + return handle_set_next_preset(true); + } else { + return BT_HAS_ERR_PRESET_SYNC_NOT_SUPP; + } case BT_HAS_OP_SET_PREV_PRESET_SYNC: - return handle_set_prev_preset(true); -#endif /* CONFIG_BT_HAS_PRESET_SYNC_SUPPORT */ + if (IS_ENABLED(CONFIG_BT_HAS_PRESET_SYNC_SUPPORT)) { + return handle_set_prev_preset(true); + } else { + return BT_HAS_ERR_PRESET_SYNC_NOT_SUPP; + } }; return BT_HAS_ERR_INVALID_OPCODE;