You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派蓝牙:无需PIN码启用传统配对/连接方法求助

树莓派蓝牙传统配对(Classic Pairing)亲测有效配置方案

一、先更新系统(适配最新Raspberry Pi OS Bookworm)

sudo apt update && sudo apt upgrade -y

二、安装/更新蓝牙工具

确保核心蓝牙组件为最新版:

sudo apt install bluez bluez-tools bluetooth -y
sudo systemctl restart bluetooth

三、配置蓝牙服务参数

编辑蓝牙主配置文件:

sudo nano /etc/bluetooth/main.conf

找到并修改以下参数:

  • 将ControllerMode改为bredr(强制启用传统蓝牙模式)
  • 确保AutoEnable设为true
  • 把PairableTimeout改为0(保持持续可配对状态)
  • 把DiscoverableTimeout改为0(保持设备可被发现)

保存退出后重启蓝牙服务:

sudo systemctl restart bluetooth

四、手动配对并信任设备

  1. 启动蓝牙交互控制台:
bluetoothctl
  1. 在控制台内执行基础设置:
power on
discoverable on
pairable on
  1. 打开目标蓝牙设备的配对模式,执行扫描:
scan on

找到设备MAC地址(如AA:BB:CC:DD:EE:FF)后停止扫描:

scan off
  1. 发起配对并完成信任:
pair AA:BB:CC:DD:EE:FF

按提示输入配对码(常见为0000或1234),配对成功后执行:

trust AA:BB:CC:DD:EE:FF
connect AA:BB:CC:DD:EE:FF
  1. 退出控制台:
exit

五、设置开机自动连接

创建自动连接服务文件:

sudo nano /etc/systemd/system/bluetooth-auto-connect.service

粘贴以下内容(替换MAC地址为你的设备地址):

[Unit]
Description=Bluetooth Auto Connect
After=bluetooth.target

[Service]
Type=simple
ExecStart=/usr/bin/bluetoothctl connect AA:BB:CC:DD:EE:FF
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

保存后启用并启动服务:

sudo systemctl daemon-reload
sudo systemctl enable bluetooth-auto-connect.service
sudo systemctl start bluetooth-auto-connect.service

常见问题排查

  • 配对失败时,先删除旧配对记录:在bluetoothctl内执行remove AA:BB:CC:DD:EE:FF后重新配对
  • 确认目标设备支持传统蓝牙(非仅BLE低功耗模式)
  • 检查蓝牙模块状态:执行hciconfig hci0,若未显示UP则执行sudo hciconfig hci0 up

内容的提问来源于stack exchange,提问作者manintree

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 10:00:02