windows 从 Wii-balanceboard 读取数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5200384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:20:31  来源:igfitidea点击:

Read data from Wii-balanceboard

c++windowsbluetoothhidwii-balanceboard

提问by ethrbunny

Im trying to get the output from a Wii Fit (balance board). I can find the device via the C++ Bluetooth enumerators but attempts to connect via a windows socket are failing.

我试图从 Wii Fit(平衡板)获得输出。我可以通过 C++ 蓝牙枚举器找到该设备,但尝试通过 Windows 套接字连接失败。

Im wondering if anyone has had success in such a direction (C++, windows) I'd love to hear how you did it.

我想知道是否有人在这样的方向上取得了成功(C++、Windows),我很想听听您是如何做到的。

采纳答案by pwc

The Wii Balance Board is a HID device. To understand communications with the Balance Board, you need to know a little bit about Bluetooth HID. There's good information on WiiBrew about the Wiimoteand the Wii Balance Board.

Wii 平衡板是一种 HID 设备。要了解与平衡板的通信,您需要对蓝牙 HID 有所了解。WiiBrew 上有关于WiimoteWii 平衡板的很好的信息。

I don't think you can use Windows Sockets to connect to a HID device. The Windows Socket Bluetooth interface only allows you to connect to RFCOMM-based services. HID is based on L2CAP which is further down the Bluetooth protocol stack. There's some information at MSDNabout that limitation.

我认为您不能使用 Windows Sockets 连接到 HID 设备。Windows Socket 蓝牙接口仅允许您连接到基于 RFCOMM 的服务。HID 基于 L2CAP,它位于蓝牙协议栈的下方。MSDN 上有一些关于该限制的信息。

If you're just looking to hack around with it, you can try Bluecovefor Java. You may be able to do something using another stack (for example, Widcomm). If you're locked in to Windows and C++, you may have to look into writing an custom HID driver for the Balance Board.

如果您只是想尝试一下,可以尝试Bluecovefor Java。您或许可以使用另一个堆栈(例如 Widcomm)执行某些操作。如果您被锁定在 Windows 和 C++ 中,您可能需要考虑为平衡板编写自定义 HID 驱动程序。

回答by garzanti

As pwc said there is a limitation in the MS Bluetooth API, so with sockets you cannot have something else except RFCOMM, but this doesn't mean you cannot go down at L2CAP layer. What you have to do is to implement a client profile driver and you can use as starting point an article from MSDN: Creating a L2CAP Client Connection to a Remote Deviceand vice-versa: Accepting L2CAP Connections in a Bluetooth Profile Driver

正如普华永道所说,MS 蓝牙 API 存在限制,因此对于套接字,除了 RFCOMM 之外,您不能拥有其他东西,但这并不意味着您不能在 L2CAP 层进行下去。您需要做的是实现客户端配置文件驱动程序,您可以使用 MSDN 中的文章作为起点:Creating a L2CAP Client Connection to a Remote Device,反之亦然:Accepting L2CAP Connections in a Bluetooth Profile Driver

Next of course as pwc said you have to study Bluetooth HID and WiiBrew for the communication protocol.

接下来当然正如普华永道所说,您必须研究蓝牙 HID 和 WiiBrew 的通信协议。

Also a good document to read is Bluetooth Wireless Technology FAQ - 2010which states clear that it is possible to have L2CAP connections with Microsoft Bluetooth stack driver. Of course not with sockets.

另一个值得阅读的好文档是蓝牙无线技术常见问题解答 - 2010,其中明确指出可以与 Microsoft 蓝牙堆栈驱动程序建立 L2CAP 连接。当然不是用插座。

回答by alanjmcf

When using HID on a Bluetooth device there is generally noneed to create a L2CAP connection directly. All(???) of the Bluetooth stacks on Win32 have support for Bluetooth HID and provide access to the HID stream/control through the native Windows HID API. No (direct) L2CAP required! :-)

当蓝牙设备上使用HID一般是有没有必要直接创建一个L2CAP连接。Win32 上的所有 (???) 蓝牙堆栈都支持蓝牙 HID,并通过本机 Windows HID API 提供对 HID 流/控制的访问。不需要(直接)L2CAP!:-)

On WinCE there is built-in support for Bluetooth HID also, but I'm not sure there's a way to access a HID API.

在 WinCE 上,也内置了对蓝牙 HID 的支持,但我不确定是否有办法访问 HID API。

That's how Brian Peek's wiimore library works -- it uses the HID API. The good thing about that is that one gets supports for all(?) the Bluetooth stacks that way -- they each support HID devices via the Windows HID API, whereas to use L2CAP directly one would have to support each of the stacks' APIs... (That's if they have one! BlueSoleil has no L2CAP API as far as I can see).

这就是 Brian Peek 的 wiimore 库的工作原理——它使用 HID API。这样做的好处是可以通过这种方式获得对所有(?)蓝牙堆栈的支持——它们每个都通过 Windows HID API 支持 HID 设备,而要直接使用 L2CAP,则必须支持每个堆栈的 API。 ..(如果他们有的话!就我所见,BlueSoleil 没有 L2CAP API)。

So, on Win32 one should just pair with the device and check that the HID checkbox is checked on its Bluetooth Service control panel tab (whichever Bluetooth stack is in use). In my 32feet.NET library one can discover the device and then ensure that HID is enabled for it with:

因此,在 Win32 上,应该只与设备配对并检查其蓝牙服务控制面板选项卡上的 HID 复选框是否已选中(无论使用的是哪个蓝牙堆栈)。在我的 32feet.NET 库中,可以发现设备,然后确保为它启用了 HID:

BluetoothDeviceInfo[] list = btCli.DiscoveryDevices();
var deviceInfo = list[n]; // Select the correct device
deviceInfo.SetServiceState(BluetoothService.HumanInterfaceDevice, true);

(That should work on MSFT and BlueSoleil; there's no API for that on Widcomm AFAIK -- although when paired it might be automatically enabled anyway).

(这应该适用于 MSFT 和 BlueSoleil;Widcomm AFAIK 上没有相应的 API——尽管配对后它可能会自动启用)。

The one possible exception case is that apparently some devices are not fully compliant with the Bluetooth/HID specs, I'm told the PS3 blu-ray controller is like that. Then one might want to try L2CAP connections directly -- however its likely that the stack's support for HID will interfere with third-party applications trying to provide the same service...

一种可能的例外情况是,显然有些设备不完全符合蓝牙/HID 规范,我听说 PS3 蓝光控制器就是这样。那么人们可能想直接尝试 L2CAP 连接——但是,堆栈对 HID 的支持很可能会干扰试图提供相同服务的第三方应用程序......