AMI-system / ami_setup

AMI configuration files
MIT License
0 stars 2 forks source link

Unable to connect via Bluetooth after installation and reboot #10

Closed DylanCarbone closed 4 months ago

DylanCarbone commented 5 months ago

Hi @JonasBchrt ,

I've just tried setup Bluetooth on my Raspberry Pi using your read me instructions. The script runs without error and the second time I ran it (apologies, I lost the console output from the first install), I received the following as output:

> pi@raspberrypi:~/Desktop/ami_setup-bluetooth-dev $ sudo ./install.sh
> Installing Bluetooth for Ami-Trap...
>     1/4 Installing dependencies...
> Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
> Requirement already satisfied: dbus-next==0.2.3 from file:///home/pi/ami_setup-bluetooth-dev/dbus_next-0.2.3-py3-none-any.whl in /usr/local/lib/python3.7/dist-packages (0.2.3)
> Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
> Requirement already satisfied: bluez-peripheral==0.1.7 from file:///home/pi/ami_setup-bluetooth-dev/bluez_peripheral-0.1.7-py3-none-any.whl in /usr/local/lib/python3.7/dist-packages (0.1.7)
> Requirement already satisfied: dbus-next in /usr/local/lib/python3.7/dist-packages (from bluez-peripheral==0.1.7) (0.2.3)
>     2/4 Enabling bluetooth on boot...
>     3/4 Adding command to rc.local for start-up after boot...
>     4/4 Tweak other commands in rc.local...
> Installation complete. Please reboot to enable Bluetooth.

However, after rebooting, I'm unable to connect via the Bluetooth application. Do you have any ideas what could be causing this error?

Thanks

JonasBchrt commented 5 months ago

Sounds quite fundamental @DylanCarbone Could you send me the following from your Pi? (Or at least what's easy for you to obtain - don't wanna waste your time.) 1) The content of /etc/rc.local. 2) The content of /boot/config.txt. 3) The output of the command sudo python3 /home/pi/Desktop/ami_setup-bluetooth-dev/ami-trap-raspi-bluetooth.py. 4) Whether you can connect via Bluetooth after executing this command or not. 5) Which base image you are using (e.g., rasp-pi-amber-20231013). 6) Whether you have modified the base image or not before installing the Blueooth stuff. (No need to list the modifications.)

One guess is that there may be a command in your rc.local that is not terminated with an &.

Thanks for your feedback!

DylanCarbone commented 5 months ago

Hi @JonasBchrt,

Thanks for your help! Sorry it took a little while to get to this. Please find attached the config and rc local file

In answer to these questions:

The output of the command sudo python3 /home/pi/Desktop/ami_setup-bluetooth-dev/ami-trap-raspi-bluetooth.py.

Run Bluetooth continuously.

Bluetooth powered on.

Ami-Trap-10000000e40ed214

Whether you can connect via Bluetooth after executing this command or not.

I can connect through your Bluetooth application! If it's any help, I also receive Command 'iwgetid -r' returned non-zero exit status 255.

Which base image you are using (e.g., rasp-pi-amber-20231013).

I'm using rasp-pi-20231013

Whether you have modified the base image or not before installing the Blueooth stuff. (No need to list the modifications.)

I've made some edits to the motion config file and Grace's bird pi script, but that should be all. However, I'm still pretty novice at using the Pi and I would consider the likelihood that I've corrupted a file somewhere, if you can't find a solution.

Thanks

config.txt rc - Copy.txt

JonasBchrt commented 5 months ago

Thanks @DylanCarbone ,

The issue is indeed the /etc/rc.local file on your Pi. I would put a & behind the motion command to run the motion software in the background rather than in the foreground. Currently, the system waits until motion terminates (which never happens) before Bluetooth starts. A fixed /etc/rc.local file could look like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/pi/scripts/setCamera.sh &

#/sbin/modprobe uvcvideo

motion &

sudo python3 /home/pi/ami_setup-bluetooth-dev/ami-trap-raspi-bluetooth.py &

exit 0

Then, the Bluetooth service should start automatically on start-up.

Currently, the way the install.sh script in this repo works is pretty hacky. It attempts to fix missing & in /etc/rc.local, but failed doing that adequately in your case. Ultimately, an image may just ship with a complete /etc/rc.local file and we hopefully won't need that script anymore.

P.S: I hope running motion in the background doesn't cause any issues.

DylanCarbone commented 5 months ago

Hi Jonas,

Apologies again for the slow reply. That's great, thank you. I'll make this change when I'm back in the office after Portugal and let you know if there are any issues with motion running in the background.

DylanCarbone commented 4 months ago

Hi Jonas,

I just checked and everything works. Thanks for your help :)