什么触发了BLE C#代码中的ValueUpdated属性

什么触发了BLE C#代码中的ValueUpdated属性,c#,xamarin,bluetooth,bluetooth-lowenergy,C#,Xamarin,Bluetooth,Bluetooth Lowenergy,我正在构建一个Xamarin.Forms跨平台移动应用程序,该应用程序使用Bluetoth低能耗功能。我正在连接到一个基于mbed的实现 在Xamarin C#中,是什么触发了Monkey.Robotics中的特征ValueUpdated事件 这是我的C#基于的一个标准示例: if (characteristic.CanUpdate) { characteristic.ValueUpdated += (s, e) => {

我正在构建一个
Xamarin.Forms
跨平台移动应用程序,该应用程序使用Bluetoth低能耗功能。我正在连接到一个基于
mbed
的实现

在Xamarin C#中,是什么触发了Monkey.Robotics中的特征
ValueUpdated
事件

这是我的C#基于的一个标准示例:

if (characteristic.CanUpdate) {
                characteristic.ValueUpdated += (s, e) => {
                    Debug.WriteLine("characteristic.ValueUpdated");
                    Device.BeginInvokeOnMainThread( () => {
                        UpdateDisplay(characteristic);
                    });
                    IsBusy = false; // only spin until the first result is received
                };
                IsBusy = true;
                characteristic.StartUpdates();
            }
这一直在工作,但自从我更改为我自己的自定义GATT服务并连接到该服务后,ValueUpdated事件从未触发。这个事件是什么?它是如何触发的?这是从mbed设备设置的特征中读取的属性,还是移动端解决的问题

谢谢这是安卓系统的


你需要问问《猴子机器人学》的作者。假设它是开源的,您可以自己查看代码。您应该确保它正在调用
WriteClientCharacteristicConfigurationDescriptorAsync()
以启用通知作为开始,并且它已订阅
GattCharacteristic.ValueChanged
事件以接收通知。请注意,
ValueUpdated
不是一个属性,而是一个事件。“这两个很不一样。”彼得杜尼奥谢谢你的回答。我已经更新了这个问题,你说得很对,我已经更改了对事件的引用。这个插件确实是开源的,而且这个问题有一个指向github页面的链接。但是,我无法找到描述此事件的代码。那么,这是否意味着Characteristic.ID更改时触发ValueUpdate事件?不,当GattCallback类上的CharacteristicValueUpdate事件为firedhmmm时,会触发此事件,这是发射机广播的内容,还是手机广播的内容(作为寻回者),将值与历史值进行比较,以解决这个问题?阅读代码。我猜是发送器,但我对GATT一无所知
    this._gattCallback.CharacteristicValueUpdated += (object sender, CharacteristicReadEventArgs e) => {
            // it may be other characteristics, so we need to test
            if(e.Characteristic.ID == this.ID) {
                // update our underlying characteristic (this one will have a value)
                //TODO: is this necessary? probably the underlying reference is the same.
                //this._nativeCharacteristic = e.Characteristic;

                this.ValueUpdated (this, e);
            }
        };