Git Product home page Git Product logo

xcarlink's Introduction

XCarlink

Music server in a car

  1. Install Raspberry Pi OS Lite
  2. Config
  3. Test a MP3 sound sample
  4. OwnTone
  5. OwnTone and Pulseaudio
  6. Setting up a Raspberry Pi as a routed wireless access point
  7. AirPlay audio player
  8. Shutdown via web
  9. Debug

Install Raspberry Pi OS Lite


Config

Custom aliases

(host) scp ./home/pi/.bash_aliases [email protected]:~/.bash_aliases

Updating and upgrading Raspberry Pi OS

sudo apt update
sudo apt full-upgrade
sudo apt install vim

raspi-config

  • sudo raspi-config
  1. System Options
    • S2 Audio: 3.5mm jack
    • S3 Password: ChangeMe
    • S4 Hostname: xcarlink
  2. Localisation Options
    • L2 Timezone: Europe/Paris
    • L4 WLAN Country: FR
  3. Advanced Options
    • A1 Expand Filesystem
  4. Update
    • sudo apt autoremove
sudo reboot

Test a MP3 sound sample

  1. Install package to read mp3
sudo apt update && sudo apt install mpg123
  1. Copy sound sample
mkdir -p ~/music
(host) scp ./srv/music/*.mp3 [email protected]:~/music
sudo mv ~/music /srv/music
sudo chown -R root:root /srv/music
  1. Test sound
mpg123 /srv/music/sample.mp3

OwnTone

How to install

  1. Add repository key
wget -q -O - http://www.gyfgafguf.dk/raspbian/owntone.gpg | sudo apt-key add -
  1. Add this line to /etc/apt/sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.org
echo "deb http://www.gyfgafguf.dk/raspbian/owntone/ buster contrib" | sudo tee -a /etc/apt/sources.list
  1. Run
sudo apt update && sudo apt install owntone

Getting started

  1. Edit the configuration file to suit your needs
sudo cp /etc/owntone.conf /etc/owntone.conf.org
sudo vim /etc/owntone.conf
L32         admin_password = ""
L76         name = "My Music on XCarlink"
L227        nickname = "XCarlink"
L230        type = "pulseaudio"
L235        server = "localhost"
  1. Start or restart the server
sudo service owntone restart
sudo service owntone status
  1. Wait for the library scan to complete. You can follow the progress with
tail -f /var/log/owntone.log

If you are going to use a remote app, pair it by going to http://owntone.local:3689 and find the settings

OwnTone and Pulseaudio

System Mode with Bluetooth support

Setting up Pulseaudio

  1. Install packages
sudo apt update && sudo apt install pulseaudio pulseaudio-module-bluetooth ofono
  1. Remove client execution
sudo cp /etc/pulse/client.conf /etc/pulse/client.conf.org
sudo vim /etc/pulse/client.conf
L25 autospawn = no
mkdir -p $HOME/.config/pulse
cp /etc/pulse/client.conf $HOME/.config/pulse/client.conf
  1. Start Pulseaudio on boot
sudo vim /etc/systemd/system/pulseaudio.service
Copy/Paste ./etc/systemd/system/pulseaudio.service
  1. Bluetooth support, add lines
sudo cp /etc/pulse/system.pa /etc/pulse/system.pa.org
sudo vim  /etc/pulse/system.pa
#### Enable Bluetooth
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover autodetect_mtu=yes
.endif
  1. Make Pulseaudio communicates with the Bluetooth daemon through D-Bus
sudo adduser pulse audio
sudo adduser pulse bluetooth
  1. Edit and change the policy for <policy context="default"> from deny to allow
sudo cp /etc/dbus-1/system.d/bluetooth.conf /etc/dbus-1/system.d/bluetooth.conf.org
sudo vim /etc/dbus-1/system.d/bluetooth.conf
L40 <allow send_destination="org.bluez"/>
Add lines:
  <policy context="default">
    <allow send_destination="org.ofono"/>
  </policy>
  1. Restart the bus
sudo service dbus restart
sudo service dbus status
  1. Enable system mode on boot
sudo systemctl --user stop pulseaudio.service pulseaudio.socket
sudo systemctl --global disable pulseaudio.service pulseaudio.socket
sudo systemctl enable bluetooth
sudo systemctl enable ofono
sudo systemctl enable pulseaudio
sudo reboot
  1. Check that the Bluetooth module is loaded
pactl list modules short | grep -i bluetooth

Setting up the server

  1. Add the user the server is running
sudo adduser root pulse-access
sudo adduser pulse pulse-access
  1. Restart and check the logs
sudo service pulseaudio restart
sudo service pulseaudio status
journalctl -u pulseaudio.service

Adding a Bluetooth device

To connect with the device, run bluetoothctl and then:

power on
agent on
scan on
**Note MAC address of BT Speaker**
pair [MAC address]
**Type Pin if prompted**
trust [MAC address]
connect [MAC address]

Now the speaker should appear. You can also verify that Pulseaudio has detected the speaker with

pactl list sinks short

  1. Install the access point and network management software
sudo apt update && sudo apt install hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo apt update && sudo apt install dnsmasq
sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent
  1. Set up the network router
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.org
sudo vim /etc/dhcpcd.conf
Add lines:
interface wlan0
    static ip_address=10.0.0.1/8
    nohook wpa_supplicant
  1. Enable routing and IP masquerading (Skipped)
  2. Configure the DHCP and DNS services for the wireless network
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.org
sudo vim /etc/dnsmasq.conf
Copy/Paste ./etc/dnsmasq.conf
  1. Test configuration file
dnsmasq --test -C /etc/dnsmasq.conf
  1. Restart service
sudo service dnsmasq restart
sudo service dnsmasq status
  1. Ensure wireless operation
sudo rfkill unblock wlan
  1. Configure the access point software
sudo vim /etc/hostapd/hostapd.conf
Copy/Paste ./etc/hostapd/hostapd.conf
  1. Run your new wireless access point
sudo service hostapd restart
sudo service hostapd status

Debug mode

sudo systemctl stop hostapd
sudo hostapd -dd /etc/hostapd/hostapd.conf

AirPlay audio player

  1. Configure and Update
sudo apt update && sudo apt upgrade
  1. Turn Off WiFi Power Management
sudo iwconfig wlan0 power off
  1. Remove Old Copies
which shairport-sync
sudo rm /usr/local/bin/shairport-sync
sudo rm /etc/systemd/system/shairport-sync.service
sudo rm /lib/systemd/system/shairport-sync.service
sudo rm /etc/init.d/shairport-sync
sudo rm /etc/dbus-1/system.d/shairport-sync-dbus.conf
sudo rm /etc/dbus-1/system.d/shairport-sync-mpris.conf
  1. Reboot after Cleaning Up
sudo reboot
  1. Build and Install
sudo apt install --no-install-recommends build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
cd && mkdir -p src && cd src
git clone https://github.com/mikebrady/shairport-sync.git && cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-systemd
make
sudo make install
  1. Configure
sudo vim /etc/shairport-sync.conf
// Sample Configuration File for Shairport Sync on a Raspberry Pi using the built-in audio DAC
general =
{
  volume_range_db = 60;
};

alsa =
{
  output_device = "hw:0";
  mixer_control_name = "PCM";
};
  1. Start Shairport Sync on boot
sudo service shairport-sync enable
sudo service shairport-sync start
sudo service shairport-sync status

  1. Install packages
sudo apt update && sudo apt install lighttpd php-cgi
sudo lighty-enable-mod fastcgi fastcgi-php
sudo service lighttpd force-reload
  1. Edit the sudoers file
sudo visudo
# Add the following line below "pi ALL etc." and exit the visudo editor:
www-data ALL = NOPASSWD: /sbin/shutdown
(^s, ^x)
  1. Create index.html
sudo vim /var/www/html/index.html
# Absolute minimum contents of the index.html file:
<html><a href="shutdown.php">Shutdown XCarlink NOW</a></html>
  1. Create php function to shutdown
sudo vim /var/www/html/shutdown.php
# Absolute minimum contents of the shutdown.php file:
<?php system('sudo /sbin/shutdown -h now'); ?>
  1. Test
(host) curl xcarlink.local/shutdown.php

Debug

  1. Services
sudo service owntone status
sudo service pulseaudio status
sudo service shairport-sync status
sudo service dbus status
sudo service dnsmasq status
sudo service hostapd status
  1. Logs
tail -f /var/log/owntone.log
journalctl -u pulseaudio.service
  1. Check that no pulseaudio in user mode is running
sudo ps -aux | grep pulse
  1. Pulseaudio in debug mode
sudo service pulseaudio stop
sudo pulseaudio -vvvv
sudo service pulseaudio restart

๐Ÿ”™ ๐Ÿ”

xcarlink's People

Contributors

starli0n avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.