본문 바로가기
.NET

BTLE SignalStrength 확인 방법

by leo21c 2025. 2. 20.

Bluetooth Low Energy Sample Code

https://mydevnote.tistory.com/329

 

Bluetooth Low Energy(BT LE) Sample Code

Bluetooth 통신 요청을 받아서 개발을 검토 했고 초기 개발을 완료해서 테스트 해보니 장치가 내가 생각했던 것이 아니었다. 내가 개발한 것은 Bluetooth Classic 방식 이었던 것이다. 요즘 스마트폰이

mydevnote.tistory.com

 

위에서 제공하는 코드를 참조해서 개발을 하다가 SignalStrength(신호 강도) 확인 요청을 받았다.

아래 클래스에서 DeviceInformation 객체를 통해 Id, Name, IsPaired 등의 정보를 확인 할 수가 있다.

그러나 SignalStrength는 없었다.

public class BluetoothLEDeviceDisplay : INotifyPropertyChanged

 

그래서 SignalStrength를 확인 하는 방법은 아래와 같이 DeviceInformation.Properties를 이용하면 된다.

기존 코드를 보면 DeviceInformation.Properties를 아래와 같이 사용을 하고 있다.

public bool IsConnected => (bool?)DeviceInformation.Properties["Systehttp://m.Devices.Aep.IsConnected"] == true;
public bool IsConnectable => (bool?)DeviceInformation.Properties["Systehttp://m.Devices.Aep.Bluetooth.Le.IsConnectable"] == true;

 

https://learn.microsoft.com/ko-kr/windows/win32/properties/props-system-devices-aep-signalstrength

 

System.Devices.Aep.SignalStrength - Win32 apps

디바이스의 신호 강도입니다. 일부 프로토콜에만 적용됩니다.

learn.microsoft.com

 

같은 방식으로 처리는 하지 못하고 아래와 같은 방식으로 SignalStrength을 확인 했다.

 

/// <summary>
///     Display class used to represent a BluetoothLEDevice in the Device list
/// </summary>
public class BluetoothLEDeviceDisplay : INotifyPropertyChanged
{
    public BluetoothLEDeviceDisplay(DeviceInformation deviceInfoIn)
    {
        DeviceInformation = deviceInfoIn;

        var val = DeviceInformation.Properties["System.Devices.Aep.SignalStrength"];
        if (val != null)
        {
            SignalStrength = (int)val;
        }

        UpdateGlyphBitmapImage();
    }
    
    public DeviceInformation DeviceInformation { get; private set; }

    public string Id => DeviceInformation.Id;
    public string Name => DeviceInformation.Name;
    public bool IsPaired => DeviceInformation.Pairing.IsPaired;
    public bool IsConnected => (bool?)DeviceInformation.Properties["System.Devices.Aep.IsConnected"] == true;
    public bool IsConnectable => (bool?)DeviceInformation.Properties["System.Devices.Aep.Bluetooth.Le.IsConnectable"] == true;
    public int SignalStrength { get; set; }

    public IReadOnlyDictionary<string, object> Properties => DeviceInformation.Properties;
LIST