morrolinux / mpradio-py

Morrolinux's Pirate radio (PiFmAdv wrapper with Bluetooth and mp3 support) - Stream music to your car's FM radio or use it as a Bluetooth speaker via headphone jack
73 stars 11 forks source link

bluetooth app and audio passthrough to fm doesnt work #53

Closed GiannisDorokidis closed 4 years ago

GiannisDorokidis commented 4 years ago

Hello I am having issues with Bluetooth not passing the audio to the pi (zero w). I can connect to pi's Bluetooth but the app doesn't work. I'm tring to passthrough my phones audio but it doesn't work. The usb stick works perfectly and it is trasmitting music from the usb stick. Is there any way to fix this?

morrolinux commented 4 years ago

which debian/raspbian version are you running on? Another user recently reported issues with bluetooth playback under Debian 10 (Buster). This project was developed on Debian Debian 9 (Stretch) and I hadn't got time to test it under Buster yet, so that might simply be the reason. Could you try flashing raspbian 9 and install again?

GiannisDorokidis commented 4 years ago

I gloogled to find this pi@mpradio:~ $ lsb_release -a No LSB modules are available. Distributor ID:Raspbian Description:Raspbian GNU/Linux 10 (buster) Release:10 Codename:buster pi@mpradio:~ And then I did this Linux mpradio 4.19.93+ #1290 Fri Jan 10 16:34:37 GMT 2020 armv6l GNU/Linux

GiannisDorokidis commented 4 years ago

were can I find raspbian stretch? Can I download it from NOOBS?

P.S I New to this stuff

morrolinux commented 4 years ago

http://downloads.raspberrypi.org/raspbian/images/raspbian-2019-04-09/

GiannisDorokidis commented 4 years ago

