From: NJNXP <nitin.jadhav@nxp.com>
To: linux-bluetooth@vger.kernel.org
Cc: devyani.godbole@nxp.com, mihai-octavian.urzica@nxp.com,
silviu.barbulescu@nxp.com, nitin.jadhav@nxp.com
Subject: [PATCH BlueZ v1 2/2] Fixed the following issue observed during PTS testing for mandatory test cases - Specified Upper and Lower Limit for Volume offset - Corrected the number of handles for VOCS - VOCS is made as included service of VCS because VOCS is secondary service and VSC is primary service
Date: Tue, 6 Jun 2023 15:08:24 +0300 [thread overview]
Message-ID: <20230606120824.4705-3-nitin.jadhav@nxp.com> (raw)
In-Reply-To: <20230606120824.4705-1-nitin.jadhav@nxp.com>
---
src/shared/vcp.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/shared/vcp.c b/src/shared/vcp.c
index 05e341108..b6e8ffdaf 100644
--- a/src/shared/vcp.c
+++ b/src/shared/vcp.c
@@ -32,9 +32,13 @@
#define VCP_STEP_SIZE 1
+#define VOCS_VOL_OFFSET_UPPER_LIMIT 255
+#define VOCS_VOL_OFFSET_LOWER_LIMIT -255
+
/* Apllication Error Code */
#define BT_ATT_ERROR_INVALID_CHANGE_COUNTER 0x80
#define BT_ATT_ERROR_OPCODE_NOT_SUPPORTED 0x81
+#define BT_ATT_ERROR_VALUE_OUT_OF_RANGE 0x82
#define GEN_AUDIO_AUDLOC_NA 0x00000000
#define GEN_AUDIO_AUDLOC_FL 0x00000001
@@ -100,7 +104,7 @@ struct bt_vcs_ab_vol {
struct bt_vocs_set_vol_off {
uint8_t change_counter;
- uint8_t set_vol_offset;
+ int16_t set_vol_offset;
} __packed;
struct bt_vcp_cb {
@@ -167,8 +171,8 @@ struct bt_vcs {
/* Contains local bt_vcp_db */
struct vol_offset_state {
- uint16_t vol_offset;
- uint8_t counter;
+ int16_t vol_offset;
+ uint8_t counter;
} __packed;
struct bt_vocs {
@@ -705,6 +709,10 @@ static uint8_t vocs_set_vol_offset(struct bt_vocs *vocs, struct bt_vcp *vcp,
return BT_ATT_ERROR_INVALID_CHANGE_COUNTER;
}
+ if(req->set_vol_offset > VOCS_VOL_OFFSET_UPPER_LIMIT || req->set_vol_offset < VOCS_VOL_OFFSET_LOWER_LIMIT) {
+ DBG(vcp, "error: Value Out of Range");
+ return BT_ATT_ERROR_VALUE_OUT_OF_RANGE;
+ }
vstate->vol_offset = req->set_vol_offset;
vstate->counter = -~vstate->counter; /*Increment Change Counter*/
@@ -971,7 +979,7 @@ static void vocs_voaodec_read(struct gatt_db_attribute *attrib,
iov.iov_len);
}
-static struct bt_vcs *vcs_new(struct gatt_db *db)
+static struct bt_vcs *vcs_new(struct gatt_db *db, struct bt_vcp_db *vdb)
{
struct bt_vcs *vcs;
struct vol_state *vstate;
@@ -990,6 +998,8 @@ static struct bt_vcs *vcs_new(struct gatt_db *db)
/* Populate DB with VCS attributes */
bt_uuid16_create(&uuid, VCS_UUID);
vcs->service = gatt_db_add_service(db, &uuid, true, 9);
+ gatt_db_service_add_included(vcs->service, vdb->vocs->service);
+ gatt_db_service_set_active(vdb->vocs->service, true);
bt_uuid16_create(&uuid, VOL_STATE_CHRC_UUID);
vcs->vs = gatt_db_service_add_characteristic(vcs->service,
@@ -1048,7 +1058,8 @@ static struct bt_vocs *vocs_new(struct gatt_db *db)
/* Populate DB with VOCS attributes */
bt_uuid16_create(&uuid, VOL_OFFSET_CS_UUID);
- vocs->service = gatt_db_add_service(db, &uuid, true, 9);
+
+ vocs->service = gatt_db_add_service(db, &uuid, false, 12);
bt_uuid16_create(&uuid, VOL_OFFSET_STATE_CHAR_UUID);
vocs->vos = gatt_db_service_add_characteristic(vocs->service,
@@ -1110,11 +1121,10 @@ static struct bt_vcp_db *vcp_db_new(struct gatt_db *db)
if (!vcp_db)
vcp_db = queue_new();
- vdb->vcs = vcs_new(db);
- vdb->vcs->vdb = vdb;
-
vdb->vocs = vocs_new(db);
vdb->vocs->vdb = vdb;
+ vdb->vcs = vcs_new(db, vdb);
+ vdb->vcs->vdb = vdb;
queue_push_tail(vcp_db, vdb);
--
2.34.1
next prev parent reply other threads:[~2023-06-06 12:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 12:08 [PATCH BlueZ v1 0/2] Code handling for VOCS service NJNXP
2023-06-06 12:08 ` [PATCH BlueZ v1 1/2] Added initial code for handling VOCS NJNXP
2023-06-06 13:31 ` Code handling for VOCS service bluez.test.bot
2023-06-06 23:11 ` [PATCH BlueZ v1 1/2] Added initial code for handling VOCS Luiz Augusto von Dentz
2023-06-06 12:08 ` NJNXP [this message]
2023-06-06 23:14 ` [PATCH BlueZ v1 0/2] Code handling for VOCS service Luiz Augusto von Dentz
2023-06-07 12:15 ` [EXT] " Nitin Jadhav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230606120824.4705-3-nitin.jadhav@nxp.com \
--to=nitin.jadhav@nxp.com \
--cc=devyani.godbole@nxp.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mihai-octavian.urzica@nxp.com \
--cc=silviu.barbulescu@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).