bluetooth: tester: HAS Preset initialization done by auto-pts client.

- Removed preset initializations. Done in auto-pts client.
- Added one additional preset in overlay-le-audio.conf.

Signed-off-by: Henrik Eriksen <heri@demant.com>
This commit is contained in:
Henrik Eriksen 2023-11-22 14:34:56 +01:00 committed by Henrik Brix Andersen
parent 839553a7d9
commit 8f0b1f6424
3 changed files with 16 additions and 45 deletions

View file

@ -87,7 +87,7 @@ CONFIG_BT_IAS_CLIENT=y
# HAS
CONFIG_BT_HAS=y
CONFIG_BT_HAS_PRESET_COUNT=5
CONFIG_BT_HAS_PRESET_COUNT=6
CONFIG_BT_HAS_PRESET_NAME_DYNAMIC=y
# CSIS

View file

@ -5,6 +5,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/bluetooth/addr.h>
/* HAS commands */
#define BTP_HAS_READ_SUPPORTED_COMMANDS 0x01

View file

@ -21,8 +21,12 @@ static uint8_t has_supported_commands(const void *cmd, uint16_t cmd_len,
{
struct btp_has_read_supported_commands_rp *rp = rsp;
/* octet 0 */
tester_set_bit(rp->data, BTP_HAS_READ_SUPPORTED_COMMANDS);
tester_set_bit(rp->data, BTP_HAS_SET_ACTIVE_INDEX);
tester_set_bit(rp->data, BTP_HAS_SET_PRESET_NAME);
tester_set_bit(rp->data, BTP_HAS_REMOVE_PRESET);
tester_set_bit(rp->data, BTP_HAS_ADD_PRESET);
tester_set_bit(rp->data, BTP_HAS_SET_PROPERTIES);
*rsp_len = sizeof(*rp) + 1;
@ -35,7 +39,7 @@ static uint8_t has_set_active_index(const void *cmd, uint16_t cmd_len,
const struct btp_has_set_active_index_cmd *cp = cmd;
int err = bt_has_preset_active_set(cp->index);
return (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
return BTP_STATUS_VAL(err);
}
static uint16_t has_presets;
@ -55,7 +59,7 @@ static uint8_t has_set_preset_name(const void *cmd, uint16_t cmd_len,
temp_name[name_len] = '\0';
err = bt_has_preset_name_change(cp->index, temp_name);
}
return (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
return BTP_STATUS_VAL(err);
}
static uint8_t has_remove_preset(const void *cmd, uint16_t cmd_len,
@ -80,7 +84,7 @@ static uint8_t has_remove_preset(const void *cmd, uint16_t cmd_len,
has_presets &= ~(1 << (cp->index - 1));
}
}
return (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
return BTP_STATUS_VAL(err);
}
static int has_preset_selected(unsigned char index, bool sync)
@ -112,7 +116,7 @@ static uint8_t has_add_preset(const void *cmd, uint16_t cmd_len,
has_presets |= 1 << (cp->index - 1);
}
}
return (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
return BTP_STATUS_VAL(err);
}
static uint8_t has_set_properties(const void *cmd, uint16_t cmd_len,
@ -123,7 +127,7 @@ static uint8_t has_set_properties(const void *cmd, uint16_t cmd_len,
bt_has_preset_available(cp->index) :
bt_has_preset_unavailable(cp->index);
return (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
return BTP_STATUS_VAL(err);
}
static const struct btp_handler has_handlers[] = {
@ -160,53 +164,19 @@ static const struct btp_handler has_handlers[] = {
}
};
static const char *preset_name(uint8_t index)
{
switch (index) {
case 0: return "PRESET_0";
case 1: return "PRESET_1";
case 2: return "PRESET_2";
case 3: return "PRESET_3";
case 4: return "PRESET_4";
case 5: return "PRESET_5";
case 6: return "PRESET_6";
case 7: return "PRESET_7";
default: return "PRESET_?";
}
}
#define PRESETS_CONFIGURED 3
#define LAST_PRESET MIN(PRESETS_CONFIGURED, CONFIG_BT_HAS_PRESET_COUNT)
uint8_t tester_init_has(void)
{
tester_register_command_handlers(BTP_SERVICE_ID_HAS, has_handlers,
ARRAY_SIZE(has_handlers));
struct bt_has_features_param params = {
BT_HAS_HEARING_AID_TYPE_BINAURAL, false, true
.type = BT_HAS_HEARING_AID_TYPE_BINAURAL,
.preset_sync_support = false,
.independent_presets = IS_ENABLED(CONFIG_BT_HAS_PRESET_SUPPORT)
};
int err = bt_has_register(&params);
if (!err) {
for (uint8_t index = 1; index <= LAST_PRESET; index++) {
enum bt_has_properties properties = (index < PRESETS_CONFIGURED) ?
BT_HAS_PROP_WRITABLE | BT_HAS_PROP_AVAILABLE :
BT_HAS_PROP_WRITABLE;
struct bt_has_preset_register_param preset_params = {
index, properties, preset_name(index), &has_preset_ops
};
err = bt_has_preset_register(&preset_params);
if (!err) {
has_presets |= 1 << (index - 1);
} else {
break;
}
}
}
return (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS;
return BTP_STATUS_VAL(err);
}
uint8_t tester_unregister_has(void)