Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
蓝牙LE服务对C#Windows应用商店应用程序中的已知特征不返回任何内容?_C#_Bluetooth_Windows Store Apps_Characteristics - Fatal编程技术网

蓝牙LE服务对C#Windows应用商店应用程序中的已知特征不返回任何内容?

蓝牙LE服务对C#Windows应用商店应用程序中的已知特征不返回任何内容?,c#,bluetooth,windows-store-apps,characteristics,C#,Bluetooth,Windows Store Apps,Characteristics,我有一个C#Windows应用商店应用程序,可以与定制的蓝牙低能设备接口。我能够枚举设备,连接到它,成功发送验证密钥,并获得设备加速计的特性。但是,当我尝试获取X轴特征的特征时,服务的GetCharacteristics()枚举器返回一个空列表。我的包清单中明确声明了X轴特征的UUID。我读过设备上的论坛,所以我知道Android用户可以访问它。但由于某种原因我不能 有人遇到过这个问题并且知道如何解决吗 这是我的舱单声明: <!-- V.BTTN Accelerometer con

我有一个C#Windows应用商店应用程序,可以与定制的蓝牙低能设备接口。我能够枚举设备,连接到它,成功发送验证密钥,并获得设备加速计的特性。但是,当我尝试获取X轴特征的特征时,服务的GetCharacteristics()枚举器返回一个空列表。我的包清单中明确声明了X轴特征的UUID。我读过设备上的论坛,所以我知道Android用户可以访问它。但由于某种原因我不能

有人遇到过这个问题并且知道如何解决吗

这是我的舱单声明:

    <!-- V.BTTN Accelerometer configuration characteristic -->
    <m2:Function Type="serviceId:fffffff2-00f7-4000-b000-000000000000" />

    <!-- V.BTTN Accelerometer X-Axis notification characteristic -->
    <m2:Function Type="serviceId:ffffffA3-00f7-4000-b000-000000000000" />
    <!-- V.BTTN Accelerometer Y-Axis notification characteristic -->
    <m2:Function Type="serviceId:ffffffA4-00f7-4000-b000-000000000000" />
    <!-- V.BTTN Accelerometer Z-Axis notification characteristic -->
    <m2:Function Type="serviceId:ffffffA5-00f7-4000-b000-000000000000" />

下面是我访问主加速计配置特性并尝试获取X轴特性的代码:

    // <!-- V.BTTN Accelerometer X-Axis notification characteristic -->
    public static Guid vbttnAccelerometerXAxisNotify_uuid = new Guid("ffffffA3-00f7-4000-b000-000000000000");

    // <!-- V.BTTN Accelerometer Y-Axis notification characteristic -->
    public static Guid vbttnAccelerometerYAxisNotify_uuid = new Guid("ffffffA4-00f7-4000-b000-000000000000");

    // <!-- V.BTTN Accelerometer Z-Axis notification characteristic -->
    public static Guid vbttnAccelerometerZAxisNotify_uuid = new Guid("ffffffA5-00f7-4000-b000-000000000000");


    private GattCharacteristic GetCharacteristicByIdAndNdx(Guid characteristicUuid, int ndx = 0)
    {
        if (characteristicUuid == Guid.Empty)
            throw new ArgumentNullException("The characteristic ID is empty.");

        if (ndx < 0)
            throw new ArgumentOutOfRangeException("The characteristic is negative.");

        // Obtain the accelerometer configuration characteristic.
        IReadOnlyList<GattCharacteristic> iroCharacteristics =
            VAlertService.Instance.Service.GetCharacteristics(characteristicUuid);

        if (iroCharacteristics.Count < 1)
            throw new InvalidOperationException("Unable to find the V.ALRT characteristic with the given UUID and index.");

        if (ndx >= iroCharacteristics.Count)
            throw new InvalidOperationException("Found the desired V.ALRT characteristic but the index is out of range.");

        return iroCharacteristics[ndx];
    }

            // < snip >
            // Obtain the accelerometer configuration characteristic.
            this._accelerometerConfigCharacteristic = GetCharacteristicByIdAndNdx(vbttnAccelerometerConfigCharacteristic_uuid);

            // Enable the accelerometer.
            if (!(await this.SetAccelerometerMode(true)))
                throw new InvalidOperationException("Unable to enable the V.ALRT accelerometer characteristic.");

            GattCharacteristic this._accelerometerXAxisCharacteristic = GetCharacteristicByIdAndNdx(vbttnAccelerometerXAxisNotify_uuid);
            GattCharacteristic this._accelerometerYAxisCharacteristic = GetCharacteristicByIdAndNdx(vbttnAccelerometerYAxisNotify_uuid);
            GattCharacteristic this._accelerometerZAxisCharacteristic = GetCharacteristicByIdAndNdx(vbttnAccelerometerZAxisNotify_uuid);
//
公共静态Guid VBTTnacellometerxaxisNotify_uuid=新Guid(“FFFFFF A3-00f7-4000-b000-000000000000”);
// 
公共静态Guid VBTTnacellometeryaxisNotify_uuid=新Guid(“FFFFFF A4-00f7-4000-b000-000000000000”);
// 
公共静态Guid VBTTnacellometerzaxisNotify_uuid=新Guid(“FFFFFF A5-00f7-4000-b000-000000000000”);
私有GattCharacteristic GetCharacteristicById和ndx(Guid characteristicUuid,int ndx=0)
{
if(characteristicUuid==Guid.Empty)
抛出新ArgumentNullException(“特征ID为空”);
如果(ndx<0)
抛出新ArgumentOutOfRangeException(“特征为负”);
//获取加速度计配置特性。
Iradonylist iroCharacteristics=
VAlertService.Instance.Service.GetCharacteristics(characteristicUuid);
if(iroCharacteristics.Count<1)
抛出新的InvalidOperationException(“无法找到具有给定UUID和索引的V.ALRT特征”);
如果(ndx>=iroCharacteristics.Count)
抛出新的InvalidOperationException(“找到所需的V.ALRT特征,但索引超出范围”);
返回特征[ndx];
}
//
//获取加速度计配置特性。
此._加速计配置特征=GetCharacteristicById和ndx(VBTTNacElectrometerConfigCharacteristic_uuid);
//启用加速计。
如果(!(等待此消息。SetAccelerometerMode(true)))
抛出新的InvalidOperationException(“无法启用V.ALRT加速计特性”);
GattCharacteristic this.\u加速计XaxisCharacteristic=GetCharacteristicByIdAndNdx(vbttnAccelerometerXAxisNotify\u uuid);
GattCharacteristic this.\u加速度计轴特性=GetCharacteristicByIdAndNdx(VBTTNacElectrometerYaxisNotify\u uuid);
GattCharacteristic this.\u加速计ZaxisCharacteristic=GetCharacteristicByIdAndNdx(VBTTnacellometerZaxisNotify\u uuid);

嘿,兄弟,我也在创建一个windows phone 8.1应用程序,我必须开发扫描设备的代码,你能帮我吗?罗伯特,如果你知道怎么做的话?我是这个平台的新手,我在这里呆了两天,没有得到任何支持,你能发布代码吗?