#!/bin/bash # Original: https://hacks.mozilla.org/2017/02/headless-raspberry-pi-configuration-over-bluetooth/ # Diese Datei soll auf dem PI installiert werden unter /home/pi/btserial.sh # Das Skript erledigt auch die Initialkonfiguration der systemd-Dienste für Bluetooth #Edit the display name of the RaspberryPi so you can distinguish #your unit from others in the Bluetooth console #(very useful in a class setting) echo PRETTY_HOSTNAME=raspi > /etc/machine-info # Edit /lib/systemd/system/bluetooth.service to enable BT services sudo sed -i: 's|^Exec.*toothd$| \ ExecStart=/usr/lib/bluetooth/bluetoothd -C \ ExecStartPost=/usr/bin/sdptool add SP \ ExecStartPost=/bin/hciconfig hci0 piscan \ |g' /lib/systemd/system/bluetooth.service # create /etc/systemd/system/rfcomm.service to enable # the Bluetooth serial port from systemctl sudo cat < /dev/null [Unit] Description=RFCOMM service After=bluetooth.service Requires=bluetooth.service [Service] ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100 -a pi [Install] WantedBy=multi-user.target EOF # enable the new rfcomm service sudo systemctl enable rfcomm # start the rfcomm service sudo systemctl restart rfcomm