Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3289502pxb; Wed, 14 Apr 2021 01:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4qjQ/85GuN7XqbKjeByOSkwYVo6KxtTxOavDFXQTBHQdjwwsQ4OX4NWeXOxq3ClLMHW06 X-Received: by 2002:a17:907:c0b:: with SMTP id ga11mr16476981ejc.545.1618389720556; Wed, 14 Apr 2021 01:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618389720; cv=none; d=google.com; s=arc-20160816; b=LHiqNXjV+A7B0oZm0kUhlDKAPFZibbWkw0gFYNOWjROXB81Zz4SaxCSnD12K+gDT6t aDLdZ3uIk1hTzrcxCAElwthyfP5AU9C+Y7Ag9msXtpSiHoTue9oLeZNyV1IvMzjAZRsT CiSpYKWjADhyhGt7L+eDrYsgMyxFs84iaJqT0gpI4/wOEuy8lxdyhVcSVZA8MKU12l3H BGYOTnNuBgrZ/meCB3W9oG/xNmLfBObJnLUfdbHJpu2csZmYcIPDfiOasaEuT1B/5DfM Lze0GKfyZ1+sk5IFZn0EfkvWi07NqEXg47HZu8XckGJ8xxfxmWNiLMRdUCuBqOx3Vf23 IrCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=sUWIt/7pRjW3IpMlWYsAMBcyzn4hw7rvu20e98BsW3A=; b=uD8B90nrADIU2yEK4N5JKtFkBEP+GFRxmS6WZwBlM5sI16hG62yWKMV+RhTJnaBYUE he0JVn8/qkFYKu//RiNLM0vgGRgA0ezH+/1di1w38R2CFH5vSCfc8OboMUpz4i6rhYgz RtlN2JDqX7b+hu12It/UBLdsgUMFNVNdMT4URbgkt061XLnyh8QQVhi6DLeQGjXTxpF6 DTvsjOTimNmWkOFXyjmEYO6xWESJBvRoVzgb+phFZk+00quZW/KPcLN9I/6iOU+qcxOr z/0MRbFb53EBMm+83RotgLXuJZNzI0fqp+izrF8dj4mMuuV7ixvaYUCGj0FwuLuteklZ 2oSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sJOedLBY; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ne9si12186009ejc.229.2021.04.14.01.41.22; Wed, 14 Apr 2021 01:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sJOedLBY; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232361AbhDMV5n (ORCPT + 99 others); Tue, 13 Apr 2021 17:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232468AbhDMV5m (ORCPT ); Tue, 13 Apr 2021 17:57:42 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F9FCC061574 for ; Tue, 13 Apr 2021 14:57:22 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id d12so18496201oiw.12 for ; Tue, 13 Apr 2021 14:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=sUWIt/7pRjW3IpMlWYsAMBcyzn4hw7rvu20e98BsW3A=; b=sJOedLBYmawmkHTaGEXVWAxFz3ftqe+3fq6UDy2hzzbNQm+r5N8qtSwlkMaag6GZVS jaPY9BuNX2VKhC/0mDXmC4ocaCpwMWyibjeUOLM7KO3dswNWVbMMpHkXJ/no6hq9frYs 3CKQ/IQtXriP2sQCXYIdTM5CpIo5BdpcQvfN+gUVWA71DqtlMPdAPlhRQ5x6yC7j7WCl v0kAVIqD29s0GbC8PoUPTzHxWE1b75d+92JWX2mLNLFH3tk17aJ6DAHwb1rViAJrggmV GuB8f0DTMDTPnbPEYkoOM103Bdyckl/iaM+sxWMGB2BnemguGD3d7xVzM32nxNfmQdi7 3RpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sUWIt/7pRjW3IpMlWYsAMBcyzn4hw7rvu20e98BsW3A=; b=Xl9UHmA5fCMWviPZOWsYyIWqmoRheiEocFCy0ZAyovhkTYz2fSVv2AWdThpLKg+Q25 pCtbdmSYEETrZwyNz0u0ji+QpBycKAPhTM88Om2vTosTUZmJboyCJkuVG2lUJnIyJzmc uyexPuHKxcAI2QRh6Nlt0G9dwewmTmOXxvLqCqnefraofguMvokEFP9XL2dXHsTlshCx D00TaLXBitdQ5YGiXHhS3w6GLSbol9szCG9T22I00XnAXXLBuDjwusOnSw6Fo6iGuy9a puMCQUMupGqVxm/vTVVdFZg5k9K7byxeB1K0dqqxl80WmnxeABkWCHo5ygjTaPOIaJ45 5mkw== X-Gm-Message-State: AOAM532g56zOaU1ENsE22ILdvYgQKhJpuVYIWnMKoXUJ/9pZfp8CG7cA j07p1k4D9sfVRAy9+gmJr3ZS1nGGImVDwSncXalI6x1xaT63PA== X-Received: by 2002:a05:6808:1313:: with SMTP id y19mr1516769oiv.161.1618351041596; Tue, 13 Apr 2021 14:57:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Tue, 13 Apr 2021 14:57:10 -0700 Message-ID: Subject: Re: Disabled bluetooth cache. But the app still getting wrong data? To: Jamie Mccrae Cc: Kenny Bian , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Jamie, Brian, On Tue, Apr 13, 2021 at 2:03 AM Jamie Mccrae 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 ar= ound an issue created because you don't want to use the feature that preven= ts this issue. Any workaround is just that, a workaround, and might not wor= k 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 > Sent: 13 April 2021 06:59 > To: linux-bluetooth@vger.kernel.org > 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 th= e new build of our firmware, then the app will get the wrong data. > By saying changed characteristics, it can be an added or removed characte= ristic, 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 ther= e is no "service changed indication". The app can't handle the changed serv= ices. So we disabled the bluetooth cache by set this in > "/etc/bluetooth/main.conf": > [GATT] > Cache =3D 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 looke= d at the log. When the app tries to read temperature by using the temperatu= re UUID, somehow the bluetooth service we created received the request to r= ead the "device name"(device name UUID). So the "device name" is returned t= o the app as the temperature. This looks like the same behavior as the blue= tooth cache is not disabled. I looked at the "/var/lib/bluetooth/[BT_MAC]/c= ache" 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 pho= ne 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 "At= tribute group list: XX entries" under "ACL Data TX" in the attached problem= atic 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 F= URTHER BE INTENDED TO BE KEPT CONFIDENTIAL. IF YOU ARE NOT THE INTENDED REC= IPIENT, 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. --=20 Luiz Augusto von Dentz