BLE 值_变化

private async void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)

        {

            // BT_Code: An Indicate or Notify reported that the value has changed.

            // Display the new value with a timestamp.

            var newValue = FormatValueByPresentation(args.CharacteristicValue, presentationFormat);

            var message = $"Value at {DateTime.Now:hh:mm:ss}: {newValue}";

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,

                () => CharacteristicLatestValue.Text = message);

        }

这是值更改的设置。^


 private async void CharacteristicReadButton_Click()

        {

             // BT_Code: Read the actual value from the device by using Uncached.

            GattReadResult result = await selectedCharacteristic.ReadValueAsync(BluetoothCacheMode.Uncached);

            if (result.Status == GattCommunicationStatus.Success)

            {

                string formattedResult = FormatValueByPresentation(result.Value, presentationFormat);


                rootPage.NotifyUser($"Read result: {formattedResult}", NotifyType.StatusMessage);

            }

            else

            {

                rootPage.NotifyUser($"Read failed: {result.Status}", NotifyType.ErrorMessage);

            }     



        }

这是读取值的设置。所以当我点击“阅读”按钮时。它捕获当时的数据。但是我希望在值更改时刷新此数据,因此我订阅了值更改。现在的问题是,在我点击订阅后,它说的是“未知格式”。所以我需要弄清楚如何更改我的格式以读取我的 rfduino 值。


达令说
浏览 316回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP