Reputation: 1814
I have a Windows 10 UWP app that I am using iBeacons for indoor geofencing using the RSSI.
So far, I am getting the RSSI, smoothing it using a Kalman filter and then calculating the distance in meters. This is working pretty well. With that, one could say that now all I have to do is create a threshold value in meters and say if my calculated distance is less than, I am inside the area and if greater than, I am outside. Well, I can do that and I am pretty confident it will work.
However, I noticed this class in the MSDN docs named:
BluetoothSignalStrengthFilter
It has some nice properties that appear to do what I want it to do such as inside and outside threshold along with a sampling period and a timeout. However, if I wanted to use this as an alternative to the approach I explained above, I am not sure how to use this filter.
I can instantiate the filter:
private BluetoothSignalStrengthFilter signalFilter = new BluetoothSignalStrengthFilter();
Then I can create my values (as constants for now during testing):
private const int BeaconInRangeThresh = -75; //The minimum RSSI value in dBm on which RSSI events will be propagated or considered in range.
private const int BeaconOutRangeThresh = -76; //The minimum RSSI value in dBm on which RSSI events will be considered out of range.
private const int SamplingInterval = 5; //The interval at which received signal strength indicator (RSSI) events are sampled.
private const int SamplingTimeout = 5; //Timeout in seconds
And finally, I can set those properties to the instantiated class like this:
signalFilter.InRangeThresholdInDBm = BeaconInRangeThresh;
And so on for the other properties.
The problem is, those four properties are the only thing this class has available, there are not methods or events or anything. So, how do I use this class? I get an event raised each time I receive a new Bluetooth advertisement, do I put this in there? Even if I set all of the properties then what?
Thanks!
Upvotes: 1
Views: 826
Reputation: 9700
As @Furmek points out, you can use BluetoothLEAdvertisementWatcher
to receive Bluetooth advertisement. You can configure the signal strength filter to only propagate events when in-range usig BluetoothLEAdvertisementWatcher.SignalStrengthFilter
. You can register Received
event in order to get an event raised each time I receive a new Bluetooth advertisement.
// Create and initialize a new watcher instance.
watcher = new BluetoothLEAdvertisementWatcher();
...
//Configure the signal strength filter.
watcher.SignalStrengthFilter.InRangeThresholdInDBm = -70;
watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -75;
...
// Attach a handler to process the received advertisement.
watcher.Received += OnAdvertisementReceived;
For more information you can reference Bluetooth advertisement sample.
Upvotes: 2