From nobody Mon Jun 27 18:51:07 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5C1C8867188; Mon, 27 Jun 2022 18:56:44 +0000 (UTC) (envelope-from kempe@lysator.liu.se) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4LWxlv35B4z3P7t; Mon, 27 Jun 2022 18:56:43 +0000 (UTC) (envelope-from kempe@lysator.liu.se) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 7C3691EAC5; Mon, 27 Jun 2022 20:51:08 +0200 (CEST) Received: from shipon.lysator.liu.se (unknown [IPv6:2001:6b0:17:f0a0::83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 796171E9E3; Mon, 27 Jun 2022 20:51:08 +0200 (CEST) Date: Mon, 27 Jun 2022 20:51:07 +0200 From: Andreas Kempe To: freebsd-bluetooth@freebsd.org Cc: freebsd-hackers@freebsd.org Subject: blued: bluetooth daemon - looking for testers Message-ID: Reply-To: freebsd-bluetooth@freebsd.org List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: ClamAV using ClamSMTP X-Rspamd-Queue-Id: 4LWxlv35B4z3P7t X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=pass (policy=none) header.from=lysator.liu.se; spf=pass (mx1.freebsd.org: domain of kempe@lysator.liu.se designates 130.236.254.3 as permitted sender) smtp.mailfrom=kempe@lysator.liu.se X-Spamd-Result: default: False [3.00 / 15.00]; HAS_REPLYTO(0.00)[freebsd-bluetooth@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.lysator.liu.se]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_SPAM_SHORT(0.99)[0.994]; RCVD_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[130.236.254.3:from]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[lysator.liu.se,none]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; MLMMJ_DEST(0.00)[freebsd-bluetooth,freebsd-hackers]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:2843, ipnet:130.236.0.0/16, country:SE]; REPLYTO_EQ_TO_ADDR(5.00)[]; GREYLIST(0.00)[pass,body] X-ThisMailContainsUnwantedMimeParts: N Hello everyone, After having issues with my bluetooth mouse, I figured out that the problem was a lack of support for secure simple pairing and I reported on this a while back to freebsd-bluetooth and freebsd-hackers. This sent me down the rabbit hole of working on my own bluetooth daemon with the goal of providing a user friendly way of pairing and using bluetooth devices. At long last, I think I have something worth sharing! blued - what is it ================== blued is made up of three parts: a library, a daemon and a command line client. In its current state, it should allow you to pair a bluetooth mouse and, most likely, keyboard, but I have no keyboard to test with. With the current version of blued, bthidd is still needed for the mouse to work and a script is provided to automatically pair a mouse and configure bthidd appropriately. In the future, my aim is to either make blued work with bthidd directly or integrate its code into blued. This for a more seamless experience. If the supplied script works as expected, your mouse will get connected, paired and simply start working. If the mouse is turned off and on again, the daemon should let it reconnect without user intervention. What is needed to use blued v0.1? ================================= First you need to make sure you have working bluetooth drivers loaded, reading the bluetooth chapter of the FreeBSD handbook is recommended for this [0]. To test blued, you will need to compile the release found at the link below [1], and you will also have to patch your FreeBSD kernel with the patches in the kernel_patches directory of the release. The kernel patches are pretty small and you will only need to recompile the hci module. Instruction on how to build blued and apply the patches are provided in the README file. blued has primarily been tested on FreeBSD 12.3, but my patches applied cleanly on 13.1 when I tested. I am not supplying a port at the moment, but "make install" works and will install all needed files. The daemon binary is called blued, while the command line utility is called bluecontrol. Man pages for blued and bluecontrol should also have been installed. An example configuration file for blued is installed in /usr/local/share/examples/blued/blued.conf.example and can be copied to /usr/local/etc/blued.conf which is the default path blued checks for its configuration. blued outputs diagnostic data to syslog and on a default FreeBSD system, it can be found in /var/log/{debug.log,messages}. To start blued in the background after installing it, execute "blued &" as root. blued and bluecontrol both use capsicum and blued can be configured to drop its root privileges. Feedback! ========= I have only tried this software with my own mouse and realise that a sample size of one single bluetooth device is pretty small. I'm expecting issues and am greatly looking forward to feedback from others! In case of trouble, output from /var/log/debug.log and /var/log/messages as well as a traffic dump from "hcidump -x" while trying to pair will help with troubleshooting. If you want to get involved with the code and submit patches, you're welcome to do so and can find the code on Lysator's Git [2]! Thank you for you attention! Cordially, Andreas Kempe [0]: https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bluetooth [1]: https://git.lysator.liu.se/kempe/blued/-/releases/v0.1 [2]: https://git.lysator.liu.se/kempe/blued