Raspberry pi 在后台应用程序中使用BluetoothLEAdvertisementWatcher?
我尝试扫描运行在Raspberry PI 3上的Windows 10 IOT后台(无头)应用程序中的BLE设备 我还尝试在同一台RaspBerry PI机器上的Head应用程序(带UI)中使用BluetoothLEAdvertisementWatcher,结果成功了 我的无头应用程序是最简单的:Raspberry pi 在后台应用程序中使用BluetoothLEAdvertisementWatcher?,raspberry-pi,windows-10-iot-core,Raspberry Pi,Windows 10 Iot Core,我尝试扫描运行在Raspberry PI 3上的Windows 10 IOT后台(无头)应用程序中的BLE设备 我还尝试在同一台RaspBerry PI机器上的Head应用程序(带UI)中使用BluetoothLEAdvertisementWatcher,结果成功了 我的无头应用程序是最简单的: public sealed class StartupTask : IBackgroundTask { private readonly BluetoothLEAdvertisementWatc
public sealed class StartupTask : IBackgroundTask
{
private readonly BluetoothLEAdvertisementWatcher _bleWatcher =
new BluetoothLEAdvertisementWatcher();
public void Run(IBackgroundTaskInstance taskInstance)
{
_bleWatcher.Received += _bleWatcher_Received;
_bleWatcher.ScanningMode = BluetoothLEScanningMode.Active;
_bleWatcher.Start();
}
private void _bleWatcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
}
}
_收到的bleWatcher_从未命中。已设置功能(蓝牙、互联网、近距离)
有什么问题?我错过了什么?当run方法完成时,您的应用程序将关闭。这就是为什么收到的
\u bleWatcher\u
永远不会被击中的原因
要阻止你的应用退出,你需要像这样调用“getDeleral”方法:
public void Run(IBackgroundTaskInstance taskInstance)
{
deferral = taskInstance.GetDeferral();
//YOUR CODE HERE
}
有关更多信息,请参考“”。您能更清楚一点吗?谢谢Joe。你是什么意思?你是在rPi上还是在另一台机器上使用了标题应用程序?请在同一台机器上更具体地说明。我更新了我的问题。