Я пытаюсь создать простое приложение UWP, которое отображает значение, считываемое с пульсометра (Wahoo TICKR FIT). Я могу подключиться к монитору, но не могу получить доступ к значению характеристики HeartRateMeasurement. GattReadResult имеет статус ProtocolError и значение null. Как я могу исправить ProtocolError?
Это все в простом приложении UWP, использующем шаблон Visual Studio 2017. Затем планируется перенести рабочий код в проект HoloLens.
Вот код:
string btAddr = "F013C3B15603";
System.UInt64 addrInt = Convert.ToUInt64(btAddr, 16);
BluetoothLEDevice device = await BluetoothLEDevice.FromBluetoothAddressAsync(addrInt);
string guidString = "0000180d-0000-1000-8000-00805f9b34fb"; // Armband HeartRate uuid
Guid guid = new Guid(guidString);
GattDeviceService gattService = device.GetGattService(guid);
// Try to access the characteristic we want
DeviceAccessStatus serviceAccessStatus = await gattService.RequestAccessAsync(); // allowed
GattOpenStatus openStatus = await gattService.OpenAsync(GattSharingMode.SharedReadAndWrite); // success
GattCharacteristicsResult results = await gattService.GetCharacteristicsAsync();
IReadOnlyList<GattCharacteristic> charList = results.Characteristics;
Debug.WriteLine(charList.Count); // should be 2
GattCharacteristic heartRateChar = charList[0];
Debug.WriteLine(heartRateChar.AttributeHandle); // should be 15
// Try to pull the heart rate data
GattCommunicationStatus commStatus = await heartRateChar.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify); // This works
GattReadResult heartRateResult = await heartRateChar.ReadValueAsync(BluetoothCacheMode.Uncached); // Status is ProtocolError (2)
Проблема появляется в самом конце, при вызове ReadValueAsync.