RaspberryPi 蓝牙文件应用程序始终要求在 iOS 上进行配对

问题描述 投票:0回答:3

我目前正在开发一个移动应用程序,该应用程序连接到 Ble 外围设备并从中读取数据。为了测试连接是否正常。我编写了一个小型 C# 应用程序,通过 DBus 和 BlueZ 使用 RaspberryPi4 蓝牙。

一切正常,除了当连接到 iOS 时,树莓派发出配对请求,尽管我没有任何加密特征。

我在Apple论坛上读到这是因为蓝牙会自动尝试读取手机的电池电量。但遗憾的是,即使在修复建议之后我也收到了配对请求。

有人知道我该如何解决这个问题吗?

提前致谢

c# dbus bluez raspberry-pi4 ios-bluetooth
3个回答
1
投票

我相信在

/etc/bluetooth/main.conf
中禁用此 bluez 配置选项将阻止 pi 尝试从 iOS 设备读取特征(如果这是问题所在):

# Do reverse service discovery for previously unknown devices that connect to
# us. For BR/EDR this option is really only needed for qualification since the
# BITE tester doesn't like us doing reverse SDP for some test cases, for LE
# this disables the GATT client functionally so it can be used in system which
# can only operate as peripheral.
# Defaults to 'true'.
#ReverseServiceDiscovery = true

0
投票

检查连接最小和最大间隔,它们应符合 iOS 指南:https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf(第 180 页 - 40.6 连接参数)。

你可以这样调整它们:

echo "30" > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo "45" > /sys/kernel/debug/bluetooth/hci0/conn_min_interval

默认值对我有用:[24,40]


0
投票

造成这种情况的一个原因是 Linux 尝试从 iPhone,这会触发配对请求。您可以配置 bluez 可以防止这种情况发生。

禁用自动电池读取功能

  1. 在文本编辑器中打开蓝牙服务文件 /usr/lib/systemd/system/bluetooth.service 或 /etc/systemd/system/bluetooth.target.wants/bluetooth.service。您可能需要 sudo 权限才能写入此文件。

  2. 将 -P Battery 添加到 ExecStart 行的末尾以禁用 bluetoothd 中的电池功能。您的 ExecStart 现在应该类似于 ExecStart=/usr/lib/bluetooth/bluetoothd -P Battery 。保存文件。

  3. 运行 systemctl daemon-reload 和 systemctl restart bluetooth 将更改应用到蓝牙服务

来源:https://github.com/ukBaz/python-bluezero/issues/335

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.