【问题标题】:Bluez Code cannot detect Bluetooth device but Settings canBluez Code 无法检测到蓝牙设备,但设置可以
【发布时间】:2016-08-26 00:52:20
【问题描述】:

我在设置中的蓝牙适配器(在 Ubuntu 上)可以检测到我的 AR Drone (MiniSpider) 设备。但是使用simple Bluez code example 检测蓝牙设备,我无法检测到无人机设备。我的代码与前面提到的链接中的代码完全相同。我可以使用代码检测到手机(如果手机已显示自己)。

知道可能是什么问题吗?

hcitool lescan的输出:成功找到无人机蓝牙设备。

sudo hcitool lescan
LE 扫描 ...
A0:14:31:48:8C:EB RS_W082091
A0:14:31:48:8C:EB RS_W082091
A0:14:31:48:8C:EB RS_W082091

【问题讨论】:

  • 代码示例适用于经典的 BT 扫描而非 LE 扫描。

标签: c ubuntu bluetooth bluez


【解决方案1】:

您使用的代码 sn-p 用于扫描经典蓝牙设备。这相当于在命令行中使用hcitool inq,在这种情况下您可能无法检测到您的设备。

但是,AR Drone 似乎支持低功耗蓝牙 (BLE),而不是经典蓝牙。因此,使用查询方法您无法检测到它。如果您使用扫描 BLE 设备的代码,您将能够找到您的设备。您可以在下面查看 hcitool.c 的源代码:-

https://github.com/aguedes/bluez/blob/master/tools/hcitool.c

然后你的出发点是使用 hcitool lescan 代码:-

static void cmd_lescan(int dev_id, int argc, char **argv)
{
    ...
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-26
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 2020-05-27
    相关资源
    最近更新 更多