I do not think.
Scan parameters are hardcoded up to a scan interval of 118.125 ms and a scan window of 18.125 ms.
That's why you get only 1/7 of all packages (from 18.125 / 118.125 is ~ 1/7).
DeviceIoControl . . BluetoothLEAdvertiseWatcher (, BetterScanner.StartScanner(0, 29, 29)). , Windows "" , .
DeviceIoControl , . , io, CancelIoEx. , .
using System;
using System.Runtime.InteropServices;
using System.Threading;
class BetterScanner {
[StructLayout(LayoutKind.Sequential)]
private struct BLUETOOTH_FIND_RADIO_PARAM
{
internal UInt32 dwSize;
internal void Initialize()
{
this.dwSize = (UInt32)Marshal.SizeOf(typeof(BLUETOOTH_FIND_RADIO_PARAM));
}
}
[DllImport("Kernel32.dll", SetLastError = true)]
static extern bool CloseHandle(IntPtr handle);
[DllImport("irprops.cpl", SetLastError = true)]
static extern IntPtr BluetoothFindFirstRadio(ref BLUETOOTH_FIND_RADIO_PARAM pbtfrp, out IntPtr phRadio);
[StructLayout(LayoutKind.Sequential)]
private struct LE_SCAN_REQUEST
{
internal int scanType;
internal ushort scanInterval;
internal ushort scanWindow;
}
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)]
static extern bool DeviceIoControl(IntPtr hDevice, uint dwIoControlCode,
ref LE_SCAN_REQUEST lpInBuffer, uint nInBufferSize,
IntPtr lpOutBuffer, uint nOutBufferSize,
out uint lpBytesReturned, IntPtr lpOverlapped);
public static void StartScanner(int scanType, ushort scanInterval, ushort scanWindow)
{
var thread = new Thread(() =>
{
BLUETOOTH_FIND_RADIO_PARAM param = new BLUETOOTH_FIND_RADIO_PARAM();
param.Initialize();
IntPtr handle;
BluetoothFindFirstRadio(ref param, out handle);
uint outsize;
LE_SCAN_REQUEST req = new LE_SCAN_REQUEST { scanType = scanType, scanInterval = scanInterval, scanWindow = scanWindow };
DeviceIoControl(handle, 0x41118c, ref req, 8, IntPtr.Zero, 0, out outsize, IntPtr.Zero);
});
thread.Start();
}
}