不知道我完全理解你的問題,但是對於藍牙低功耗設備,我在UWP應用程序中做了類似以下C#的事情。
using System;
using Windows.Devices.Bluetooth.Advertisement;
namespace WindowsIoTCorePi2FezHat
{
internal class BleTagWatcher
{
private ulong tagNo;
private BluetoothLEAdvertisementWatcher watcher;
private const short OutOfRange = -127;
private short rssi;
private DateTime lastDetected;
public BleTagWatcher(ulong v)
{
this.tagNo = v;
Rssi = OutOfRange;
watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += OnAdvertisementReceipt;
watcher.Stopped += (s, a) => { Rssi = OutOfRange; };
watcher.Start();
}
private void OnAdvertisementReceipt(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
if (args.BluetoothAddress == tagNo)
Rssi = args.RawSignalStrengthInDBm;
}
public short Rssi
{
get
{
//if (lastDetected.AddSeconds(20) < DateTime.Now)
// return OutOfRange;
return rssi;
}
set
{
rssi = value;
lastDetected = DateTime.Now;
}
}
}
}
當然您可以從設備廣告中獲得更多信息。不僅僅是信號強度。
對於使用Windows 10 IoT核心的Raspberry Pi 3運行的信息。
希望這能給你一點指導。