Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp1263913qtg; Thu, 30 Mar 2023 11:33:41 -0700 (PDT) X-Google-Smtp-Source: AKy350bI58YlMZlo90tpaE14DVJw5v2Wy4C7sf5AimTcliFK/jCktghw6f//JIVeg7gkq45mQaiS X-Received: by 2002:a17:906:31cb:b0:92c:a80e:225f with SMTP id f11-20020a17090631cb00b0092ca80e225fmr27714522ejf.52.1680201220844; Thu, 30 Mar 2023 11:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680201220; cv=none; d=google.com; s=arc-20160816; b=C/YGmMCKXJp1W7T9Umy/6ja4f3Myx2Qgh5I/TMRKpEZxlYSC8R0SxDPB0+RhzqlCr2 rs5jmWiMqSGJ+wOA7P76EwPwXCy9l5V2W7v5n7t+Mx+t+HKYAsZh65AeRIxBv2SEi9aR CpyYyNN/ltBtnjT8DQR3e0zmKZshWgh28yyXUHvhFXxlIvtW7xgZt1pE++bF62gDHnsY x68tlLwDnuJBBSOn+/MpdoOFqOdKwHuXcM9g2PE2k1kwGVFA/WcAvIjpBXeHL6F7kGx6 YPTGIlpTqPN6yN22oOWC/NFool21s7OklPijNK2u+IShXTfuwo48mt0yDtfM1D8OhirO xZ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:references:cc:to:from:content-language:subject :mime-version:date:message-id:dkim-signature; bh=KpjQgMlCxvz1aRknvywc/KB47S0KCt76gMfJAksNes4=; b=WVREhLbsWkH1Vf5mIW589jXHItMLr2a5w4zdjz29i4xsOcdc24RRkKma6sV7qDVkOj 92bfX/d2aeZOgRwY523xmohI4ysq9qSFAKnnANh4MqglnPFc/aWLWE5hqLCNAqTlOh2l LBTvzFdlXzr8CgWb68O/u3v/z4D5+Y2YAXe5cw1BTXu7/6z1gW+DIs8khnkQ+VKTF4Bt 870B5fdhe3Zjttl/CM/WEYeYnZF5+U+nr11EwA+rveYR6QwQAX79A/R+5yPLB1/KNdYS CPHYFrz7ocG59of/hA+Xv5ehlbqAIbajZdqeh02quYKDb9N/thLaZS2qfn93REJS/bZ7 SiTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tavla.de header.s=MBO0001 header.b=vvhkOKmK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tavla.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056402114d00b004fb4859cd4csi289151edw.562.2023.03.30.11.32.50; Thu, 30 Mar 2023 11:33:40 -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; dkim=pass header.i=@tavla.de header.s=MBO0001 header.b=vvhkOKmK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tavla.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbjC3SZk (ORCPT + 99 others); Thu, 30 Mar 2023 14:25:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230427AbjC3SZh (ORCPT ); Thu, 30 Mar 2023 14:25:37 -0400 X-Greylist: delayed 567 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 30 Mar 2023 11:25:35 PDT Received: from mout-b-105.mailbox.org (mout-b-105.mailbox.org [IPv6:2001:67c:2050:102:465::105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC798D517 for ; Thu, 30 Mar 2023 11:25:35 -0700 (PDT) Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-105.mailbox.org (Postfix) with ESMTPS id 4PnWnZ5KVjz9tkR; Thu, 30 Mar 2023 20:16:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tavla.de; s=MBO0001; t=1680200162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KpjQgMlCxvz1aRknvywc/KB47S0KCt76gMfJAksNes4=; b=vvhkOKmKKZIxsCw6x7pCPSdTBXhpHYmRy1X96FQ2FpNfAMa/rVPjGeGimzbgPGSu3L45af e5aGHjw/5dCQNJmy955790R7hY+TTwh1/4quXY2PS1KZH4Sb2j1EkEC/BH9317tVOLbyVP ppCvmAuupDDJAWCNBU3iH+dqoUa9pgZlq2rrBtyOcg1ZdJbu0QX8tNLBmui8qbQhmM9eGW Mw99eQejOSfKv7zAipaVdJHkNMZEZUkx2mWLyDdk1GxzEuxGfBhgaZkmVU0MWl3Ll0mIN9 /VvXWZePxKLrHqJ7Q25QlhphZucpUvCl0BI7lPqB8FnvjtTtvWD2OusUKY4OKw== Message-ID: <96ab0304-09e0-7bd9-944c-09ab03a21b67@tavla.de> Date: Thu, 30 Mar 2023 20:16:01 +0200 MIME-Version: 1.0 Subject: Re: How to Automatically Re-Connect Bluetooth HID over GATT (HOG) Device when BlueZ Plugin "hog" is Disabled Content-Language: en-GB From: Martin Petzold To: Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org References: <6950dd49-7436-ebef-eb88-940597472ce1@tavla.de> <56921851-be55-1380-2185-111335edaeb0@tavla.de> Organization: TAVLA Technology GmbH In-Reply-To: <56921851-be55-1380-2185-111335edaeb0@tavla.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Dear Luiz, I now have another issue with remote control HID integration (non-system; direct implementation). I am using Java with d-bus BlueZ 5.55 on Debian Linux. I have "hid" and "input" plugin disabled on bluetooth startup. I have one remote integrated and working. With this one after boot and while application startup I iterate over all paired devices with existing HID service (check for existing service UUID) and then iterate all Report characteristics and enabling notifying for all of them (if supported). Everything is running well with this (legacy) remote. After pairing it also auto-connects using my own registered object manager, as suggested by you. Now we received our final custom remote control from our manufacturer (other chip) and this approach does not work any more. I have tried a lot of things now. Once the remote control is paired (which is also somehow still buggy) and I rebooted the system with our application, the device is found in the list as paired, BUT I cannot access the HID service any more. Therefore, I cannot enable notifying for this remote. What I realized is, that this remote control seems to have something like MAC address randomization enabled (probably for security reasons). It also does not propagate device information unless I start pairing mode. Because of MAC address randomization it also seems that pairing is buggy - only works sometimes with some special procedure. I know this remote works, because if I connected in manually via bluetoothctl sometimes I works with enabling of notifying. Also directly after pairing it seemed to work. Have you seen something like this before? What should I do? Thanks, Martin Am 09.02.23 um 10:18 schrieb Martin Petzold: > Hi Luiz, > > Am 01.02.23 um 22:37 schrieb Luiz Augusto von Dentz: >> Hi Martin, >> >> On Wed, Feb 1, 2023 at 1:25 PM Martin Petzold >> wrote: >>> Hi, >>> >>> Linux 5.10, BlueZ 5.55 >>> >>> I have a remote control which implements Bluetooth LE. If I use the >>> default Bluetooth daemon, I am able to pair and trust using >>> bluetoothctl. If the connection is lost after a while (or days) and a >>> button on the remote control is pressed, the daemon re-connects >>> automatically (because the device is paired). This is basically what >>> I need. >>> >>> But, I would also like to manually set notifying for characteristics >>> (Report) on the HID service within my application (Java via d-bus). >>> This >>> is not possible anymore (also not via bluetoothctl) because the "hog" >>> (or "input") plugin manages the input device and the related HID >>> services are now hidden. >>> >>> I then added "--noplugin=input,hog" to my Bluetooth daemon. Which is >>> okay, because I don't need this support for Kernel HID. Great, now the >>> HID services are available (also using bluetoothctl), but the >>> peripheral >>> does not re-connect automatically any more. I always have to connect >>> manually first. I also have no signal on the d-bus when I press the >>> button of the remote control, when it is disconnected. >>> >>> How can I enable automatic re-connect for devices, when these plugins >>> are disabled? >>> >>> The only other way I was thinking of is to leave the "hog" plugin >>> enabled and use the operating system HID interface. However, my >>> application runs as non-root which makes it complicated and also I >>> would >>> like to have direct connection and control to my device. >> https://github.com/bluez/bluez/blob/master/doc/gatt-api.txt#L390 >> > Thanks, I have implemented and registered the HID profile using > org.bluez.GattProfile1 and now the device (remote control) re-connects > automatically. > > However, when I enable notifying on the Report characteristics of the > HID service after I received the first device properties update (with > services resolved), I miss the first Report event. If I press a > button, the remote re-connects and dbus events for device properties > updated are fine, but I don't have a Report event. If I then press > again, I do get a Report event, because I set notifying on the Report > characteristics. Setting notify seems to be too late. > > What is the trick to get also the first button pressed as a Report > characteristic event? > > At the moment I only have the HID service > (00001812-0000-1000-8000-00805f9b34fb) in the properties map of the > org.bluez.GattProfile1. > > Thanks, > > Martin >