Bluetooth: audio: Fix error message in PACS

Change error code in PACS source/sink
write operation to Write Request Rejected.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
This commit is contained in:
Szymon Czapracki 2022-08-23 14:55:23 +02:00 committed by Fabio Baltieri
commit 85639f78bd

View file

@ -307,25 +307,25 @@ static ssize_t snk_loc_write(struct bt_conn *conn,
} }
if (len != sizeof(location)) { if (len != sizeof(location)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
if (pacs_cb == NULL || if (pacs_cb == NULL ||
pacs_cb->write_location == NULL) { pacs_cb->write_location == NULL) {
BT_WARN("No callback for write_location"); BT_WARN("No callback for write_location");
return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
location = (enum bt_audio_location)sys_get_le32(data); location = (enum bt_audio_location)sys_get_le32(data);
if (location > BT_AUDIO_LOCATION_MASK || location == 0) { if (location > BT_AUDIO_LOCATION_MASK || location == 0) {
BT_DBG("Invalid location value: 0x%08X", location); BT_DBG("Invalid location value: 0x%08X", location);
return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
err = pacs_cb->write_location(conn, BT_AUDIO_DIR_SINK, location); err = pacs_cb->write_location(conn, BT_AUDIO_DIR_SINK, location);
if (err != 0) { if (err != 0) {
BT_DBG("write_location returned %d", err); BT_DBG("write_location returned %d", err);
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
return len; return len;
@ -403,25 +403,25 @@ static ssize_t src_loc_write(struct bt_conn *conn,
} }
if (len != sizeof(location)) { if (len != sizeof(location)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
if (pacs_cb == NULL || if (pacs_cb == NULL ||
pacs_cb->write_location == NULL) { pacs_cb->write_location == NULL) {
BT_WARN("No callback for write_location"); BT_WARN("No callback for write_location");
return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
location = (enum bt_audio_location)sys_get_le32(data); location = (enum bt_audio_location)sys_get_le32(data);
if (location > BT_AUDIO_LOCATION_MASK || location == 0) { if (location > BT_AUDIO_LOCATION_MASK || location == 0) {
BT_DBG("Invalid location value: 0x%08X", location); BT_DBG("Invalid location value: 0x%08X", location);
return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
err = pacs_cb->write_location(conn, BT_AUDIO_DIR_SOURCE, location); err = pacs_cb->write_location(conn, BT_AUDIO_DIR_SOURCE, location);
if (err != 0) { if (err != 0) {
BT_DBG("write_location returned %d", err); BT_DBG("write_location returned %d", err);
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} }
return len; return len;