locked
Bluetooth Signal Strength in Windows Phone 8.1 RRS feed

  • Question

  • I have lost a bluetooth device and I want to find it via its signal strength.

    Where are the APIs to get the RSS for Bluetooth and Bluetooth LE devices? For LE devices I can query a supported GATT service where the rtt time is a good indicator how close I am.

    But for "regular" bluetooth devices I need to connect to via a StreamSocket which gives me more or less random numbers where I cannot really find anything.Currently I am using this approach:

            public async void Search()
            {
                while (true && !Model.IsCancellationActive)
                {
                    Model.DeviceStatus = Device.ConnectionStatus.ToString();
                    using (StreamSocket socket = new StreamSocket())
                    {
                        socket.Control.QualityOfService = SocketQualityOfService.LowLatency;
                        var sw = Stopwatch.StartNew();
                        string status = "";
                        try
                        {
                            await socket.ConnectAsync(Device.HostName, "1");
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                            status = "Denied Exception";
                        }
                        catch (Exception ex)
                        {
                            status = "Other Exception";
                        }
                        sw.Stop();
                        Model.AddToList(String.Format("Got reply in {0:F2}s, Status: {1}", sw.Elapsed.TotalSeconds, status), sw.Elapsed.TotalSeconds);
                    }
                }
    
                Model.IsCancellationActive = false;
            }
        }

    But this does not give me reliable numers at all. Using the best or worst times is of no help either. Also more advanced statistical things like median value or calcualating a stable median by removing the high rtt outliers did also not help.

    Is there a way to get from the socket connect failure time a similar metric to RSS or where are the RSS values hidden? Unmanged code would also do it. I find it rather frustrating that for Windows Phone it is still not possible to implement a simple Bluetooth signal strength display. The data is there but not the APIs. Are there some IOCTL commands necessary to get the required infos?

    Sunday, January 11, 2015 9:59 AM

All replies