BLE Scan Interval Windows 10

后端 未结 3 1302
情歌与酒
情歌与酒 2020-12-05 09:03

Is there any way to adjust the BLE advertisement scanning interval on Windows 10 when using Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcher

3条回答
  •  独厮守ぢ
    2020-12-05 09:37

    for Windows Universal App try to change StartScanner as following:

    public static void StartScanner(int scanType, ushort scanInterval, ushort scanWindow) {
    
        Action action = (object obj) => {
            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);
        };
        Task task = new Task(action,"nothing");
        task.Start();
    }
    
        

    提交回复
    热议问题