Код: Выделить всё
bthservВот мой код: < /p>
Код: Выделить всё
int retryCount = 5;
DeviceInformation deviceInfo = null;
// Sometimes Windows loses track of the services! We may need to refresh them - can sometimes take a few retries.
while (deviceInfo == null && retryCount-- > 0)
{
// after switching devices this call usually returns an empty set even though I have successfully paired the second device with the same service.
var allDeviceInfos = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(MyServiceId));
deviceInfo = allDeviceInfos.FirstOrDefault(d => d.Name == device.DeviceInformation.Name);
if (deviceInfo == null)
{
_logger.LogDebug("Device not found! Retrying...");
await RefreshServices();
Thread.Sleep(1000);
}
}
< /code>
....
private async Task RefreshServices()
{
_logger.LogDebug("Refreshing the device's service list.");
var devices = await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelector());
var myDevices = new List();
foreach (var device in devices.Where(d => d.Name.StartsWith("MyDeviceName_")))
{
var bleDevice = await BluetoothLEDevice.FromIdAsync(device.Id);
// after switching devices, the application hangs on the following line and never returns a value.
var services = await bleDevice.GetGattServicesAsync();
_logger.LogDebug($"Service list from {wristOx.Name}: Status: {services.Status}, count: {services.Services?.Count}");
}
}
- Я также попробовал с GetGattServicesAsync (bluetoothmode.uncached) < /code>, но получить тот же результат. < /li>
Я попытался перезагрузить свой компьютер, но, похоже, это не выходит из GetGattServicesAsync () из своего торпора! Это действительно странно - убийство процесса «исправляет» его, но перезапуск компьютера не делает! 0 Устройства, последующий вызов к DeviceInformation.findallasync (bluetoothledevice.getDeviceselector ()) Возвращает некоторые устройства, включая мой один!
Как запрошено, что я попытался получить журналы Bluetooth с помощью WPR и ссылки, предоставленной Junjie Zhu - MSFT, и я сейчас трачу время, чтобы уйти Через график «общие события», который является единственным с любой информацией в нем. Однако я не совсем уверен в том, как сопоставить подвес с событиями на этом графике, и здесь слишком много информации, чтобы вставить его здесь. < /P>
e.g. Я нашел этот раздел «Bluetooth», но сужение правильных событий для просмотра и интерпретации результатов - это сложная часть. < /P>
Интересно, что WPA сбои каждый раз, когда я пытаюсь просматривать RadiodiAgnostictlvverbose ... Это ArgirgyOutOfRangeException
Другое редактирование
Как запрошено, вот журналы из WPR. (21 МБ каждый)
Отказ - это показывает, когда он сбой - т.е. я получаю 0 устройств от DeviceInformation.findallasync (gattdeviceservice.getDeviceseLectorFromuuid (myServiceId)) затем getGattServicesAsync ()
Подробнее здесь: https://stackoverflow.com/questions/793 ... -same-serv
Мобильная версия