Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2525775pxp; Mon, 21 Mar 2022 23:32:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy98VTMX0a6OJmPBhj+EvirxHuxXfbE+M/bJSNOPc65x0LDFa20mGbcdzUGWqK8wrsk8oP8 X-Received: by 2002:a17:90a:9f0b:b0:1c6:a876:4157 with SMTP id n11-20020a17090a9f0b00b001c6a8764157mr3194094pjp.173.1647930779382; Mon, 21 Mar 2022 23:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647930779; cv=none; d=google.com; s=arc-20160816; b=ttqXmYDpRU5ps+3u7hRDNBf8R7KWDBvwABeLJphLlIMSmFBwniCfqzSuu5kTlDROXD bkY7r+xTRdmXtF2pluQtgjoZAORB0G+CdunzojTGpJaTbjjLJE92+Bwfsjzgsxqmf0xo u0C9AxsVi3mw57QT6kXI7S3+ULqHiwNNkf9bnzWNiYKZ8bLCEY2hSSV0m7wbpAhfy5to 5Cm2LUNXhyKm7i4fHVZATpNZoioGXcT8wUe6HMsLEXhtL8MhCETYFCj74AZVnofaMc6+ VAXbFd8pycL14MGIbJxnN3TGM2/RHqjmKNN8ISlt5GMCEG+GTuWbzObS+bMBEBCVQXFK GR3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yviPRoNCsxnnkW3G+JqFsi5JehNjFkYYjatmXaXYQm4=; b=Ua5QqDsbEh3/9/lZPMsCHynjZPE/CxSrmxcIZDtcbVH4Mntir++YE9Uxp5B24BchMS HuvD7afrHR3ubaynJU3aLucnq64nMCdfRBhI5ZlzNihj1ZKuYpwWmR+pfLXlj76B2ee1 Sdii2Otu/5oiff3YpJRSMfegRxfjpwrG8GdLBmne6wK/QE5PyXfuZkcxTqvD63lN8ZBZ KVaKK/8Sux3jT5A8+t+6dG+ReGOLWI6yRHqMNogy2P+UejOk7sh3KKCt4X1BIaCTCrNg nonpKOwxlkbx0k/kfL9dCuH4G2On6W03mbJNtbC1+b2upG7bE0xpMkLe959baHC+9Qjz 0XMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BneRAjS6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n37-20020a634d65000000b003825f9cfbcasi9157440pgl.776.2022.03.21.23.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 23:32:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BneRAjS6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC77BD4C; Mon, 21 Mar 2022 23:04:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236836AbiCVGGV (ORCPT + 99 others); Tue, 22 Mar 2022 02:06:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiCVGGU (ORCPT ); Tue, 22 Mar 2022 02:06:20 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F93AD4C for ; Mon, 21 Mar 2022 23:04:52 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-2db2add4516so179531957b3.1 for ; Mon, 21 Mar 2022 23:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yviPRoNCsxnnkW3G+JqFsi5JehNjFkYYjatmXaXYQm4=; b=BneRAjS6qMqGNPzt+IONjDb2LHUMmeC+2i3PL+czkdq6FJh6Ic6ablrCq8Vf1h568/ ouoazn+JGYRRvDcQgKIJn2Q1TGGlmawwrl5vash9Q/+wTpfvR+vQu9a4Kx5OxzHEW7q6 k+RlflnKeyL8KM9JmuftbnEFw1+zIBSsqYnlNIaU/TF1yA1bX20fVOKgWZKr3fc4ghYP otf712kEPfx0fmTuW4NSR6DBGxB23lMpWawXK3UuLidrefvbqZ7ONkmwHNN6l5zUrsDs 4MAxZFwbESG6Yv5Wob5bbjmZuaUrmehGkJcfXihJ+T2JJodrzESzrDb1gqK7eDWEVrDf 9Huw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yviPRoNCsxnnkW3G+JqFsi5JehNjFkYYjatmXaXYQm4=; b=Zhcmq8JHk4SUVEMJFElyuuge3Hb8dDuaYyHPaIxO+t8+jdLk1PaarLrVp+ogKHXZ8D 4sSPhuZLQaOq4jvF33eqctKBWWenLkznWLmBsNcBzZsJih1tsgBJpV7A1HDvVnys/Jm7 KbzlkrA58XJyecL2k77ak200ogKoT/6PM12AE8H4I+S32Y5YSJms25+LVQ97ggY4a0EO VU6HDTbCCuGAB7Nblmyi9T6hEHJRI0GQ2aEHsbN2J7RQYKTOsGHx94UAwzc6NC35noo7 /wTxfiBWSOGJuzbgrAJWtbgTh0DJj49Yw6HPQ/ZH+QpjYJqGU1Old8lIQlp+IfX8hS6S bi+Q== X-Gm-Message-State: AOAM530VfG0xWGtLy8B4DWNyPdDZlO2YdDnfddD2XwZkTawmjRZKeH3q m2OK/SfXpH3zJiijQ3vQtEa49n4TvQrOM3AY7rbXR6Nz X-Received: by 2002:a81:9ace:0:b0:2e6:5069:5f9e with SMTP id r197-20020a819ace000000b002e650695f9emr5526810ywg.317.1647929091421; Mon, 21 Mar 2022 23:04:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 21 Mar 2022 23:04:40 -0700 Message-ID: Subject: Re: GATT issue, possible bluez bug? To: Adam Pigg Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Adam, On Mon, Mar 21, 2022 at 5:43 PM Luiz Augusto von Dentz wrote: > > Hi Adam, > > On Mon, Mar 21, 2022 at 4:03 PM Adam Pigg wrote: > > > > Hi > > > > A bit of background, I write a linux desktop/mobile app called > > Amazfish which interfaces with several watches over BLE using their > > GATT services. To do this, I use the bluez dbus api (technically a > > thin wrapper around it I wrote called qble > > https://github.com/piggz/qble) > > > > All has been good so far, I support several generations of > > Huami/Amazfit watches, as well as the open source Pinetime and > > Bangle.js. For the Amazfit watches, i have implementations for older > > devies such as the Bip, and newer ones such as the GTS. > > > > Much of the reverse engineering comes from the Android Gadget Bridge > > project, which supports many more devices. > > > > My community of users donated to buy me a newer device called a GTR2, > > which, according to the GB devs uses the same protocol as the slightly > > older GTS, and the packet captures I have from Android would support > > this. > > > > But this is where my trouble starts with Bluez, my existing > > implementation doesnt work at all. Normally, after a connection, I > > would wait for the ServicesResolved signal, which happens pretty fast > > on all other devices, but on the GTR2, it takes about 30 seconds, by > > which time, the watch has disconnected. (i get a disconnected signal > > immediately after the ServicesResolved signal) > > > > To rule out my code, I have tried several things: > > Gatttool > > With gattool, i can connect, get the services, enable a notification, > > write a value and get the expected results seemingly fine > > > > Python-gatt (using the bluez dbus api) > > Im unable to iterate the services, like my app, it takes 30 seconds to > > get the signal and then swiftly disconnects > > > > Gattlib (https://github.com/labapart/gattlib) > > Gattlib is interesting as it appears to have "borrowed" much of its > > code directly from bluez. When built against the system bluez, if the > > version is > 5.42, it will use the dbus api. When I do this, again im > > unable to list services on the watch. However, if I edit the build to > > force it to use its internal gatt implementation, which appears to be > > the same one used by gatttool, then, it IS able to interrogate the > > watch. > > > > I have attached 3 files > > 1. test python program which should print services, and associated btmon > > 2. btmon output while using gatttool > > 3. btmon output running gattlib discover example > > > > Note, other than discovery, I havnt been able to get gattlib to > > read/write/notify! > > > > It seems as though I may be triggering a bug in the bluez dbus api? > > Can anyone suggest anything? > > What version are you using? I would first try with the latest to see > if that something already fixed. Btw, please use bluetoothctl instead of gatttool, gatttool may actually conflict with the bluetoothd. -- Luiz Augusto von Dentz