BluetoothGATTGetCharacteristicValue function does not work RRS feed

  • Question

  • Hello All,

    I'm working on a development with a Nordic device and Win 8. I created a custom service for our data. Our characteristic value is 6 bytes long.

    I'm able to open a connection to the BLE device and subscribe to the notification or indication and receive characteristic value updates via a callback.

    The problem is that I have a requirement for the Win 8.1 app that needs to be able to READ the characteristic value using BluetoothGATTGetCharacteristicValue function. I'm unable to make it work I keep getting error 0x80650002 "The attribute cannot be read.".

    I'm a little confused about the handle. 

    my service UUID is {00001523-1212-EFDE-1523-785FEABCD123}

    my characteristic UUID is {00001524-1212-EFDE-1523-785FEABCD123}

    I successfully get a handle to my device using the service UUID. I don't use characteristic UUID to get the value I don't think I need it but I admit I must say I tried to get a handle to the characteristic UUID and Win 8 returned a null pointer.

    This is the code that is failing:

    if (m_PrimaryServiceCharacteristic.IsReadable)
    // Determine Characteristic Value Buffer Size
    printf("BluetoothGATTGetCharacteristicsValue retrieve value size...\r\n");

    hr = BluetoothGATTGetCharacteristicValue(
    m_hDeviceHandle,                        //<<==============Obtained from Service UUID
    &m_PrimaryServiceCharacteristic, //<<======Obtained from BluetoothGATTGetCharacteristics

    PrintHr("BluetoothGATTGetCharacteristicValue - NOT ERROR_MORE_DATA ?!\r\n");

    if (FAILED(hr))
    printf("Error: BluetoothGATTGetCharacteristicsValue Buffer Size failed!!! 0x%4x\r\n", hr);

    if (CharacteristicsDataSize != 6)
    printf("Error: BluetoothGATTGetCharacteristicsValue size mismatch! size: %d expected: 6\r\n", CharacteristicsDataSize);
    printf("warning: characteristic is not readable!\r\n");

    Any ideas or suggestions are greatly appreciated? Thanks for checking my discussion.

    Below are my traces:

    Get handle to {00001523-1212-EFDE-1523-785FEABCD123}
    BLE device found...
    get number of services
    BLE services count 1
    retrieve services
    Service UUID = {00001523-1212-EFDE-1523-785FEABCD123}
    Services listed...
    get characteristics count
    number of characterisitics 1
    malloc: 36 bytes
    reset characteristics buffer...
    BluetoothGATTGetCharacteristics success
    Characteristic UUID = {00001524-1212-EFDE-1523-785FEABCD123}
    BluetoothGATTGetDescriptors size...
    malloc for the descriptors buffer.
    BluetoothGATTGetDescriptors retrieve the descriptors.
    Loop through the list of descriptors...
    Found ClientConfigDesc!
    BluetoothGATTGetCharacteristicsValue retrieve value size...
    BluetoothGATTGetCharacteristicValue - NOT ERROR_MORE_DATA ?!
    Error: BluetoothGATTGetCharacteristicsValue Buffer Size failed!!! 0x80650002
    Error: BluetoothGATTGetCharacteristicsValue size mismatch! size: 0 expected: 6
    BluetoothGATTGetCharacteristicsValue get value...0
    BluetoothGATTGetCharacteristicsValue failed!!! 0x80650002

    Thursday, August 28, 2014 4:37 PM