开发者

32Feet API with C# .NET - Stuck

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 device开发者_开发技巧s)
{
   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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