All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH Bluez v2] gatt: Either notify or indicate, do not do both
@ 2021-04-12 20:34 Curtis Maves
  2021-04-12 20:47 ` [Bluez,v2] " bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Curtis Maves @ 2021-04-12 20:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Curtis Maves

AcquireNotify and StartNotify starts notifications and/or indications
by whether the characteristic supports them. Before this patch, if both
were supported, Bluez would try to start both simultaneously. This
patch changes this behavior so if both are supported, only
notifications are started. Test cases have also be updated accordingly.
---
 src/shared/gatt-client.c | 10 +++++-----
 unit/test-gatt.c         | 43 +++++++++++++++++++++++++++-------------
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 4e10f244d..9511ea8ca 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1585,20 +1585,20 @@ static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
 {
 	uint8_t pdu[4];
 	unsigned int att_id;
+	uint16_t properties = notify_data->chrc->properties;
 
 	assert(notify_data->chrc->ccc_handle);
 	memset(pdu, 0, sizeof(pdu));
 	put_le16(notify_data->chrc->ccc_handle, pdu);
 
 	if (enable) {
-		/* Try to enable notifications and/or indications based on
+		/* Try to enable notifications or indications based on
 		 * whatever the characteristic supports.
 		 */
-		if (notify_data->chrc->properties & BT_GATT_CHRC_PROP_NOTIFY)
+		if (properties & BT_GATT_CHRC_PROP_NOTIFY)
 			pdu[2] = 0x01;
-
-		if (notify_data->chrc->properties & BT_GATT_CHRC_PROP_INDICATE)
-			pdu[2] |= 0x02;
+		else if (properties & BT_GATT_CHRC_PROP_INDICATE)
+			pdu[2] = 0x02;
 
 		if (!pdu[2])
 			return false;
diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 4aa87d09c..6a47268e6 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -241,8 +241,8 @@ struct context {
 #define CHARACTERISTIC_DISC_SMALL_DB					\
 		raw_pdu(0x08, 0x01, 0x00, 0xff, 0xff, 0x03, 0x28),	\
 		raw_pdu(0x09, 0x07, 0x02, 0x00, 0xb2, 0x03, 0x00, 0x29,	\
-			0x2a),						\
-		raw_pdu(0x08, 0x03, 0x00, 0xff, 0xff, 0x03, 0x28),	\
+			0x2a, 0x07, 0x00, 0x22, 0x08, 0x00, 0x28, 0x2a),\
+		raw_pdu(0x08, 0x08, 0x00, 0xff, 0xff, 0x03, 0x28),	\
 		raw_pdu(0x09, 0x07, 0x12, 0xf0, 0x02, 0x13, 0xf0, 0x00,	\
 			0x2a),						\
 		raw_pdu(0x08, 0x13, 0xf0, 0xff, 0xff, 0x03, 0x28),	\
@@ -256,11 +256,17 @@ struct context {
 		raw_pdu(0x01, 0x08, 0x18, 0xf0, 0x0a)
 
 #define DESCRIPTOR_DISC_SMALL_DB					\
-		raw_pdu(0x04, 0x04, 0x00, 0x10, 0x00),			\
+		raw_pdu(0x04, 0x04, 0x00, 0x06, 0x00),			\
 		raw_pdu(0x05, 0x01, 0x04, 0x00, 0x02, 0x29, 0x05, 0x00,	\
 			0x01, 0x29),					\
-		raw_pdu(0x04, 0x06, 0x00, 0x10, 0x00),			\
-		raw_pdu(0x01, 0x04, 0x06, 0x00, 0x0a),			\
+		raw_pdu(0x04, 0x06, 0x00, 0x06, 0x00),			\
+		raw_pdu(0x05, 0x01, 0x06, 0x00, 0x00, 0x29),		\
+		raw_pdu(0x0a, 0x06, 0x00),				\
+		raw_pdu(0x0b, 0x01, 0x00),				\
+		raw_pdu(0x04, 0x09, 0x00, 0x10, 0x00),			\
+		raw_pdu(0x05, 0x01, 0x09, 0x00, 0x02, 0x29),		\
+		raw_pdu(0x04, 0x0a, 0x00, 0x10, 0x00),			\
+		raw_pdu(0x01, 0x04, 0x0a, 0x00, 0x0a),			\
 		raw_pdu(0x04, 0x16, 0xf0, 0x16, 0xf0),			\
 		raw_pdu(0x05, 0x01, 0x16, 0xf0, 0x00, 0x29),		\
 		raw_pdu(0x0a, 0x16, 0xf0),				\
@@ -1565,6 +1571,13 @@ static struct gatt_db *make_test_spec_small_db(void)
 							"Manufacturer Name"),
 		DESCRIPTOR(GATT_CHARAC_EXT_PROPER_UUID, BT_ATT_PERM_READ, 0x01,
 									0x00),
+		CHARACTERISTIC_STR(GATT_CHARAC_SOFTWARE_REVISION_STRING,
+						BT_ATT_PERM_READ,
+						BT_GATT_CHRC_PROP_READ |
+						BT_GATT_CHRC_PROP_INDICATE,
+						"5.59"),
+		DESCRIPTOR(GATT_CLIENT_CHARAC_CFG_UUID, BT_ATT_PERM_READ
+			| BT_ATT_PERM_WRITE, 0x00, 0x00),
 
 		PRIMARY_SERVICE(0xF010, GAP_UUID, 9),
 		INCLUDE(0x0001),
@@ -2308,7 +2321,7 @@ static void test_indication(struct context *context)
 }
 
 static const struct test_step test_indication_1 = {
-	.handle = 0x0003,
+	.handle = 0x0008,
 	.func = test_indication,
 	.value = read_data_1,
 	.length = 0x03,
@@ -2573,9 +2586,10 @@ int main(int argc, char *argv[])
 			raw_pdu(0x03, 0x00, 0x02),
 			raw_pdu(0x08, 0x01, 0x00, 0x0f, 0x00, 0x03, 0x28),
 			raw_pdu(0x09, 0x07, 0x02, 0x00, 0xb2, 0x03, 0x00, 0x29,
-					0x2a),
-			raw_pdu(0x08, 0x03, 0x00, 0x0f, 0x00, 0x03, 0x28),
-			raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a));
+					0x2a, 0x07, 0x00, 0x22, 0x08, 0x00,
+					0x28, 0x2a),
+			raw_pdu(0x08, 0x08, 0x00, 0x0f, 0x00, 0x03, 0x28),
+			raw_pdu(0x01, 0x08, 0x08, 0x00, 0x0a));
 
 	define_test_server("/TP/GAD/SR/BV-04-C/large-1", test_server,
 			ts_large_db_1, NULL,
@@ -2626,9 +2640,10 @@ int main(int argc, char *argv[])
 			raw_pdu(0x03, 0x00, 0x02),
 			raw_pdu(0x08, 0x01, 0x00, 0x0f, 0x00, 0x03, 0x28),
 			raw_pdu(0x09, 0x07, 0x02, 0x00, 0xb2, 0x03, 0x00, 0x29,
-					0x2a),
-			raw_pdu(0x08, 0x03, 0x00, 0x0f, 0x00, 0x03, 0x28),
-			raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a));
+					0x2a, 0x07, 0x00, 0x22, 0x08, 0x00,
+					0x28, 0x2a),
+			raw_pdu(0x08, 0x08, 0x00, 0x0f, 0x00, 0x03, 0x28),
+			raw_pdu(0x01, 0x08, 0x08, 0x00, 0x0a));
 
 	define_test_server("/TP/GAD/SR/BV-05-C/large-1", test_server,
 			ts_large_db_1, NULL,
@@ -3241,7 +3256,7 @@ int main(int argc, char *argv[])
 			&test_notification_1,
 			CLIENT_INIT_PDUS,
 			SMALL_DB_DISCOVERY_PDUS,
-			raw_pdu(0x12, 0x04, 0x00, 0x03, 0x00),
+			raw_pdu(0x12, 0x04, 0x00, 0x01, 0x00),
 			raw_pdu(0x13),
 			raw_pdu(),
 			raw_pdu(0x1B, 0x03, 0x00, 0x01, 0x02, 0x03));
@@ -3267,7 +3282,7 @@ int main(int argc, char *argv[])
 			&test_indication_1,
 			CLIENT_INIT_PDUS,
 			SMALL_DB_DISCOVERY_PDUS,
-			raw_pdu(0x12, 0x04, 0x00, 0x03, 0x00),
+			raw_pdu(0x12, 0x09, 0x00, 0x02, 0x00),
 			raw_pdu(0x13),
 			raw_pdu(),
 			raw_pdu(0x1D, 0x03, 0x00, 0x01, 0x02, 0x03),
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [Bluez,v2] gatt: Either notify or indicate, do not do both
  2021-04-12 20:34 [PATCH Bluez v2] gatt: Either notify or indicate, do not do both Curtis Maves
@ 2021-04-12 20:47 ` bluez.test.bot
  2021-04-13 21:24   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: bluez.test.bot @ 2021-04-12 20:47 UTC (permalink / raw)
  To: linux-bluetooth, curtis

