From f798a00cb7576f34a6f12db1d5c417d73b9f18f6 Mon Sep 17 00:00:00 2001 From: Peter Steenbergen Date: Sat, 11 Jan 2020 19:16:36 +0100 Subject: [PATCH] MycroftOS: Add Bluetooth Speaker functionality. --- buildroot-external/Config.in | 1 + buildroot-external/configs/rpi3_defconfig | 8 +++++- .../package/btspeaker/Config.in | 6 +++++ .../package/btspeaker/btspeaker.mk | 24 ++++++++++++++++++ .../package/btspeaker/btspeaker.service | 13 ++++++++++ .../package/btspeaker/main.conf | 4 +++ buildroot-external/package/btspeaker/pin.conf | 1 + buildroot-external/user_table.txt | 2 +- ...o-the-lp-group-for-bluetooth-to-work.patch | 25 +++++++++++++++++++ 9 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 buildroot-external/package/btspeaker/Config.in create mode 100644 buildroot-external/package/btspeaker/btspeaker.mk create mode 100644 buildroot-external/package/btspeaker/btspeaker.service create mode 100644 buildroot-external/package/btspeaker/main.conf create mode 100644 buildroot-external/package/btspeaker/pin.conf create mode 100644 buildroot-patches/0032-Add-pulse-to-the-lp-group-for-bluetooth-to-work.patch diff --git a/buildroot-external/Config.in b/buildroot-external/Config.in index ad8f2a0c..acce075c 100644 --- a/buildroot-external/Config.in +++ b/buildroot-external/Config.in @@ -7,6 +7,7 @@ menu "Mycroft A.I. Personal Assistant" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/wifi-ap/Config.in" menu "Additional drivers, libraries and/or applications" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/alsa-plugins/Config.in" + source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/btspeaker/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/fann/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/respeaker/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/spotifyd/Config.in" diff --git a/buildroot-external/configs/rpi3_defconfig b/buildroot-external/configs/rpi3_defconfig index d8d76793..26df7c2e 100644 --- a/buildroot-external/configs/rpi3_defconfig +++ b/buildroot-external/configs/rpi3_defconfig @@ -54,7 +54,6 @@ BR2_PACKAGE_ALSA_UTILS_ASEQNET=y BR2_PACKAGE_ALSA_UTILS_BAT=y BR2_PACKAGE_ALSA_UTILS_IECSET=y BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y -BR2_PACKAGE_BLUEZ_ALSA=y BR2_PACKAGE_FAAD2=y BR2_PACKAGE_FFMPEG_GPL=y BR2_PACKAGE_FFMPEG_NONFREE=y @@ -205,6 +204,7 @@ BR2_PACKAGE_LIBSIDPLAY2=y BR2_PACKAGE_OPUSFILE=y BR2_PACKAGE_PORTAUDIO=y BR2_PACKAGE_PORTAUDIO_OSS=y +BR2_PACKAGE_SBC=y BR2_PACKAGE_SPEEXDSP=y BR2_PACKAGE_WEBRTC_AUDIO_PROCESSING=y BR2_PACKAGE_LIBARCHIVE=y @@ -253,6 +253,11 @@ BR2_PACKAGE_PCRE2_32=y BR2_PACKAGE_AVAHI=y BR2_PACKAGE_AVAHI_DAEMON=y BR2_PACKAGE_AVAHI_LIBDNSSD_COMPATIBILITY=y +BR2_PACKAGE_BLUEZ_TOOLS=y +BR2_PACKAGE_BLUEZ5_UTILS=y +BR2_PACKAGE_BLUEZ5_UTILS_OBEX=y +BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y +BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y BR2_PACKAGE_CRDA=y BR2_PACKAGE_DNSMASQ=y # BR2_PACKAGE_DNSMASQ_TFTP is not set @@ -314,6 +319,7 @@ BR2_PACKAGE_MYCROFT_SERVICE=y BR2_PACKAGE_MYCROFT_SPLASH=y BR2_PACKAGE_WIFI_AP=y BR2_PACKAGE_ALSA_PLUGINS=y +BR2_PACKAGE_BTSPEAKER=y BR2_PACKAGE_FANN=y BR2_PACKAGE_RESPEAKER=y BR2_PACKAGE_SPOTIFYD=y diff --git a/buildroot-external/package/btspeaker/Config.in b/buildroot-external/package/btspeaker/Config.in new file mode 100644 index 00000000..30e650a3 --- /dev/null +++ b/buildroot-external/package/btspeaker/Config.in @@ -0,0 +1,6 @@ +config BR2_PACKAGE_BTSPEAKER + bool "btspeaker" + help + Service to start a BT Speaker daemon. + + https://www.j1nx.nl diff --git a/buildroot-external/package/btspeaker/btspeaker.mk b/buildroot-external/package/btspeaker/btspeaker.mk new file mode 100644 index 00000000..ff22386d --- /dev/null +++ b/buildroot-external/package/btspeaker/btspeaker.mk @@ -0,0 +1,24 @@ +################################################################################ +# +# btspeaker +# +################################################################################ + +BTSPEAKER_VERSION = 0.1.0 +BTSPEAKER_SITE = $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/btspeaker +BTSPEAKER_SITE_METHOD = local +BTSPEAKER_LICENSE = Apache License 2.0 +BTSPEAKER_LICENSE_FILES = LICENSE + +define BTSPEAKER_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 644 $(@D)/btspeaker.service \ + $(TARGET_DIR)/usr/lib/systemd/system/btspeaker.service + + mkdir -p $(TARGET_DIR)/etc/bluetooth + $(INSTALL) -D -m 644 $(@D)/main.conf \ + $(TARGET_DIR)/etc/bluetooth/main.conf + $(INSTALL) -D -m 600 $(@D)/pin.conf \ + $(TARGET_DIR)/etc/bluetooth/pin.conf +endef + +$(eval $(generic-package)) diff --git a/buildroot-external/package/btspeaker/btspeaker.service b/buildroot-external/package/btspeaker/btspeaker.service new file mode 100644 index 00000000..708c9122 --- /dev/null +++ b/buildroot-external/package/btspeaker/btspeaker.service @@ -0,0 +1,13 @@ +[Unit] +Description=Bluetooth Auth Agent +After=bluetooth.service +PartOf=bluetooth.service + +[Service] +Type=simple +ExecStartPre=/usr/bin/bt-adapter -s Powered on +ExecStartPre=/usr/bin/bt-adapter -s Discoverable on +ExecStart=/usr/bin/bt-agent -c NoInputNoOutput -p /etc/bluetooth/pin.conf + +[Install] +WantedBy=bluetooth.target diff --git a/buildroot-external/package/btspeaker/main.conf b/buildroot-external/package/btspeaker/main.conf new file mode 100644 index 00000000..62f030b3 --- /dev/null +++ b/buildroot-external/package/btspeaker/main.conf @@ -0,0 +1,4 @@ +[General] +Name = MycroftOS +Class = 0x41C +DiscoverableTimeout = 0 diff --git a/buildroot-external/package/btspeaker/pin.conf b/buildroot-external/package/btspeaker/pin.conf new file mode 100644 index 00000000..0ca9ee76 --- /dev/null +++ b/buildroot-external/package/btspeaker/pin.conf @@ -0,0 +1 @@ +* 0000 diff --git a/buildroot-external/user_table.txt b/buildroot-external/user_table.txt index 2387b4ad..270a3b1a 100644 --- a/buildroot-external/user_table.txt +++ b/buildroot-external/user_table.txt @@ -1,2 +1,2 @@ -mycroft -1 mycroft -1 =mycroft /home/mycroft /bin/sh input,i2c,spi,gpio,audio,video,pulse,pulse-access Mycroft user +mycroft -1 mycroft -1 =mycroft /home/mycroft /bin/sh input,i2c,spi,gpio,audio,video,pulse,pulse-access,lp Mycroft user diff --git a/buildroot-patches/0032-Add-pulse-to-the-lp-group-for-bluetooth-to-work.patch b/buildroot-patches/0032-Add-pulse-to-the-lp-group-for-bluetooth-to-work.patch new file mode 100644 index 00000000..2c49fb90 --- /dev/null +++ b/buildroot-patches/0032-Add-pulse-to-the-lp-group-for-bluetooth-to-work.patch @@ -0,0 +1,25 @@ +From 7809fc94c259e997cd9010eef83854e78ad4f31a Mon Sep 17 00:00:00 2001 +From: Peter Steenbergen +Date: Sat, 11 Jan 2020 16:36:36 +0100 +Subject: [PATCH 1/1] Add pulse to the lp group for bluetooth to work. + +--- + package/pulseaudio/pulseaudio.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/package/pulseaudio/pulseaudio.mk b/package/pulseaudio/pulseaudio.mk +index c91af22935..0f7a9e3c21 100644 +--- a/package/pulseaudio/pulseaudio.mk ++++ b/package/pulseaudio/pulseaudio.mk +@@ -162,7 +162,7 @@ PULSEAUDIO_POST_INSTALL_TARGET_HOOKS += PULSEAUDIO_REMOVE_VALA \ + + ifeq ($(BR2_PACKAGE_PULSEAUDIO_DAEMON),y) + define PULSEAUDIO_USERS +- pulse -1 pulse -1 * /var/run/pulse - audio,pulse-access ++ pulse -1 pulse -1 * /var/run/pulse - audio,pulse-access,lp + endef + + define PULSEAUDIO_INSTALL_INIT_SYSV +-- +2.24.0.rc1 +