×

Discussion Board

Results 1 to 5 of 5

Thread: Bluetooth

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    3

    Bluetooth

    Hi

    How do I know what Bluetooth device i connect now with my code ?

    I try next code but it's not working

    PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
    IReadOnlyList<PeerInformation> pairedDevices;
    pairedDevices = await PeerFinder.FindAllPeersAsync();

    for (int i = 0; i < pairedDevices.Count; i++)
    {
    PeerInformation selectedDevice = pairedDevices[i];
    try
    {

    StreamSocket socket = new StreamSocket();
    socket.ConnectAsync(selectedDevice.HostName, "1");
    MessageBox.Show("Connected - > " + selectedDevice.DisplayName);
    }
    catch (Exception ex)
    {
    MessageBox.Show("Not connected - > " + selectedDevice.DisplayName);
    }
    }


    Regards
    Alex

  2. #2
    Nokia Developer Champion
    Join Date
    Jul 2012
    Posts
    88

    Re: Bluetooth

    This will try to connect to every peer found by FindAllPeersAsync() (Not a very good idea), you should access the peer you want by index or you can search by hostname inside the loop.

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    3

    Re: Bluetooth

    I can receive Bluetooth device event connect/disconnect in my application maybe ?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,686

    Re: Bluetooth

    Well, when a discussion starts covering "everything", it often turns out to be a good approach to describe what you are trying to achieve.

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    5

    Re: Bluetooth

    as mentioned below this code tries to find every user. you should try to find them individually

Similar Threads

  1. Replies: 0
    Last Post: 2004-04-12, 12:23
  2. Replies: 0
    Last Post: 2004-04-12, 12:22
  3. Replies: 0
    Last Post: 2004-04-12, 12:21
  4. Replies: 3
    Last Post: 2003-12-29, 13:54
  5. Bluetooth Connectivity Problem: 8910, 3COM Bluetooth Wireless PC Card
    By ellistai in forum PC Suite API and PC Connectivity SDK
    Replies: 3
    Last Post: 2003-02-20, 12:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×