I tried to run it on raspbian stretch but it has failed pi@mpradio:~ $ sudo systemctl status mpradio ● mpradio.service - Morrolinux Pirate Radio Loaded: loaded (/etc/systemd/system/mpradio.service; enabled; vendor pr Active: failed (Result: exit-code) since Wed 2020-01-29 22:07:06 GMT; 5 Process: 334 ExecStart=/bin/bash -l -c sudo -E chrt -f 99 /home/pi/mprad Main PID: 334 (code=exited, status=1/FAILURE)

● mpradio.service - Morrolinux Pirate Radio Loaded: loaded (/etc/systemd/system/mpradio.service; enabled; vendor pr Active: failed (Result: exit-code) since Wed 2020-01-29 22:07:06 GMT; 5 Process: 334 ExecStart=/bin/bash -l -c sudo -E chrt -f 99 /home/pi/mprad Main PID: 334 (code=exited, status=1/FAILURE) Jan 29 22:07:06 mpradio bash[334]: Traceback (most recent call last): Jan 29 22:07:06 mpradio bash[334]: File "/home/pi/mpradio.py", line 8, iJan 29 22:07:06 mpradio bash[334]: from bluetooth_remote import BtRemoJan 29 22:07:06 mpradio bash[334]: File "/home/pi/mpradio/src/bluetooth_Jan 29 22:07:06 mpradio bash[334]: import bluetooth Jan 29 22:07:06 mpradio bash[334]: ImportError: No module named 'bluetoothJan 29 22:07:06 mpradio sudo[334]: pam_unix(sudo:session): session closed Jan 29 22:07:06 mpradio systemd[1]: mpradio.service: Main process exited, Jan 29 22:07:06 mpradio systemd[1]: mpradio.service: Unit entered failed sJan 29 22:07:06 mpradio systemd[1]: mpradio.service: Failed with result 'e

morrolinux commented 4 years ago

looks like pybluez package didn't get installed... which is awkward because the installer script should take care of it. 1) Did you run }install.sh} with sudo following the README? 2) what happens if you type pip3 install pybluez?

GiannisDorokidis commented 4 years ago

pi@mpradio:~ $ ls Desktop Downloads mpradio mpradio.py Pictures Templates Documents MagPi mpradio-py Music Public Videos pi@mpradio:~ $ cd mpradio pi@mpradio:~/mpradio $ ls a2dp-sink.py doc mpradio-py-notes.txt rfcomm-client.py sounds classes.png install README.md songs src pi@mpradio:~/mpradio $ sudo nano README.md pi@mpradio:~/mpradio $ cd mpradio/install && sudo bash install.sh -bash: cd: mpradio/install: No such file or directory pi@mpradio:~/mpradio $ sudo bash install.sh bash: install.sh: No such file or directory pi@mpradio:~/mpradio $ cd mpradio.py -bash: cd: mpradio.py: No such file or directory pi@mpradio:~/mpradio $ pip3 install pybluez
Collecting pybluez Downloading https://files.pythonhosted.org/packages/08/9f/e9d93b266d2d1ea988780a52a696073ba0a65df65a532165fdf6ff90d0ed/PyBluez-0.23.tar.gz (97kB) 100% |████████████████████████████████| 102kB 301kB/s Building wheels for collected packages: pybluez Running setup.py bdist_wheel for pybluez ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-13fyw4pa/pybluez/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmpi0_lp0pppip-wheel- --python-tag cp35: running bdist_wheel running build running build_py creating build creating build/lib.linux-armv6l-3.5 creating build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/ble.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/widcomm.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/init.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/macos.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/btcommon.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/bluez.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/msbt.py -> build/lib.linux-armv6l-3.5/bluetooth Fixing build/lib.linux-armv6l-3.5/bluetooth/ble.py build/lib.linux-armv6l-3.5/bluetooth/widcomm.py build/lib.linux-armv6l-3.5/bluetooth/init.py build/lib.linux-armv6l-3.5/bluetooth/macos.py build/lib.linux-armv6l-3.5/bluetooth/btcommon.py build/lib.linux-armv6l-3.5/bluetooth/bluez.py build/lib.linux-armv6l-3.5/bluetooth/msbt.py Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: ws_comma Fixing build/lib.linux-armv6l-3.5/bluetooth/ble.py build/lib.linux-armv6l-3.5/bluetooth/widcomm.py build/lib.linux-armv6l-3.5/bluetooth/init.py build/lib.linux-armv6l-3.5/bluetooth/macos.py build/lib.linux-armv6l-3.5/bluetooth/btcommon.py build/lib.linux-armv6l-3.5/bluetooth/bluez.py build/lib.linux-armv6l-3.5/bluetooth/msbt.py Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: ws_comma running build_ext building 'bluetooth._bluetooth' extension creating build/temp.linux-armv6l-3.5 creating build/temp.linux-armv6l-3.5/bluez arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./port3 -I/usr/include/python3.5m -c bluez/btmodule.c -o build/temp.linux-armv6l-3.5/bluez/btmodule.o In file included from bluez/btmodule.c:20:0: bluez/btmodule.h:5:33: fatal error: bluetooth/bluetooth.h: No such file or directory

include <bluetooth/bluetooth.h>

                               ^

compilation terminated. error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1


Failed building wheel for pybluez Running setup.py clean for pybluez Failed to build pybluez Installing collected packages: pybluez Running setup.py install for pybluez ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-13fyw4pa/pybluez/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-9ggjzrrw-record/install-record.txt --single-version-externally-managed --compile --user --prefix=: running install running build running build_py creating build creating build/lib.linux-armv6l-3.5 creating build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/ble.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/widcomm.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/init.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/macos.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/btcommon.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/bluez.py -> build/lib.linux-armv6l-3.5/bluetooth copying bluetooth/msbt.py -> build/lib.linux-armv6l-3.5/bluetooth Fixing build/lib.linux-armv6l-3.5/bluetooth/ble.py build/lib.linux-armv6l-3.5/bluetooth/widcomm.py build/lib.linux-armv6l-3.5/bluetooth/init.py build/lib.linux-armv6l-3.5/bluetooth/macos.py build/lib.linux-armv6l-3.5/bluetooth/btcommon.py build/lib.linux-armv6l-3.5/bluetooth/bluez.py build/lib.linux-armv6l-3.5/bluetooth/msbt.py Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: ws_comma Fixing build/lib.linux-armv6l-3.5/bluetooth/ble.py build/lib.linux-armv6l-3.5/bluetooth/widcomm.py build/lib.linux-armv6l-3.5/bluetooth/init.py build/lib.linux-armv6l-3.5/bluetooth/macos.py build/lib.linux-armv6l-3.5/bluetooth/btcommon.py build/lib.linux-armv6l-3.5/bluetooth/bluez.py build/lib.linux-armv6l-3.5/bluetooth/msbt.py Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: ws_comma running build_ext building 'bluetooth._bluetooth' extension creating build/temp.linux-armv6l-3.5 creating build/temp.linux-armv6l-3.5/bluez arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./port3 -I/usr/include/python3.5m -c bluez/btmodule.c -o build/temp.linux-armv6l-3.5/bluez/btmodule.o In file included from bluez/btmodule.c:20:0: bluez/btmodule.h:5:33: fatal error: bluetooth/bluetooth.h: No such file or directory

include <bluetooth/bluetooth.h>

                                 ^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-13fyw4pa/pybluez/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-9ggjzrrw-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-13fyw4pa/pybluez/ pi@mpradio:~/mpradio $

GiannisDorokidis commented 4 years ago

should I try to re-install raspian stretch and then downloading the Project?

morrolinux commented 4 years ago

libbluetooth-dev is also missing. And that too is being installed by the installer script. Please retry the install by doing exactly what the README says: (you can copy-paste this for simplicity)

1) login to your Raspberry Pi 2) cd mpradio/install && sudo bash install.sh

