locked
Seeing Bluetooth devices paired with tablet

    Question

  • Hi,

    I am trying to get my win store app to work with a Bluetooth printer but having no luck.  So for testing I am now trying to connect to any Bluetooth objects already paired with the tablet.  I have looked online and can see 2 ways to connect to Bluetooth and I have tried both code examples below but in both cases below the count of services1 is 0.

    So on my tablet I have 4 devices paired by bluetooth...should the below code iterate through all 4...or should it iterate only through those paired AND connected.  At a start, I am want to iterate through all devises just paired so at least I know I am on the right track. Should the below code do this?

    I seen a mention in the MS docs that you need to specify the actual Bluetooth device in the package manifest.  Do I need to do this just to see the paired devices?

    At the moment I am not sure if it is my code or the tablet that is the issue...can others just use the code below and see all paired devises or is there a step I am missing? 

    Thanks for all help

            Dim services1 = Await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.ObexObjectPush))
    
    

    PeerFinder.Start()
     PeerFinder.AlternateIdentities("Bluetooth:Paired") = ""
    Dim services1 = Await PeerFinder.FindAllPeersAsync()

    Thursday, October 23, 2014 10:09 AM

All replies

  • Please try the following code.

    PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = ""; 
    var available_devices = await PeerFinder.FindAllPeersAsync(); 
    if (available_devices.Count > 0) 
    {            
       PeerInformation pi= // Select the device  
    }
    StreamSocket socket = new StreamSocket(); 
    await socket.ConnectAsync(pi.HostName, “1");

    Regards,

    Friday, October 24, 2014 1:55 PM
  • Hi,

    Thanks for your reply...but that code is the same as the original code I posted in my question (in my second code block).  I have tried both code blocks and neither return a count unfortunately.

    Is there anything you do in your app other than use the above code i.e. do you add anything to your manifest file?  Do you have any other capabilities bar proximity turned on?

    Thanks


    • Edited by Ireland75 Friday, October 24, 2014 5:06 PM
    Friday, October 24, 2014 4:25 PM