Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2569579pxp; Tue, 22 Mar 2022 00:59:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylP5nxqvQpyu+3ttmwlWssJNJO8DVBTirdfBGwcQCkSvIohpL2wYsLFnpoF+xZGOHFGFh7 X-Received: by 2002:a17:902:ea04:b0:154:63ae:ab97 with SMTP id s4-20020a170902ea0400b0015463aeab97mr7304764plg.110.1647935992423; Tue, 22 Mar 2022 00:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647935992; cv=none; d=google.com; s=arc-20160816; b=UmEHXB9WC9nL+BP/QMAcfVvtFhENwivbqu4GcDmcW06x7bF9TPf9CJ/sI+ex/KdtHw yAEORPDSnihbmuuXWtwP+sfAgiJPJUjhELowJin1HGOTG6G9WZ5L3v+DMNEoKAIc6oeB XwbiqYzShMoiE5G4SsKrsyF0OGSGPz5XriPpqaDpgOi1PStkF3+X6CVfgvGfw5NIwXye goga3wsbtWfBRSARx6le/5a6CS5SkIm8eZ5kH3qKdBjvlY5eM7lU/efakwiekpT1QSC9 YUpeZbykJBSG2PV9mqiz+83IbugtP1ScgHcH28kFJ0Od1BDUVNnACZ1W9E5Vvw9PmzlD 55Ig== 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; bh=C1We4UvL4QPwmGDLrWjVNOB5JOzUc+sQhEdjrrL1tto=; b=tIRBu1FuaaVwDrhyf+3Cs2pJpssFmP5MB/f5gpbjShSwX93NCmQ5JjO5J0QKLXGSyG VSuHuDbLxhv1Vd9zuudMp9Wy3K4Z/QNhN9id4hvY/gVz+UDNGK86vRnhIeIcMXyuOVDt AuIBZ6Kbt2td2BcyyZdaQXv4loWAHQho3Nl+QMQAliz4gN1i37idHwRxTF/CtPAOvbro dZDAMXE31QkB8EBzj0Ii7bko3gju8HZCPGjmPVpnwYiwbEH4O2fGm0iaL/ezLM03OuWZ RBv+dr9aW6CFPtDmPl45q8fcyRHI5RqMrJI6hbTz+nNTwg9enLUS4f/oEkMRFMTDYrli JUUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a638f07000000b003816043f143si15532605pgd.824.2022.03.22.00.59.22; Tue, 22 Mar 2022 00:59:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiCVH5d (ORCPT + 99 others); Tue, 22 Mar 2022 03:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiCVH5c (ORCPT ); Tue, 22 Mar 2022 03:57:32 -0400 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011CB5A08E for ; Tue, 22 Mar 2022 00:56:02 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id bn33so22872157ljb.6 for ; Tue, 22 Mar 2022 00:56:01 -0700 (PDT) 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=C1We4UvL4QPwmGDLrWjVNOB5JOzUc+sQhEdjrrL1tto=; b=UduC406sTPHRqfV+CfJWRn3/a+wVqk5rlx4kAQa2Ecy8XAeQ/2DqUvMv3sMbv63TFL Yf+CItIJXSurRpFqB3zrarqe4/E09frMVkcn7h2dWxeYUlKZGBEBiABEpth0J7FQvIv9 HQooIUEY9HXBy3amRjeTxU8H/LrTrCYiyuCrlywFIFP6w9OMKzahY3+xXzRLwqCbFi9O 8pPAtMoaLObKF19Iy4E7kT57WjqK4jDOZFNgSjo/L2QNy48HTX24H2fHkKmtrWruql74 qDAL8/EoC8MBMixaUp6C7FKTIfRhTpHcI06U51irjG22soaptSlaIYPIDWfZEZwHZ1Ng N+Jw== X-Gm-Message-State: AOAM5314Bh8aCz7APEavGUtvjtUHoxDGRFf2/NL/KncbXiDPfrtO/v+G /5Q/dwo0tkHD2VfYe0iLbzjPfjZ/uWc83Zd0iwx6J6wO8uk= X-Received: by 2002:a2e:8496:0:b0:249:7dbc:d81b with SMTP id b22-20020a2e8496000000b002497dbcd81bmr9221240ljh.332.1647935760248; Tue, 22 Mar 2022 00:56:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Adam Pigg Date: Tue, 22 Mar 2022 07:55:48 +0000 Message-ID: Subject: Re: GATT issue, possible bluez bug? To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,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 Luiz On Tue, 22 Mar 2022 at 00:44, 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. > > Im using 5.63 already, which is the latest tag (on opensuse tumbleweed) I'll also try bluetoothctl and attach logs using that, though I suspect it will behave the same as the python library and my own library. > -- > Luiz Augusto von Dentz