Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1324823pxb; Thu, 4 Mar 2021 08:31:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2gQwM6cJNHnjqNFzuene/+oQL3RqsNdbhfmgLyB0OjZ6McyFUbVg6yFhA8H2PYVm+U5j/ X-Received: by 2002:a17:906:a51:: with SMTP id x17mr5245959ejf.25.1614875516623; Thu, 04 Mar 2021 08:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614875516; cv=none; d=google.com; s=arc-20160816; b=kKvo+NZoo7GnM7gGOKqR27ElTqNL0hag6VGlDJFEsIhu+DTXmFPy0sradoYSlXhBiw pv3f0HD0QiWGBO2UJxNxfDlNNY1YpDmkj/kT/TyaAGrvUl3+gxDASjKqAl5mxIY1xlyL 9o0edgrexif2BKJ61VhxY1KRuzYeO+0VMVSIMGs9kCzREUz/+gqSR7sazB001BhYcNwn B9OzSRcTLVaWY0t6SLu5G6oTVObnbM98wVnAIT9akdwaJ1C3TFajOwmzlKL6BGK2XAlk PU8iej0TtqFrHgfNxJQrwZjFXdx8yiGqNh8eCf9BfGM4ol2QzCDDPT6/5NdGF2eQwS+1 5aJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:to:from:subject:message-id; bh=3QI1xA3668OXAdxoMOp3CUd/Tq6WsGwZVDijbGNM07g=; b=M87Ax7G5EdLMVZO+U4xItE77qzbS5UKg+OnKT5Blx1vo4PVoxVKcrodyX59hx8Q24K L6SFypTxT2hO7V8FT8TagICzOziiF9a8s6c36IibgI94/5krQ/GjD29eX0uNbUkau6pk 3wSz9Fg6jnxHzZvTiVNLhf25e/P+ss/nrPgsOQMbowGVypU33LrnZoJEhg7N00+7nL6x LvR88SzGMi+1UTIwpVru6z7Fg2syi03SeeSkPDhykHQZQ34C09r4fT7oJfyINCvnKGQT rXOoWl4fPO5UxwAz1lqldpnkK73mE4eg8L3eM16NHsOa3FdCLyfxMJRpd5Yn7dy99Q2Y RPOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 38si5208572edr.200.2021.03.04.08.31.21; Thu, 04 Mar 2021 08:31:56 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239113AbhCDK5D (ORCPT + 99 others); Thu, 4 Mar 2021 05:57:03 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:39571 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239108AbhCDK4d (ORCPT ); Thu, 4 Mar 2021 05:56:33 -0500 X-Originating-IP: 78.199.60.242 Received: from [192.168.1.150] (unknown [78.199.60.242]) (Authenticated sender: hadess@hadess.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 22E1260003; Thu, 4 Mar 2021 10:55:40 +0000 (UTC) Message-ID: <0f80d7ef92366fde06f3b24fe060066e01933980.camel@hadess.net> Subject: Re: Autopairing From: Bastien Nocera To: Mihai Emilian , linux-bluetooth@vger.kernel.org Date: Thu, 04 Mar 2021 11:55:40 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Tue, 2021-03-02 at 18:07 +0100, Mihai Emilian wrote: > Dear bluetooth community, > > I am trying to create a pairing agent using bluez API in C. > > The problem that I am trying to solve is autopairing from a known list > of MAC addresses (i.e auto-accept pairing for known devices in the > list). > > I tried registering a bluetooth agent with NoInputNoOutput capability. > However, when I try to access Pair, I receive Authentication Failed > error. > > Another problem here is that even if I call RequestDefaultAgent after > registration, it seems that the bluetooth settings agent (UI) is still > called and prompts me to yes/no. > > I have the following questions: > > From the api doc: > "Special permission might be required to become the default agent" > > - Is there anything else I have to do to acquire these permissions? > - The return value from RequestDefaultAgent and RegisterAgent is void. > How can I check whether my agent has been registered/became default? > - I also tried trusting the discovered device after registering the > agent and trying to make it default, which didn't make any difference > - is this required? You might want to look at ready made pairing tools, such as bt-agent in bluez-tools: https://github.com/khvzak/bluez-tools This is an example of using static pincode with unattended pairing: https://github.com/hadess/CHIP-bluetooth-speaker/blob/master/setup.sh#L73 The bt-agent pin code file can accommodate using bluetooth addresses, so something like: AA:BB:CC:DD:EE:FF * in the pin code file should work. Cheers > > Here's my source code: > https://pastebin.com/Wj3rdHy3 > > Thank you for your time. > > Best regards, > Mihai