locked
How to find paired BT Devices for Windows Store App (8.1)

    Question

  • All examples and discussions I have found so far show how to use  PeerFinder.FindAllPeersAsync(); on Windows Phone 8.1 App to discover paired BT devices. Using this mechanism does not seem to work for Windows Store App 8.1; I always get zero device count. (also, for Windows Store App, we're required to call PeerFinder.Start().

    PeerFinder.Start();
    PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = "";
    var devices = await PeerFinder.FindAllPeersAsync();

    :

    I understand that the Window.Networking.Proximity is now a converged namespace in Win8.1 and WP8.1. Is there a white paper or example on how to do this for Windows Store App 8.1?

    Thanks

    Wednesday, July 9, 2014 1:38 PM

Answers

All replies

  • See Supporting Bluetooth Devices (XAML)

    As noted in the FindAllPeersAsync docs FindAllPeersAsync uses Wi-Fi Direct on Windows, not Bluetooth. It uses Bluetooth only on Windows Phone.

    Wednesday, July 9, 2014 1:45 PM
    Owner
  • For windows store apps it would be a little different (forexample selecting a predefined DeviceHostName device that is broadcasting a serial port on bt stack):

    var bluetoothDevices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
     
    foreach (var bluetoothDevice in bluetoothDevices)
    {
        if (bluetoothDevice.Name == DeviceHostName)
        {
            try
            {
                var device = await RfcommDeviceService.FromIdAsync(bluetoothDevice.Id);
                m_HostName = device.ConnectionHostName;
                m_ServiceName = device.ConnectionServiceName;
     
                break;
            }
            catch (Exception ex)
            {
            }
        }
    }

    you can find the actual example here => https://canbilgin.wordpress.com/2014/06/02/universal-apps-devices-api-i/

    Hope it helps


    Can Bilgin
    Blog Samples CompuSight


    • Edited by Can BilginMVP Thursday, July 10, 2014 6:05 AM correction
    Thursday, July 10, 2014 6:03 AM