【问题标题】:c# uwp reading more than one value (BLE)c# uwp 读取多个值(BLE)
【发布时间】:2018-05-27 01:23:17
【问题描述】:
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 设置了一个 mpu6050。所以它应该读取 x 、 y 、 z 值。但是,就我而言,它只读取“z”值。如何让它读取所有三个值?

在我的 c# 中:(只读取 z 值)

在我的 arduino 中:

【问题讨论】:

    标签: c# uwp bluetooth-lowenergy


    【解决方案1】:

    看起来问题出在 FormatValueByPresentation 中。以字节数组形式返回的值,函数将其简单格式化为 int 或 float。

    首先检查您的特色演示格式。然后检查返回值长度。

    之后就可以修复你的代码了。

    【讨论】:

    • 感谢您的建议。我真的是 c# 新手,我需要有人指导我如何解决这个问题。
    • 简单尝试将characteristic读取为原始值并检查其长度。
    • Mike,你有时间慢慢指导我一步一步解决这个问题吗?有什么可以联系你的吗?
    • 在哪里检查它的长度?
    • Skype:mike.petrichenko
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-24
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    相关资源
    最近更新 更多