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.

Read characteristic asynchronously

Other Parts Discussed in Thread: CC2640

Hi,

I have custom made device with CC2640 and host MCU, I have characteristic which is Read Only and it's value consists of two 4 byte long strings: one of the strings is local and the other comes from the Host MCU which is connected through UART. So when the device gets read request it reads the host MCU string and then assembles the reply with both strings. The problem is that I always read the "previous"  Host string because it's value is not currently available.

How to modify the callback function so the replied value is the one currently read from the host??

Thanks, Bitkiller.

  • Hello Bitkiller,

    One way to do this is by returning blePending in your ReadCB function instead of SUCCESS. Then, you can retrieve the value from your host MCU and call ATT_ReadRsp from your app task. You have 30 secs to complete the procedure after returning blePending.

    Best wishes
  • Hi JXS, 

    Thanks for your reply.

    I've tried your suggestion and after Reading the value the BLE connection got disconnected. Then I connected with debugger and realized that the cc2640 was getting inside error handler in the ROM each time I am trying to read the value.

    Can you see why this would happen ?

    Best regards, Bitkiller.

  • Hi Bitkiller,

    It's hard to say why, but perhaps add some debugging capability using the tips in the debug section of the BLE SW Developer's Guide (SWRU393).

    A common reason for aborts is making a BLE Stack API call during an call back function or doing excessive processing in a callback. How are you notifying your app task after you return blePending to the ReadCB fxn (i.e., SEM post)?

    Best wishes
  • Hi JXS,

    I fixed the disconnection problem, I was doing some calculations inside the Read Callback.
    So now I don't get disconnected, but I do get TIMEOUT error although I get the value from the Host MCU in 1-2mSec and then call the ATT_ReadRsp fxn and then Semaphor_post

    after timeout error I cannot read other Char values and I get Operation Aborted error.. 

    Is there example somewhere that shows how to do asynchronous reads properly?

    Best regards, Bitkiller.