蓝牙信号强度

发布于 2024-07-05 08:24:44 字数 133 浏览 4 评论 0原文

有谁知道如何在 C# 中最好地跟踪蓝牙连接的信号强度?

我正在考虑使用 WMI 查询,但无法追踪封装连接的 WMI 类。

这个想法是,当我把手机放在口袋里离开机器时,蓝牙信号会减弱,我的机器会锁定,我不会被攻击。

Does anyone have any idea how to track the signal strength of a bluetooth connection perferably in C#?

I was thinking using a WMI query but couldn't track down the WMI class encapsulating the connection.

The idea is when I leave my machine with my cellphone in pocket the bluetooth signal weakens and my machine locks and I don't get goated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帥小哥 2024-07-12 08:24:44

蓝牙设备中运行的链路管理协议 (LMP) 负责链路设置和配置。 这一切都是通过两个设备交换协议数据单元 (PDU) 来完成的。RSSI 的硬件和软件功能在 LMP 级别提供,允许您管理 RSSI 数据。 它允许您读取 RSSI 电平并控制 TX RF 输出功率(LMP 功率命令)LMP 进行控制并获取状态信息。

因此,当使用 MS 蓝牙堆栈时,您实际要查找的内容是在 LMP 中定义的。
MS 蓝牙堆栈 HCI 接口已支持以下功能,即

HCI_READHCIPARAMETERS
HCI_START硬件
HCI_STOPHARDWARE
HCI_SETCALLBACK
HCI_OPENCONNECTION
HCI_READPACKET
HCI_WRITEPACKET
HCI_CLOSECONNECTION

我想微软可以实现一个名为 HCI_Read_RSSI 的函数,但他们没有。

要获取 RSSI 数据,您必须使用 LMP 来获取所需的信息。

读取 RSSI 数据的伪代码示例

// Read HCI Parameters

#include <windows.h>
#include <windev.h>
#include <bt_buffer.h>
#include <bt_hcip.h>
#include <bt_os.h>
#include <bt_debug.h>
#include <svsutil.hxx>
#include <bt_tdbg.h>

unsigned short hci_subversion, lmp_subversion, manufacturer;
unsigned char hci_version, lmp_version, lmp_features[8];

if (BthReadLocalVersion (&hci_version, &hci_subversion, &lmp_version, &lmp_subversion, &manufacturer, lmp_features) != ERROR_SUCCESS) {
            SetUnloadedState ();
            return 0;
      }
WCHAR szLine[MAX_PATH]
unsigned char *pf = lmp_features;

if ((*pf) & 0x02) {
wsprintf (szLine, L"   RSSI");
}

这仅适用于 Microsoft 蓝牙堆栈。 这也是 C++ 代码。 我从页面底部的专家交流帖子(我知道)中得到了这个。
http://www.experts-exchange.com/Programming/Wireless_Programming/Bluetooth /Q_21267430.html

没有特定的函数可以为您完成此操作。

还有一个库可以帮助您,我还没有完全浏览文档,但我听说过有关它的好消息。
http://inthehand.com/content/32feet.aspx

祝你好运!

The Link Manager Protocol (LMP) running in a Bluetooth device looks after the link setup and configuration. This is all done by two devices exchanging Protocol Data Units (PDUs).The hardware and software functionality of the RSSI is provided at the LMP level that permits you to manage the RSSI Data. It allows you to read the RSSI level and control the TX RF output power (the LMP power commands) LMP for control and to get at status information.

So what you are actually looking for is defined in the LMP when using the MS Bluetooth stack.
The MS Bluetooth Stack HCI interface already supports functions below i.e

HCI_READHCIPARAMETERS
HCI_STARTHARDWARE
HCI_STOPHARDWARE
HCI_SETCALLBACK
HCI_OPENCONNECTION
HCI_READPACKET
HCI_WRITEPACKET
HCI_CLOSECONNECTION

I suppose microsoft could have implemented a function called HCI_Read_RSSI but they didn't.

To obtain the the RSSI data you will have to use the LMP to get the info you need.

Example psuedocode to read RSSI Data

// Read HCI Parameters

#include <windows.h>
#include <windev.h>
#include <bt_buffer.h>
#include <bt_hcip.h>
#include <bt_os.h>
#include <bt_debug.h>
#include <svsutil.hxx>
#include <bt_tdbg.h>

unsigned short hci_subversion, lmp_subversion, manufacturer;
unsigned char hci_version, lmp_version, lmp_features[8];

if (BthReadLocalVersion (&hci_version, &hci_subversion, &lmp_version, &lmp_subversion, &manufacturer, lmp_features) != ERROR_SUCCESS) {
            SetUnloadedState ();
            return 0;
      }
WCHAR szLine[MAX_PATH]
unsigned char *pf = lmp_features;

if ((*pf) & 0x02) {
wsprintf (szLine, L"   RSSI");
}

This will ONLY work with the Microsoft bluetooth stack. This is C++ code also. I got this from the experts exchange post(I know) at the bottom of the page.
http://www.experts-exchange.com/Programming/Wireless_Programming/Bluetooth/Q_21267430.html

There is no specific function that does it for you.

Also there is this library that may help you, I haven't looked through the documentation completely but I've heard good things about it.
http://inthehand.com/content/32feet.aspx

Goodluck man!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文