32Feet API 与 C# .NET - 卡住

发布于 2024-09-25 03:22:04 字数 952 浏览 11 评论 0原文

我正在尝试使用 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,然后从他们的流中读取内容吗?

I am trying to pair my Wiimotes using 32Feet API and I am successfully in doing so by following code.

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?
    }
}

The line which I have commented as "Here I am confused!..." is what messing all the time. Can someone help me how to connect to all the wiimotes one by one and then to read from their stream please?

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

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

发布评论

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

评论(1

╰ゝ天使的微笑 2024-10-02 03:22:04

不要尝试重新发明轮子,使用现有的库:http://wiimotelib.codeplex.com/

Don't try to reinvent the wheel, use an existing library: http://wiimotelib.codeplex.com/

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