Subject: [bug#52470] [PATCH] services: bluetooth: Add missing config parameters

From: Demis Balbach <[email-masked]>
Date: Mon, 13 Dec 2021 20:36:32 +0100

Hello,

this patch adds all (as far as I know) missing config parameters to the
bluetooth-service.

I added all config parameters (that were missing) that are defined in
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf

If a default value was given, e.g.:

--8<---------------cut here---------------start------------->8---
# Specify the policy to the JUST-WORKS repairing initiated by peer
# Possible values: "never", "confirm", "always"
# Defaults to "never" <------------------------------------------
#JustWorksRepairing = never
--8<---------------cut here---------------end--------------->8---

I used that default value. However, there are other paramaters
(everthing under `[BR]' and almost everything under `[LE]') that don't
specify default values. They are always integers as one can see here:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/btd.h#n39

So I took a nonsensical value like `-1' and only printed the in question
with the user provided line if it did not equal -1.

This approach isn't pretty, but it worked for me, however please give
feedback regarding that.
My guile-fu is bad so I'm sure there's plenty room for improvement.

Here is the config I tested it with:

--8<---------------cut here---------------start------------->8---
(define-module (base-system)
  #:use-module (gnu)
  #:use-module (gnu services desktop)
  #:use-module (srfi srfi-1))

(define base-operating-system
  (operating-system

   ;; Machine settings
   (host-name "geekcave")
   (timezone "Europe/Berlin")
   (locale "en_US.utf8")
   (keyboard-layout (keyboard-layout "us" "altgr-intl"))

   ;; Services
   (services (append (list
                      (service bluetooth-service-type (bluetooth-configuration
                                                       (name "test")
                                                       (class "0x123")
                                                       (discoverable-timeout 60)
                                                       (always-pairable? #f)
                                                       (pairable-timeout 20)
                                                       (device-id "bluetooth:123")
                                                       (reverse-service-discovery? #f)
                                                       (name-resolving? #f)
                                                       (debug-keys? #t)
                                                       (controller-mode 'le)
                                                       (multi-profile 'multiple)
                                                       (fast-connectable? #t)
                                                       (privacy 'network/on)
                                                       (just-works-repairing 'confirm)
                                                       (temporary-timeout 10)
                                                       (refresh-discovery? #f)
                                                       (experimental 'd4992530-b9ec-469f-ab01-6c481c47da1c)
                                                       (remote-name-request-retry-delay 20)
                                                       (page-scan-type #xFFF)
                                                       (page-scan-interval #x0)
                                                       (page-scan-window #x1)
                                                       (inquiry-scan-type #xFFFF)
                                                       (inquiry-scan-interval #x123)
                                                       (inquiry-scan-window 23890)
                                                       (link-supervision-timeout 13)
                                                       (page-timeout 9)
                                                       (min-sniff-interval 0)
                                                       (max-sniff-interval 2)
                                                       (min-advertisement-interval 0)
                                                       (max-advertisement-interval 2)
                                                       (multi-advertisement-rotation-interval 3)
                                                       (scan-interval-auto-connect 0)
                                                       (scan-window-auto-connect 0)
                                                       (scan-interval-suspend 0)
                                                       (scan-window-suspend 0)
                                                       (scan-interval-discovery 0)
                                                       (scan-window-discovery 0)
                                                       (scan-interval-adv-monitor 0)
                                                       (scan-window-adv-monitor 0)
                                                       (scan-interval-connect 0)
                                                       (scan-window-connect 0)
                                                       (min-connection-interval 0)
                                                       (max-connection-interval 1)
                                                       (connection-latency 10)
                                                       (connection-supervision-timeout 34)
                                                       (autoconnect-timeout 4)
                                                       (adv-mon-allowlist-scan-duration 20)
                                                       (adv-mon-no-filter-scan-duration 30)
                                                       (enable-adv-mon-interleave-scan 0)
                                                       (cache 'yes)
                                                       (key-size 15)
                                                       (exchange-mtu 23)
                                                       (att-channels 1)
                                                       (session-mode 'ertm)
                                                       (stream-mode 'streaming)
                                                       (reconnect-uuids (list ""))
                                                       (reconnect-attempts 3)
                                                       (reconnect-intervals (list 2 4 49))
                                                       (auto-enable? #t)
                                                       (resume-delay 29)
                                                       (rssi-sampling-period "0x10"))))
                     %base-services))

   ;; Boot loader
   (bootloader (bootloader-configuration
                (bootloader grub-efi-bootloader)
                (target "/boot/efi")
                (timeout 3)))

   ;; File systems
   (file-systems (cons* (file-system ;; System partition
                         (device (file-system-label "GUIX"))
                         (mount-point "/")
                         (type "btrfs"))
                        (file-system ;; Boot partition
                         (device (file-system-label "BOOT"))
                         (mount-point "/boot/efi")
                         (type "vfat"))
                        %base-file-systems))))
base-operating-system
--8<---------------cut here---------------end--------------->8---

-- 
Best regards / Mit freundlichen Grüßen,
Demis Balbach