Bluetooth: Audio: Fix HAS double register
Calling bt_has_register multiple times would cause attempts to register a HAS multiple times. Fixed by adding a check and return with EALREADY if it is already registered. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
c45bc68e5c
commit
d6055f9938
1 changed files with 7 additions and 0 deletions
|
@ -1128,6 +1128,7 @@ int bt_has_preset_name_change(uint8_t index, const char *name)
|
||||||
|
|
||||||
int bt_has_register(const struct bt_has_register_param *param)
|
int bt_has_register(const struct bt_has_register_param *param)
|
||||||
{
|
{
|
||||||
|
static bool registered;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
LOG_DBG("param %p", param);
|
LOG_DBG("param %p", param);
|
||||||
|
@ -1137,6 +1138,10 @@ int bt_has_register(const struct bt_has_register_param *param)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (registered) {
|
||||||
|
return -EALREADY;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the supported features characteristic value */
|
/* Initialize the supported features characteristic value */
|
||||||
has.features = param->type;
|
has.features = param->type;
|
||||||
|
|
||||||
|
@ -1179,5 +1184,7 @@ int bt_has_register(const struct bt_has_register_param *param)
|
||||||
k_work_init(&active_preset_work, active_preset_work_process);
|
k_work_init(&active_preset_work, active_preset_work_process);
|
||||||
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT */
|
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT */
|
||||||
|
|
||||||
|
registered = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue