locked
Connect to a Bluetooth HID device with WinRT on Windows Phone 8.1

    Question

  • I have a Gamepad which advertises itself as a Bluetooth hid gamepad, I am able to connect (pair then connect) it to my windows phone via System settings.

    However after I switch to my app on the phone, the device always gets disconnected (unlike on windows 8.1, it remains connected).

    So in the app I want to establish a connection to the device the same way as System Settings does,

    With the following test codes

    //connect to a paired bluetooth device
                 PeerFinder.AlternateIdentities["Bluetooth:Paired"] = ""; ;
                 var peers=await PeerFinder.FindAllPeersAsync();
                 if(peers.Count>0)
                 {
                     var p = peers.Last();
                     Debug.WriteLine(p.DisplayName);
                     Debug.WriteLine(p.ServiceName);
    
    
                     var bt = await BluetoothDevice.FromHostNameAsync(p.HostName);
                     Debug.WriteLine(bt.ConnectionStatus.ToString());
                     
                     
                     var addr=bt.BluetoothAddress;
    
    
                 }
    

    I am able to find the Bluetooth device of interest, however I am now stuck with how to make a connection request to the Bluetooth device.

    Could anyone please enlighten me for the next step, have been stuck here for a while now.


    • Edited by hereafter Saturday, February 14, 2015 3:59 PM
    Saturday, February 14, 2015 2:54 PM

All replies

  • Windows Phone Store apps can access the Windows.Devices.HumanInterfaceDevice API if the manufacturer supported the HID protocol for specific devices and provided corresponding device-data to app developers. Refer to your manufacturer’s documentation for a list of supported HID devices as well as the data that you’ll need to implement device discovery.

    http://stackoverflow.com/questions/27422653/selfie-stick-bluetooth-hid-device-on-windows-phone-8-1

    Monday, February 16, 2015 3:21 AM
  • yes, i can use this namespace to get connected device to work on Windows 8.1.

    The link gives me the exact question i am asking. but it was left unanswered. i am not able to connect to the device, like the system settings applicataion does.

    Because the device is not even connected with Bluetooth. HID cann't find it and initialie.


    • Edited by hereafter Monday, February 16, 2015 5:09 AM
    Monday, February 16, 2015 5:07 AM