Paste here the shell output. but please use pastebin.com if you manage

GiannisDorokidis commented 4 years ago

re run the commant "cd mpradio/install && sudo bash install.sh'' Then this

https://drive.google.com/file/d/18oUlMkOhEsljtwwwdgYmsiLt0vwak6D7/view?usp=drivesdk

https://drive.google.com/file/d/197BGz_yw6MXDbVwV9xG0TzxODZlml1RI/view?usp=drivesdk

morrolinux commented 4 years ago

c'mon man first file is truncated and for the second I don't have access. Why didn't you use https://pastebin.com ?

morrolinux commented 4 years ago

Anyway from what I can read on the first half it looks like a build issue with pyav library: https://github.com/mikeboers/PyAV You should really go open a ticket there providing all the requested information which are needed to investigate on that

GiannisDorokidis commented 4 years ago

sorry wasting your time here is the links: https://pastebin.com/K52hWMEF https://pastebin.com/f3MPRUvn

GiannisDorokidis commented 4 years ago

I made a forum on pyAv and they told me what version of FFmpeg I have how can I find that?

morrolinux commented 4 years ago

you can really easily google that: https://www.google.com/search?q=linux+which+version+of+ffmpeg+am+I+running&oq=linux+which+version+of+ffmpeg+am+I+running&aqs=chrome..69i57j69i64.7723j0j7&sourceid=chrome&ie=UTF-8 it's the first result.

Take this as a general approach

GiannisDorokidis commented 4 years ago

They told me that pyAv isn't supported because they don't support FFmpeg v3.0 so thats why its not working on raspian stretch Thank you for your time and work

morrolinux commented 4 years ago

Ok I've read the issue on the pyAV. They switched to version 7 wich no longer supports ffmpeg < 4. Lukily we can install a specific version via pip. Try this command and let me know: sudo pip install 'av==6'

GiannisDorokidis commented 4 years ago

I tried this and then this happened https://pastebin.com/614zKqWf Sould I try to install av before mpradio it self ?

morrolinux commented 4 years ago

I need to see the output of: sudo pip install 'av==6'

morrolinux commented 4 years ago

Since the av==6 installation goes well, I now updated the install script to install that instead of the latest version. try pulling the new version, run the installer and paste here both the installer log and the systemctl status mpradio

GiannisDorokidis commented 4 years ago

installation https://pastebin.com/9vmurmH2 mpradio status https://pastebin.com/y0c3QQnX

morrolinux commented 4 years ago

Looks like we moved one step ahead. Now the application is crashing on a routine it never really crashed before, is the config file (pirateradio.config) in the right place? what's its content?

GiannisDorokidis commented 4 years ago

I had problem with pirateradio.config Now its streaming properly here is the status https://pastebin.com/PgYnmctX I will Now try the bluetooth also RDS is working finaly properly

GiannisDorokidis commented 4 years ago

bluetooth doesn't work its disconecting after 10 seconds and I can't controll the pi with the apk https://pastebin.com/aiyP7wTc And bt-setup doesn't seem to exist

morrolinux commented 4 years ago

yeah bt-setup is legacy.

Is it streaming 10 seconds of audio and then disconnecting or does it stay connected for 10 seconds without any transmission working? Even in this case I would need the mpradio log as always

GiannisDorokidis commented 4 years ago

its streaming from the usb stick only I can connect to the pi via bluetooth with no audio and after 10 seconds it disconects https://pastebin.com/Qaup2eK0

