我正在尝试使用 32Feet API 配对我的 Wiimotes,我通过以下代码成功地做到了这一点。
var client = new InTheHand.Net.Sockets.BluetoothClient();
var devices = client.DiscoverDevices();
var count = (from d in devices
where d.DeviceName.Contains("Nintendo")
select d).Count();
foreach (var device in devices)
{
if (device.DeviceName.Contains("Nintendo"))
{
if (device.InstalledServices.Length > 0)
{
InTheHand.Net.Bluetooth.BluetoothSecurity.RemoveDevice(device.DeviceAddress);
//while it's being removed
Thread.Sleep(2000);
}
device.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService.HumanInterfaceDevice, false);
device.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService.HumanInterfaceDevice, true);
//Here I am confused! What to do to read from stream?
}
}
我评论为“我在这里感到困惑!......”的那句话一直很混乱。有人可以帮助我如何一一连接到所有 wiimotes,然后从他们的流中读取吗?