Windows 10 Bluetooth Gatt Client ValueChanged问题

时间:2015-06-22 15:10:53

标签: windows bluetooth bluetooth-lowenergy win-universal-app gatt

我现在遇到蓝牙Gatt特征读数问题。我试图用自己的自定义配置文件运行代码

thermometerCharacteristic.ValueChanged += temperatureMeasurementChanged;

导致此异常

mscorlib.ni.dll中发生了'System.ArgumentException'类型的异常,但未在用户代码中处理

其他信息:价值不在预期范围内。

我的函数参数看起来像这样

void temperatureMeasurementChanged(GattCharacteristic sender, GattValueChangedEventArgs eventArgs)

此代码类似于在MSDN上检索蓝牙LE数据的示例。有什么可能导致这个问题的想法?非常感谢!

1 个答案:

答案 0 :(得分:3)

Check for thermometerCharacteristic.CharacteristicProperties == (GattCharacteristicProperties.Read | GattCharacteristicProperties.Notify)
订阅前

     if (characteristic.CharacteristicProperties == (GattCharacteristicProperties.Read | GattCharacteristicProperties.Notify))
        {
            characteristic.ValueChanged += Characteristic_ValueChanged;

            GattCommunicationStatus status =
                       await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(
                       CHARACTERISTIC_NOTIFICATION_TYPE);
        }