morrolinux commented 4 years ago

what does cat /var/log/bluetooth_dev say? is mpradio.service enabled?

try issuing sudo systemctl stop mpradio && sudo rm /tmp/mpradio_bt && sudo systemctl enable mpradio && sudo reboot

After the reboot, wait until you hear some music from storage, THEN try connecting your phone to your Pi's bluetooth like you would normally do for any bluetooth speaker and try playing something.

IF it doesn't work, log back in to your Pi and post again the status of mpradio.service

Let me know

GiannisDorokidis commented 4 years ago

pi@mpradio:~ $ cat /var/log/bluetooth_dev [Sun Feb 2 18:28:21 GMT 2020]: Start Bluetooth played connection via python script

Then its says mpradio.service is running After reboot the same mpradio.service https://pastebin.com/CrgGJXyN

morrolinux commented 4 years ago

looks like a2dp_connected.py script is unable to find the connected bluetooth device and report its mac address. Strange, I'll have to think of something to debug this

GiannisDorokidis commented 4 years ago

I try again to run "sudo systemctl stop mpradio && sudo rm /tmp/mpradio_bt && sudo systemctl enable mpradio && sudo reboot" And bluetooth is Now connected but still can't stream music over bluetooth

morrolinux commented 4 years ago

try this: 1) on the console, write "python" 2) paste this:

from __future__ import absolute_import, print_function, unicode_literals
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()

for path, interfaces in objects.items():
    print("PATH: ", path, "\n INTERFACES", interfaces, "\n KEYS", interfaces.keys())
    print("-----------------------------")

and attach the output as always

GiannisDorokidis commented 4 years ago

output https://pastebin.com/vwMcBTm1

morrolinux commented 4 years ago

what's the output of running on the shell a2dp_connected.py ?

GiannisDorokidis commented 4 years ago

https://pastebin.com/3mk2GC9U Is this what you wanted to see? because I didn't understand

morrolinux commented 4 years ago

no man just type the above command on the bash shell

morrolinux commented 4 years ago

(you'd have to quit the python shell you're in)

GiannisDorokidis commented 4 years ago

pi@mpradio:~ $ a2dp_connected.py 40:40:A7:F2:C6:04 (witch is my phone's Mac address)

morrolinux commented 4 years ago

Maybe I've got an idea. I changed the bluetooth event script, so: 1) move to mpradio folder and git pull to download the update 2) run this command sudo cp install/usr/lib/udev/bluetooth /usr/lib/udev/bluetooth 3) reboot and test

GiannisDorokidis commented 4 years ago

I did "cd mpradio" then "git pull" And then "sudo cp.... bluetooth"

morrolinux commented 4 years ago

...and?

GiannisDorokidis commented 4 years ago

the same bluetooth connected no playback from it

morrolinux commented 4 years ago

as always I need the status of mpradio.service to see if anything's changed

GiannisDorokidis commented 4 years ago

https://pastebin.com/ebVrLBSx

morrolinux commented 4 years ago

I was able to reproduce the issue and devised a fix. you need to try it out: run: cd mpradio/install && git pull && git checkout embedding_bt_dev_lookup && sudo bash install.sh let me know

GiannisDorokidis commented 4 years ago

It does nothing the status led is showing that its blinking randomly but it shuts it self down I think I need to format the sd card because I cant get to the ssh shell at all

GiannisDorokidis commented 4 years ago

and no music streamed while its doing that

morrolinux commented 4 years ago

in mpradio.py https://github.com/morrolinux/mpradio-py/blob/db1d1502594dcbd414ff631e81373fbce0729dce/src/mpradio.py#L81 comment out this line with a # if that's the case

morrolinux commented 4 years ago

you should have the time to ssh pi@<your-raspi> 'sudo systemctl disable mpradio' otherwise you can simply mount the sdcard in your pc and go straight editing the file mentioned above

GiannisDorokidis commented 4 years ago

I put the sd card on my pc and I looked at overlays and didn't find it I also tried to use the search bar for files

morrolinux commented 4 years ago

If you're on windows I think you have to enable/install something to get to read ext4 partitions.. otherwise you could use a linux virtual machine for example. If you're fast enough, you could run the command above BEFORE mpradio starts and just after the network is present. you'd need a monitor connected to the Pi to help yourself with this. Otherwise you can start over from scratch