locked
RFCOMM connection fails

    Question

  • Hello,

    I am trying to establish a connection to the pebble smart watch from a Windows 8.1 WinRT app exactly as described in http://channel9.msdn.com/Events/Build/2013/3-026, of course after pairing. I am using the very same source code so the capabilities are declared. Here is the abbreviated code:

    var serviceInfoCollection =
     await DeviceInformation.FindAllAsync(
      RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
    serviceInfo = serviceInfoCollection[0];

    // Initialize the target Bluetooth RFCOMM device service
    rfcommService = await RfcommDeviceService.FromIdAsync(serviceInfo.Id);

    if (rfcommService != null)
    {
     // Create a socket and connect to the target
     socket = new StreamSocket();
     await socket.ConnectAsync(
      rfcommService.ConnectionHostName,
      rfcommService.ConnectionServiceName,
      SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);

     writer = new DataWriter(socket.OutputStream);
    }

    Unfortunately socket.ConnectAsync fails with message Element not found. (Exception from HRESULT: 0x80070490). I have spent more than a day trying different things with no success. I know that pebble bluetooth communication works because I can connect and write to it from WP8 and Desktop apps.

    WP8 sample:

    PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
    IReadOnlyList<PeerInformation> pairedDevices = PeerFinder.FindAllPeersAsync().AsTask().Result;
    var pebble = pairedDevices[0];

    StreamSocket socket = new StreamSocket();
    try
    {
     await socket.ConnectAsync(pebble.HostName, new Guid(0x00001101, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB).ToString("B"));
      
     _prot = new Protocol(socket);
     _prot.MessageReceived += AsynMessageRecived;

     if(Connected != null)
      Connected(this, EventArgs.Empty);
    }
    catch (Exception e)
    {
     if(ConnectionError != null)
      ConnectionError(this, EventArgs.Empty);
    }

    Note that I also tried to use the serial port UUID as I did in WP8 (Guid(0x00001101, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB).ToString("B")) with Win8.1 but then it fails with "The requested address is not valid in its context. (Exception from HRESULT: 0x80072741)".

    Can you deduce something from these errors? Any ideas?

    Any help would be much appreciated.

    Lorant

    Monday, March 10, 2014 9:30 PM

All replies

  • At what line does the code fail?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, March 11, 2014 12:13 PM
    Moderator
  •  await socket.ConnectAsync is where it fails.
    Tuesday, March 11, 2014 1:16 PM
  • I am having this exact same issue.
    Thursday, March 13, 2014 12:39 PM
  • Are you also using the Pebble?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, March 13, 2014 1:31 PM
    Moderator
  • If you don't mind, drop me an email at daniel@danielgary.net. I'm under NDA with Microsoft and am unable to further discuss my scenario on here.

    Thanks,

    Daniel

    Thursday, March 13, 2014 8:45 PM
  • Hi All,

    I still have the same problem with Pebble Watch. It was working fine  under WP8  and I started having issues when I upgraded to WP8.1. I temporarily solved the issue by unpairing the watch and pairing it again. But this needs to be done quite often (like everyday). Has anyone managed to find a solution?

    Kind Regads

    Ehad

    Thursday, August 7, 2014 10:39 PM