BlueZ hci_ * API使主机可发现 [英] BlueZ hci_* API to make the host discoverable

查看:174
本文介绍了BlueZ hci_ * API使主机可发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:

  • Linux
  • BlueZ蓝牙堆栈
  • C API
  • 不使用dbus接口

我必须说HCI BlueZ C API( hci_lib.h )的文献资料很少,也就是说,是否存在控制主机可发现状态的C hci_ * API?类似于"hci_write_simple_pairing_mode"可以控制可发现性?

I must say that the HCI BlueZ C API ( hci_lib.h ) is poorly documented, having that said, Is there a C hci_* API controlling the host discover-able state? something similar to "hci_write_simple_pairing_mode" enabling control of discoverability?

推荐答案

以下hci命令可发现适配器
hciconfig hci0 piscan

The following hci command makes the adapter discoverable
hciconfig hci0 piscan

以下是hciconfig中的相应代码

Following is the corresponding code from hciconfig

if (!strcmp(opt, "pscan"))
    dr.dev_opt = SCAN_PAGE;
else if (!strcmp(opt, "piscan"))
     dr.dev_opt = SCAN_PAGE | SCAN_INQUIRY;
if (ioctl(ctl, HCISETSCAN, (unsigned long) &dr) < 0) {

这里的ctl是从中得到的:

Here ctl is what is got from:

 if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) 

这篇关于BlueZ hci_ * API使主机可发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