2

I have a C# Windows Store app that interfaces with a custom Bluetooth Low Energy device. I am able to enumerate the device, connect to it, send a verification key successfully, and get the characteristic for the device's accelerometer. However, when I try to get the characteristic for the X axis characteristic, the service's GetCharacteristics() enumerator returns an empty list. I definitely have the X axis characteristic's UUID declared in my package manifest. I've read the forums on the device so I know that Android users are able to access it. But for some reason I can't.

Has anybody run into this problem and knows how to fix it?

Here's my manifest declaration:

    <!-- 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" />

Here's the code where I access the main accelerometer configuration characteristic and try to get the X-axis characteristic:

    // <!-- 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);
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
  • hey brother, I am also creating a windows phone 8.1 application, I have to develop code for scanning BLE device can you help me? – Viraj Shah Jul 03 '14 at 11:56
  • Robert,if you know then how to do it? I am new in this platform,I stuck here for last two days and not getting support anywhere, can you post the code? – Viraj Shah Jul 03 '14 at 11:58

0 Answers0