WordCloud

BestOfTFM (41287) IFTTT (41287)

Thursday, June 26, 2014

[Korben] Transformer un Raspberry Pi en récepteur audio Bluetooth

Si vous avez un vieil autoradio dans votre voiture ou une vieille chaine Hifi disposant d'une entrée auxiliaire, 2 solutions s'offrent à vous pour pouvoir y balancer de la musique en Bluetooth via votre téléphone ou votre ordinateur.


La première est très simple et s'adresse aux paresseux : Acheter un transmetteur Bluetooth comme celui-ci ou celui-là.


La seconde est beaucoup plus cool puisqu'elle permet tout simplement d'utiliser un Raspberry Pi pour en faire un récepteur audio Bluetooth.


Voici les explications de Parkerireed qui partage son montage avec les gens de l'Internet




I had always wanted to do something like this but never quite connected all the pieces. You need pulseaudio and bluez from your favorite package manager.


I did this in Arch linux but at least udev and maybe the bluetooth up service file should apply to more distros.


First, I created /etc/udev/rules.d/10-local.rules with the contents


# Set Bluetooth power up

ACTION=="add", KERNEL=="hci0", RUN+="/usr/bin/hciconfig hci0 up"


Second, I created a systemd target file for bringing the hci0 interface up right after the bluetooth daemon starts. The file is /lib/systemd/system/bluepower.target and contains


[Unit]

Description=Bluetooth power keeper

Requires=sys-subsystem-bluetooth-devices-%i.device bluetooth.service

PartOf=sys-subsystem-bluetooth-devices-%i.device

After=bluetooth.service sys-subsystem-bluetooth-devices-%i.device suspend.target

Conflicts=shutdown.target systemd-sleep.service


[Service]

Type=oneshot

RemainAfterExit=yes

ExecStart=/usr/bin/dbus-send --system --type=method_call --dest=org.bluez /org/bluez/%I org.freedesktop.DBus.Properties.Set string:org.bluez.Adapter1 string:Powered variant:boolean:true

ExecStop=/usr/bin/dbus-send --system --type=method_call --dest=org.bluez /org/bluez/%I org.freedesktop.DBus.Properties.Set string:org.bluez.Adapter1 string:Powered variant:boolean:false


[Install]

WantedBy=bluetooth.target


Then I ran


sudo systemctl enable bluepower.target


Next, I enabled auto login to my user on the first tty1 by editing the file


/etc/systemd/system/getty@tty1.service.d/autologin.conf


(You might have to create the getty@tty1.service.d folder) with the contents


[Service]

ExecStart=

ExecStart=-/usr/bin/agetty --autologin username --noclear %I 38400 linux


Then at the end of my ~/.bashrc I added


pulseaudio -D


Finally comes the first time connect. Run


bluetoothctl (This is bluez5. If you are using an older bluez refer to the documentation to connect to your phone/audio device)

power on

agent on

scan on


Put device is discovery mode. It will show the device in the output.


pair macaddress


Follow pairing instructions.


trust macaddress

connect macaddress


If all goes well you should have audio being played from the phone/media player to the Raspberry Pi and everything auto launching at boot.


Sources:


[1] http://ift.tt/1pttXWc


[2] http://ift.tt/1fpN76x



Amusez-vous bien !


Source


Cet article merveilleux et sans aucun égal intitulé : Transformer un Raspberry Pi en récepteur audio Bluetooth ; a été publié sur Korben, le seul site qui t'aime plus fort que tes parents.





by via MyTFMRSS

No comments:

Post a Comment