Return-Path: MIME-Version: 1.0 In-Reply-To: References: <1426712691-5048-1-git-send-email-luiz.dentz@gmail.com> <1426712691-5048-6-git-send-email-luiz.dentz@gmail.com> <550A7C86.8050403@ubnt.com> Date: Thu, 19 Mar 2015 12:56:52 +0200 Message-ID: Subject: Re: [PATCH BlueZ 5/5] shared/gatt-client: Fix service discovery From: Luiz Augusto von Dentz To: Andrejs Hanins Cc: "linux-bluetooth@vger.kernel.org" Content-Type: multipart/mixed; boundary=001a11c34c54bb99010511a20e93 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: --001a11c34c54bb99010511a20e93 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Andrejs, On Thu, Mar 19, 2015 at 12:17 PM, Luiz Augusto von Dentz wrote: > Hi Andrejs, > > On Thu, Mar 19, 2015 at 9:36 AM, Andrejs Hanins = wrote: >> Hi Luiz >> >> On 2015.03.18. 23:04, Luiz Augusto von Dentz wrote: >>> From: Luiz Augusto von Dentz >>> >>> The code should proceed to discover all descriptors before moving to >>> next service otherwise it may attempt to insert characteristics in the >>> wrong service which would probably fail. >>> --- >>> src/shared/gatt-client.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c >>> index 3e28c6e..729bd87 100644 >>> --- a/src/shared/gatt-client.c >>> +++ b/src/shared/gatt-client.c >>> @@ -690,13 +690,13 @@ static void discover_descs_cb(bool success, uint8= _t att_ecode, >>> goto failed; >>> } >>> >>> +next: >>> if (!discover_descs(op, &discovering)) >>> goto failed; >>> >>> if (discovering) >>> return; >>> >>> -next: >>> /* Done with the current service */ >>> gatt_db_service_set_active(op->cur_svc, true); >>> >>> >> >> I tested this new patch-set and and results are the following: >> 1. Three characteristics (GAP, GATT and custom) do appear on D-BUs. This= was not the case before. >> 2. CCC descriptor still does not appear on D-Bus. If I change handles on= the peripheral back to sequential, then CCC appears on D-Bus also. >> 3. Reading of any characteristic times out with 'g-io-error-quark: Timeo= ut was reached (24)'. Logs attached. Based on HCI dumps the ATT reading is = OK, but for some reason result is not propagated to the D-Bus level, so D-D= bus method times out. With sequential handles reading works fine. > > Strange for me it is working normally: > > [NEW] Service /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011 > Battery Service (Primary) > [NEW] Characteristic > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012 Battery > Level > [NEW] Descriptor > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012/desc0014 > Client Characteristic Configuration > [Arc Touch Mouse SE]# select-attribute > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012 > [Arc Touch Mouse SE:/service0011/char0012]# read > Attempting to read /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char= 0012 > [CHG] Attribute > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012 Value: 0x5d > 5d ] > [Arc Touch Mouse SE:/service0011/char0012]# select-attribute > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012/desc0014 > [Arc Touch Mouse SE:/service0011/char0012/desc0014]# read > Attempting to read > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012/desc0014 > [CHG] Attribute > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012/desc0014 > Value: 0x00 > [CHG] Attribute > /org/bluez/hci0/dev_F3_43_74_B7_86_24/service0011/char0012/desc0014 > Value: 0x00 > 00 00 > > But perhaps this is because the handles are in sequence as you said, > can you try with the following changes: > > http://fpaste.org/199962/67601931/ See if the attachment works. --=20 Luiz Augusto von Dentz --001a11c34c54bb99010511a20e93 Content-Type: text/x-patch; charset=US-ASCII; name="0001-core-gatt-Fix-not-replying-if-db-operation-fail.patch" Content-Disposition: attachment; filename="0001-core-gatt-Fix-not-replying-if-db-operation-fail.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i7g1ma9i0 RnJvbSBkYmFkMDNiZjE0MzJmMWVlYzMyNjBmNmRiNzd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