我正在尝试将 PS5 控制器自动连接到 Raspberry。我在以下位置使用这个脚本/home/pi/bt.sh
:
#!/bin/bash
coproc bluetoothctl
echo -e 'scan on\n' >&${COPROC[1]}
sleep 3
echo -e 'connect 3C:C9:9D:54:E2:1C\n' >&${COPROC[1]}
sleep 1
echo -e 'scan off\n' >&${COPROC[1]}
echo -e 'exit\n' >&${COPROC[1]}
output=$(cat <&${COPROC[0]})
echo $output
我编辑sudo nano /etc/rc.local
了这个:
#!/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.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/home/pi/bt.sh &
exit 0
控制器在启动时连接几秒钟,然后关闭。为什么?我该如何解决?
dmesg 输出:
[ 19.266779] Bluetooth: Core ver 2.22
[ 19.266900] NET: Registered protocol family 31
[ 19.266911] Bluetooth: HCI device and connection manager initialized
[ 19.266939] Bluetooth: HCI socket layer initialized
[ 19.266957] Bluetooth: L2CAP socket layer initialized
[ 19.266986] Bluetooth: SCO socket layer initialized
[ 19.285056] Bluetooth: HCI UART driver ver 2.3
[ 19.285077] Bluetooth: HCI UART protocol H4 registered
[ 19.285185] Bluetooth: HCI UART protocol Three-wire (H5) registered
[ 19.285573] Bluetooth: HCI UART protocol Broadcom registered
[ 19.719726] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 19.719738] Bluetooth: BNEP filters: protocol multicast
[ 19.719756] Bluetooth: BNEP socket layer initialized
[ 19.751825] NET: Registered protocol family 38
[ 19.803472] cryptd: max_cpu_qlen set to 1000
[ 20.410378] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[ 20.410403] Bluetooth: HIDP socket layer initialized
[ 20.498154] Bluetooth: RFCOMM TTY layer initialized
[ 20.498179] Bluetooth: RFCOMM socket layer initialized
[ 20.498210] Bluetooth: RFCOMM ver 1.11
[ 20.955136] vc4-drm soc:gpu: [drm] Cannot find any crtc or sizes
[ 21.977207] hid-generic 0005:054C:0CE6.0001: unknown main item tag 0x0
[ 21.977731] input: Wireless Controller as /devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0CE6.0001/input/input4
[ 21.986045] hid-generic 0005:054C:0CE6.0001: input,hidraw0: BLUETOOTH HID v1.00 Gamepad [Wireless Controller] on b8:27:eb:a5:84:e4