[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=465885

---Test result---

Test Summary:
CheckPatch                    PASS      0.30 seconds
GitLint                       PASS      0.10 seconds
Prep - Setup ELL              PASS      40.34 seconds
Build - Prep                  PASS      0.10 seconds
Build - Configure             PASS      7.08 seconds
Build - Make                  PASS      168.14 seconds
Make Check                    PASS      8.33 seconds
Make Dist                     PASS      11.23 seconds
Make Dist - Configure         PASS      4.40 seconds
Make Dist - Make              PASS      68.95 seconds
Build w/ext ELL - Configure   PASS      7.14 seconds
Build w/ext ELL - Make        PASS      161.10 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Dist - PASS
Desc: Run 'make dist' and build the distribution tarball

##############################
Test: Make Dist - Configure - PASS
Desc: Configure the source from distribution tarball

##############################
Test: Make Dist - Make - PASS
Desc: Build the source from distribution tarball

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Bluez,v2] gatt: Either notify or indicate, do not do both
  2021-04-12 20:47 ` [Bluez,v2] " bluez.test.bot
@ 2021-04-13 21:24   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2021-04-13 21:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Curtis

Hi Curtis,

On Tue, Apr 13, 2021 at 12:07 AM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=465885
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    PASS      0.30 seconds
> GitLint                       PASS      0.10 seconds
> Prep - Setup ELL              PASS      40.34 seconds
> Build - Prep                  PASS      0.10 seconds
> Build - Configure             PASS      7.08 seconds
> Build - Make                  PASS      168.14 seconds
> Make Check                    PASS      8.33 seconds
> Make Dist                     PASS      11.23 seconds
> Make Dist - Configure         PASS      4.40 seconds
> Make Dist - Make              PASS      68.95 seconds
> Build w/ext ELL - Configure   PASS      7.14 seconds
> Build w/ext ELL - Make        PASS      161.10 seconds
>
> Details
> ##############################
> Test: CheckPatch - PASS
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
>
> ##############################
> Test: GitLint - PASS
> Desc: Run gitlint with rule in .gitlint
>
> ##############################
> Test: Prep - Setup ELL - PASS
> Desc: Clone, build, and install ELL
>
> ##############################
> Test: Build - Prep - PASS
> Desc: Prepare environment for build
>
> ##############################
> Test: Build - Configure - PASS
> Desc: Configure the BlueZ source tree
>
> ##############################
> Test: Build - Make - PASS
> Desc: Build the BlueZ source tree
>
> ##############################
> Test: Make Check - PASS
> Desc: Run 'make check'
>
> ##############################
> Test: Make Dist - PASS
> Desc: Run 'make dist' and build the distribution tarball
>
> ##############################
> Test: Make Dist - Configure - PASS
> Desc: Configure the source from distribution tarball
>
> ##############################
> Test: Make Dist - Make - PASS
> Desc: Build the source from distribution tarball
>
> ##############################
> Test: Build w/ext ELL - Configure - PASS
> Desc: Configure BlueZ source with '--enable-external-ell' configuration
>
> ##############################
> Test: Build w/ext ELL - Make - PASS
> Desc: Build BlueZ source with '--enable-external-ell' configuration
>
>
>
> ---
> Regards,
> Linux Bluetooth
>

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-13 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 20:34 [PATCH Bluez v2] gatt: Either notify or indicate, do not do both Curtis Maves
2021-04-12 20:47 ` [Bluez,v2] " bluez.test.bot
2021-04-13 21:24   ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.