Bluetooth: Audio: Ignore RFU VOCS location
This commit changes VOCS set location behavior. When an RFU location is written, VOCS ignores it. Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
This commit is contained in:
parent
0acc7fdd58
commit
77c8cffae0
2 changed files with 44 additions and 4 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "audio_internal.h"
|
||||
#include "vocs_internal.h"
|
||||
#include "zephyr/bluetooth/audio/audio.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_BT_VOCS_LOG_LEVEL
|
||||
#include <zephyr/logging/log.h>
|
||||
|
@ -26,6 +27,8 @@ LOG_MODULE_REGISTER(bt_vocs);
|
|||
|
||||
#define VALID_VOCS_OPCODE(opcode) ((opcode) == BT_VOCS_OPCODE_SET_OFFSET)
|
||||
|
||||
#define BT_AUDIO_LOCATION_RFU (~BT_AUDIO_LOCATION_ANY)
|
||||
|
||||
#if defined(CONFIG_BT_VOCS)
|
||||
static void offset_state_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
|
||||
{
|
||||
|
@ -53,7 +56,7 @@ static ssize_t write_location(struct bt_conn *conn, const struct bt_gatt_attr *a
|
|||
const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
|
||||
{
|
||||
struct bt_vocs *inst = BT_AUDIO_CHRC_USER_DATA(attr);
|
||||
uint32_t old_location = inst->srv.location;
|
||||
enum bt_audio_location new_location;
|
||||
|
||||
if (offset) {
|
||||
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
|
||||
|
@ -63,10 +66,14 @@ static ssize_t write_location(struct bt_conn *conn, const struct bt_gatt_attr *a
|
|||
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
|
||||
}
|
||||
|
||||
memcpy(&inst->srv.location, buf, len);
|
||||
LOG_DBG("%02x", inst->srv.location);
|
||||
new_location = sys_get_le32(buf);
|
||||
if ((new_location & BT_AUDIO_LOCATION_RFU) > 0) {
|
||||
LOG_DBG("Invalid location %u", new_location);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (old_location != inst->srv.location) {
|
||||
if (new_location != inst->srv.location) {
|
||||
inst->srv.location = new_location;
|
||||
(void)bt_gatt_notify_uuid(NULL, BT_UUID_VOCS_LOCATION,
|
||||
inst->srv.service_p->attrs,
|
||||
&inst->srv.location,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue