Setting proper SDP bluetooth parameters in Universal app? RRS feed

  • Question

  • I'm developing a Universal app which should receive data from device by bluetooth through Rfcomm protocol.

    Device uses SDP, SPP protocols. For proper discovering I have to set appropriate ServiceName and COD Filter(I think that it is unnecessary).

    So my question is: How to set appropriate Service Name as SDP Parameter?

    protected const byte SdpServiceNameAttributeType = 0x4;
    protected const UInt16 SdpServiceNameAttributeId = 0x0;
    public async Task Start()
                    if (rfcommProvider == null)
                        rfcommProvider = await RfcommServiceProvider.CreateAsync(
                    if (rfcommProvider != null)
                        if (socketListener != null)
                            socketListener = null;
                        // Create a listener for this service and start listening
                        socketListener = new StreamSocketListener();
                        socketListener.ConnectionReceived += OnConnectionReceived;
                        await socketListener.BindServiceNameAsync(rfcommProvider.ServiceId.AsString(),
                        // Set the SDP attributes and start Bluetooth advertising
                        DataWriter sdpWriter = new DataWriter();
                        //Write the Service Name Attribute.
                        // The length of the UTF-8 encoded Service Name SDP Attribute.
                        // The UTF-8 encoded Service Name value.
                        sdpWriter.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;
                        // Set the SDP Attribute on the RFCOMM Service Provider.
                        if (rfcommProvider.SdpRawAttributes.ContainsKey(SdpServiceNameAttributeId))
                        rfcommProvider.SdpRawAttributes.Add(SdpServiceNameAttributeId, sdpWriter.DetachBuffer());
                        // Start Bluetooth advertising
                catch (Exception e)
                    System.Diagnostics.Debug.WriteLine( "ERROR: " + e.Message);

    I found a nice presentation about SDP. Unfortunately, when I set :

    SdpServiceNameAttributeType = 0x4;
    SdpServiceNameAttributeId = 0x0;
    I get the exception from rfcommProvider.StartAdvertising(socketListener) : "Exception from HRESULT: 0xD000000D"
    Saturday, July 12, 2014 10:23 PM

All replies

  • I've asked our Bluetooth team to check this out.

    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.

    Monday, July 14, 2014 7:18 PM
  • Thank you very much, please let me know if there are any news.
    Wednesday, July 16, 2014 9:43 AM