This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

blePending - CC2640

Hi

After returning blePending to the ReadCallBack function, I get Timeout error  and all Read/Write operations get Abort error!

Before returning blePending all Reads/Writes are working Ok.

I need to compute a value before sending it back that is why I'm using blePending and after the value is computed I use ATT_ReadRsp to return it .

What is the reason for the Timeout error and why all other reads / writes are now return Abort error?

Kind regards, Bitkiller.

  • Hi Bitkiller,

    Can you share how you & where you are calling ATT_ReadRsp? Is this from the application task context that is registered with ICall? Do you encounter any errors calling ATT_ReadRsp? Also, you need to make the Read Rsp call within 30 secs after initially receiving the Read Request from the client.

    Best wishes
  • Hi JXS,

    After I return blePending and posting App semaphore, I perform read (using UART) value from other MCU.
    Then I'm calling ATT_ReadRsp inside Uart_Read_CallBack function.

    the result of ATT_ReadRsp function is 0x02 which means INVALIDPARAMETER

    I call the function this way:


    bStatus_t StatusReply(uint32_t ulSTATReg ,uint32_t StatReg, uint32_t ulTimeStamp)
    {
    volatile bStatus_t stat1;
    uint8_t dat[20] = {0};

    attReadRsp_t msg1;
    msg1.len = 20;

    memcpy((void*)dat, &ulSTATReg, 4);
    memcpy((void*)&dat[4], &StatReg, 4);
    memcpy((void*)&dat[8], &ulTimeStamp, 4);

    msg1.pValue = dat;

    stat1 = ATT_ReadRsp(getCurrentConnectionHandle(), &msg1);

    return stat1;
    }
  • Hi Bitkiller,

    Thanks for sharing. I see a couple of issues that were not apparent from your original description. First, you need to use GATT_bm_alloc to reserve the memory, and second, I'm not sure about sending the response from the callback function (SWI context?) - bad things could happen down the road. As per guidance in the BLE SW Dev Guide, making stack API calls from callbacks should not be performed.

    A proper example for using ATT_ReadRsp is in the SimpleNP reference project; see the implementation SimpleNP_GATT.c. I apologize for not directing you to this example sooner. Note that as shown in the example, GATT_bm_free is only called when there is an error!

    I'm confident that after implementing the above suggestions, the delayed read response will work in your implementation. Again, thanks for sharing your code snippet.

    Best wishes
  • Thank you very much :)