Hi Gordon ,
I was able to get all the data from puck using the advertising example of Microsoft.
Microsoft provides a class BluetoothLEManufacturerData were you can get the CompanyId and the data. To make Microsoft's example to work I had to comment all the filters(this class takes filters to limit the bluetooth devices) and that resulted to return me everything..
The thing is that I want to limit (add filter) the number of devices and read only the puck devices.
I was wondering how to do that.
The class has a CompanyID property and the Data. When you put the CompanyID as a filter the watcher reads only this device. Take a look at the below code .
// Begin of watcher configuration. Configure the advertisement filter to look for the data advertised by the publisher
// in Scenario 2 or 4. You need to run Scenario 2 on another Windows platform within proximity of this one for Scenario 1 to
// take effect. The APIs shown in this Scenario are designed to operate only if the App is in the foreground. For background
// watcher operation, please refer to Scenario 3.
// Please comment out this following section (watcher configuration) if you want to remove all filters. By not specifying
// any filters, all advertisements received will be notified to the App through the event handler. You should comment out the following
// section if you do not have another Windows platform to run Scenario 2 alongside Scenario 1 or if you want to scan for
// all LE advertisements around you.
// For determining the filter restrictions programatically across APIs, use the following properties:
// MinSamplingInterval, MaxSamplingInterval, MinOutOfRangeTimeout, MaxOutOfRangeTimeout
// Part 1A: Configuring the advertisement filter to watch for a particular advertisement payload
// First, let create a manufacturer data section we wanted to match for. These are the same as the one
// created in Scenario 2 and 4.
var manufacturerData = new BluetoothLEManufacturerData();
// Then, set the company ID for the manufacturer data. Here we picked an unused value: 0xFFFE
**manufacturerData.CompanyId = 0xFFFE;**
// Finally set the data payload within the manufacturer-specific section
// Here, use a 16-bit UUID: 0x1234 -> {0x34, 0x12} (little-endian)
var writer = new DataWriter();
writer.WriteUInt16(0x1234);
// Make sure that the buffer length can fit within an advertisement payload. Otherwise you will get an exception.
manufacturerData.Data = writer.DetachBuffer();
// Add the manufacturer data to the advertisement filter on the watcher:
watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData);
// Part 1B: Configuring the signal strength filter for proximity scenarios
// Configure the signal strength filter to only propagate events when in-range
// Please adjust these values if you cannot receive any advertisement
// Set the in-range threshold to -70dBm. This means advertisements with RSSI >= -70dBm
// will start to be considered "in-range".
watcher.SignalStrengthFilter.InRangeThresholdInDBm = -70;
// Set the out-of-range threshold to -75dBm (give some buffer). Used in conjunction with OutOfRangeTimeout
// to determine when an advertisement is no longer considered "in-range"
watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -75;
// Set the out-of-range timeout to be 2 seconds. Used in conjunction with OutOfRangeThresholdInDBm
// to determine when an advertisement is no longer considered "in-range"
watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(2000);
// By default, the sampling interval is set to zero, which means there is no sampling and all
// the advertisement received is returned in the Received event
// End of watcher configuration. There is no need to comment out any code beyond this point.
The example puts a value manufacturerData.CompanyId = 0xFFFE;
In our case with the Puck device what should I put in order to tell the watcher to read only the puck.js?
Is this value changes everytime ?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi Gordon ,
I was able to get all the data from puck using the advertising example of Microsoft.
Microsoft provides a class BluetoothLEManufacturerData were you can get the CompanyId and the data. To make Microsoft's example to work I had to comment all the filters(this class takes filters to limit the bluetooth devices) and that resulted to return me everything..
https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.advertisement.bluetoothlemanufacturerdata?f=255&MSPPError=-2147217396
The thing is that I want to limit (add filter) the number of devices and read only the puck devices.
I was wondering how to do that.
The class has a CompanyID property and the Data. When you put the CompanyID as a filter the watcher reads only this device. Take a look at the below code .
The example puts a value manufacturerData.CompanyId = 0xFFFE;
In our case with the Puck device what should I put in order to tell the watcher to read only the puck.js?
Is this value changes everytime ?
Appreciate your guidance on this.
thank you