获取RSSI与hcidump [英] Obtain RSSI with hcidump

查看:1130
本文介绍了获取RSSI与hcidump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了读取原始的RSSI值,我们使用一个名为Hcidump工具,它监控蓝牙HCI数据。使用hcidump命令,接收到查询响应消息时,我们可以读取原始RSSI值。要获得RSSI值每一个应答包,我们首先查询模式设置到询价随着RSSI.In为了读取原始RSSI值我们运行hcidump工具,然后使用适当的
人机交互功能,开始定期查询。

In order to read the raw RSSI values, we use a utility called Hcidump, which monitors the Bluetooth HCI data. Using hcidump commands, we can read the raw RSSI values when an inquiry response message is received. To obtain RSSI values for every response packet we first set the inquiry mode to Inquiry With RSSI.In order to read raw RSSI values we run the hcidump tool and then use the appropriate HCI functions to start periodic inquiry.

我不知道如何使用hcidump到obatain仅RSSI原始数据或者如何开始定期查询。我看到所有的opcions,但我不能。

I don't know how to use hcidump to obatain only RSSI raw data or maybe how to start a periodic inquiry. I see all the opcions but I am not able.

我做hcidump --raw获得原始数据,并尝试分析这些数据来获得RSSI,但我不知道至极十六进制是RSSI信息。

I make hcidump --raw to obtain raw data, and try to parse this data to obtain the rssi, but I dont know wich hex is the rssi info.

这是我获得

  04 2F FF 01 AC A2 65 92 88 EC 01 00 0C 02 5A 2D 1F D2 08 09 
  4E 65 78 75 73 20 36 17 03 05 11 0A 11 0C 11 0E 11 12 11 15 
  11 16 11 1F 11 2F 11 00 12 32 11 01 05 01 07 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

现在我需要知道这是RSSI值。

Now I need to know which is the RSSI value.

推荐答案

我们可以通过检查 hcidump 工具背后的源$ C ​​$ C图了这一点。这是 的BlueZ,正式的Linux蓝牙堆栈的一部分。你可以在这里下载源的BlueZ code ,跟着一起。如果你打开​​源$ C ​​$ c和步入的lib / 文件夹,你可以找到 hci.h ,它拥有的BlueZ的人机交互功能的结构。定义。否则,你可以看看你的Linux系统的头文件。路径应该是这样的: /usr/include/bluetooth/hci.h 。在这个头文件,你会发现所有的BlueZ的人机交互功能的结构定义。具体来说,你可以找到 inquiry_info_with_rssi 的结构确定指标。头文件是长几千行,所以你会得到更好的服务搜索头文件,而不是试图通过它来寻找。通过观察这个结构与的#define 下面,你可以看到结构大小为14字节。 RSSI值是结构的最后一个成员,只有1个字节,所以应该算上14字节。

We can figure this out by inspecting the source code behind the hcidump tool. It is a part of BlueZ, the official Linux Bluetooth stack. You can download the BlueZ source code here, to follow along. If you open up the source code and step into lib/ folder, you can find hci.h, which has the struct definitons for BlueZ's HCI functions. Otherwise, you can look in your Linux system's header files. The path should be something like: /usr/include/bluetooth/hci.h. In this header file, you will find all the struct definitions for BlueZ's HCI functionality. Specifically, you can find the struct defintion for inquiry_info_with_rssi. The header file is a few thousand lines long so you would be better served searching the header file instead of trying to look through it. From looking at this struct and the #define below, you can see the struct size is 14 bytes. The rssi value is the last member of the struct and only 1 byte, so it should be the 14th byte you count.

typedef struct {
bdaddr_t    bdaddr;
uint8_t     pscan_rep_mode;
uint8_t     pscan_period_mode;
uint8_t     dev_class[3];
uint16_t    clock_offset;
int8_t      rssi;
} __attribute__ ((packed)) inquiry_info_with_rssi;
#define INQUIRY_INFO_WITH_RSSI_SIZE 14

这是有趣的注意的是, __ attribute__((包装))是一个编译器preprocessor指挥它不垫结构,使14个字节大小存在保证

An interesting note is that __attribute__ ((packed)) is a compiler preprocessor directing it not to pad the structure, so the size of 14 bytes is guranteed.

这篇关于获取RSSI与hcidump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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