我现在遇到蓝牙Gatt特征读数问题。我试图用自己的自定义配置文件运行代码
thermometerCharacteristic.ValueChanged += temperatureMeasurementChanged;
导致此异常
mscorlib.ni.dll中发生了'System.ArgumentException'类型的异常,但未在用户代码中处理
其他信息:价值不在预期范围内。
我的函数参数看起来像这样
void temperatureMeasurementChanged(GattCharacteristic sender, GattValueChangedEventArgs eventArgs)
此代码类似于在MSDN上检索蓝牙LE数据的示例。有什么可能导致这个问题的想法?非常感谢!
答案 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);
}