Re: Disabled bluetooth cache. But the app still getting wrong data?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jamie, Brian,

On Tue, Apr 13, 2021 at 2:03 AM Jamie Mccrae
<Jamie.Mccrae@xxxxxxxxxxxxxxxx> wrote:
>
> Hi Kenny,
> Why not just add the service changed indication as you refer to below? It was purposely designed for this specific purpose, you're trying to work around an issue created because you don't want to use the feature that prevents this issue. Any workaround is just that, a workaround, and might not work as intended.

Yep, and while at it implement the so called Robust Caching feature so
we can detect if anything has changed by reading the DB Hash.

> Thanks,
> Jamie
>
> -----Original Message-----
> From: Kenny Bian <kennybian@xxxxxxxxx>
> Sent: 13 April 2021 06:59
> To: linux-bluetooth@xxxxxxxxxxxxxxx
> Subject: Disabled bluetooth cache. But the app still getting wrong data?
>
> EXTERNAL EMAIL: Be careful with attachments and links.
>
> Previously we had an issue: if there is a change of characteristics in the new build of our firmware, then the app will get the wrong data.
> By saying changed characteristics, it can be an added or removed characteristic, or adding notification to an existing characteristic.
> In order to keep the pairing information, the "/var/lib/bluetooth"
> folder is copied over to the new build's partition. We realized that there is no "service changed indication". The app can't handle the changed services. So we disabled the bluetooth cache by set this in
> "/etc/bluetooth/main.conf":
> [GATT]
> Cache = no

When you say the app can't handle changed service do you mean BlueZ
doesn't emit changes to the attributes (via Service Changed) or is it
really the application not being able to handle the changes?

> But recently, we saw the problem again even if the bluetooth cache is
> disabled: in the build number 101, a characteristic is removed. But when we upgrade the build from 100 to 101, the app gets the wrong data. We looked at the log. When the app tries to read temperature by using the temperature UUID, somehow the bluetooth service we created received the request to read the "device name"(device name UUID). So the "device name" is returned to the app as the temperature. This looks like the same behavior as the bluetooth cache is not disabled. I looked at the "/var/lib/bluetooth/[BT_MAC]/cache" folder. There is no "[Attributes]" section in the files in the folder. That means the disabled cache seems working.

So BlueZ is acting as the server, right? The Cache only applies to the
client portion, there is no such thing as disabling the remote cache.
I don't see any incoming Read By Group Request from the remote so it
is very likely that it has cached the values, there is no Read By Type
for the DB Hash either which is quite surprising to me since that is
required for stacks supporting Robust Caching which I believe is the
case of iOS.

Anyway, I would check that the following lines are being triggered:

When starting:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/gatt-database.c#n3798

On connect:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/gatt-database.c#n3741

If those lines are not being triggered it is likely a client problem
which for some reason had not subscribed to received service changes
for some reason, if it doesn't subscribe to service changes then it
shall not cache any attribute and attempt to rediscover on every
connection.

> The only way to fix this issue is to force exit the mobile app on the phone and "Forget This Device" in iOS or "Unpair" in Android.
>
> I looked at the btmon(see attached). For the working btmon log, there is "Attribute group list: XX entries" under "ACL Data TX". But there is no "Attribute group list: XX entries" under "ACL Data TX" in the attached problematic btmon log.
>
> Questions:
> 1. How is it possible that this still happens even if the bluetooth cache is disabled?
> 2. Is this the problem on the Linux side which runs the GATT server or on the mobile side?
> 3. Is there anything else we should look into?
>
> We're going to release our product soon. This is a critical issue for us. Please help if you have any suggestions.
>
> Thanks!
> THIS MESSAGE, ANY ATTACHMENT(S), AND THE INFORMATION CONTAINED HEREIN MAY BE PROPRIETARY TO LAIRD CONNECTIVITY, INC. AND/OR ANOTHER PARTY, AND MAY FURTHER BE INTENDED TO BE KEPT CONFIDENTIAL. IF YOU ARE NOT THE INTENDED RECIPIENT, PLEASE DELETE THE EMAIL AND ANY ATTACHMENTS, AND IMMEDIATELY NOTIFY THE SENDER BY RETURN EMAIL. THIS MESSAGE AND ITS CONTENTS ARE THE PROPERTY OF LAIRD CONNECTIVITY, INC. AND MAY NOT BE REPRODUCED OR USED WITHOUT THE EXPRESS WRITTEN CONSENT OF LAIRD CONNECTIVITY, INC.



-- 
Luiz Augusto von Dentz




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux