Windows 10蓝牙Gatt客户端ValueChanged问题 [英] Windows 10 Bluetooth Gatt Client ValueChanged issue

查看:91
本文介绍了Windows 10蓝牙Gatt客户端ValueChanged问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此刻,我在Bluetooth Gatt特性读取方面遇到问题.我试图用自己的自定义配置文件运行代码

I'm having an issue with Bluetooth Gatt characteristic reading at the moment. I was trying to run the code with my own custom profile

thermometerCharacteristic.ValueChanged += temperatureMeasurementChanged;

它导致此异常

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

An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll but was not handled in user code

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

Additional information: Value does not fall within the expected range.

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

My function arguments looks like this

void temperatureMeasurementChanged(GattCharacteristic sender, GattValueChangedEventArgs eventArgs)

此代码类似于在MSDN上检索Bluetooth LE数据的示例.关于什么可能导致此的任何想法?非常感谢!

This code resembles the sample to retrieve Bluetooth LE data on MSDN. Any ideas on what could cause this? Thanks so much!

推荐答案

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);
        }

这篇关于Windows 10蓝牙Gatt客户端ValueChanged问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