raspberrypi / piserver

Raspberry Pi Server wizard to serve Raspbian to network booting Pis
318 stars 60 forks source link

Can I use bluetooth #100

Closed gits00 closed 4 years ago

gits00 commented 4 years ago

I wish to use a network booted RPi as a data collector from Bluetooth devices. I was able to boot a pi 3B+ with a minimal image of Rasbian buster lite. But I am unable to get the Bluetooth working probably because of the security risk which prevents Bluetooth to not work unless started using "sudo bluetoothctl" (Tried the steps at https://github.com/DrRowland/RPi-Bluetooth-Console/blob/master/setup.sh). But I feel there would be some workaround to get this because a networked sensor array is one of the main use cases of piserver.

maxnet commented 4 years ago

Have not tried Bluetooth. And I do not know whether or not that wouldn't like to write information like pairing data to locations that are read-only on a default piserver installation.

But generally speaking:

gits00 commented 4 years ago

@maxnet, Thanks.

Is there anything I am missing here? Thank you.

maxnet commented 4 years ago

If you want to add network users (created in Piserver) to a group, easiest is to do so by executing "leafpad /etc/security/group.conf" in chroot and adding a line among the lines of:

# Extra groups for all users logged in to local console
login;tty*;*;Al0000-2400;bluetooth, sudo

Might need to use something different than "login" and "tty*" if connecting through ssh or other means. Or specify individual users instead:

# Give myuser extra groups regardless how he logged in, at all times of the day
*;*;myuser;Al0000-2400;bluetooth, sudo

Be aware that this is just for interactive login sessions. Good for playing around and testing purposes. In the end you probably want to create a systemd service instead. If you do not want to have that running as root, it may be better to create a local user instead of a network user.

gits00 commented 4 years ago

Thanks @maxnet. I was able to get bluetooth working in interactive session though a couple of times I see UART initialization timed out in "/var/log/syslog" . In such cases "bluetoothctl" got hung. At other times bluetooth worked. The changes needed were -

Do I need to create a systemd service here? I see bluetooth service getting started at boot time. Looking around found that "BLUETOOTH_ENABLED=1" in "/etc/default/bluetooth". I am pretty new to using bluetooth and Raspberry Pi so not really sure.

maxnet commented 4 years ago

Do I need to create a systemd service here? I see bluetooth service getting started at boot time.

Well, you mentioned wanting to use it as data collector. If by that you mean that multiple Pi collect data from bluetooth sensors, and phone it back home to some central server, then the daemon that does the data collection typically would run as a systemd service, yes. That's not Piserver specific though.

gits00 commented 4 years ago

Oh ok, I got it now. Thanks @maxnet !