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.

LAUNCHXL-CC2640R2: Gatt_read seems to freeze or crash program.

Part Number: LAUNCHXL-CC2640R2

Tool/software:

I am currently using the simple_peripheral and simple_central programs to communicate joystick data.  I am successfully sending continual data from the peripheral using a task and semaphores.  However, when I try this same approach it seems to freeze the the putty window which seems to maybe signal a crash or it looks like it is hitting the abort loop.  If I leave the simple_central as is and do a gatt_read pressing the buttons I have successfully read some joystick data.  Obviously, I need the GATT_Read to happen continuously.  So I tried to use a thread, task, and semaphore as the simple_peripheral sending the data.  It seems to crash the program as the putty screen freezes.  I thought maybe I need to change the priority to a lower priority, but that did not work.  Is there something different I need to do?  Is it logical to have continuous calling of Gatt_ReadChar or is there a different approach that needs to be taken?  On the simple_peripheral side it uses the thread and semaphore and I'm continually calling SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR5,SIMPLEPROFILE_CHAR5_LEN, &adcValue);



Here is what I was trying in the simple_central

Calling the Gatt_readChar in a  thread



and then handling the shifting and reading the adcValue from the SIMPLEPROFILE_CHAR5 characteristic and doing the shifting.  


Works like a charm when I do a simple Gatt_read with the button on the board, but seems to bind up and or crash when using it in a thread.

Maybe I need to register with the iCall stuff?  Maybe it is crashing, or it is calling the Abort function when I debugged it, as I am calling the Gatt_ReadCharValue from another task/thread and it's not able to communicate with the other thread as it is not registered with iCall?   
In that case though, why am I able to call Set_parameter in the simple_peripheral program from another task without any issues?

  • Hi,

    You are correct, any thread that calls a BLE API must be registered with icall. I would recommend looking at how the simple_central task registers with icall and copying the same logic. Afterwards, you should be able to make the same API call. Another alternative that wouldnt require registering your second task would be to send an event to the simple_central event loop to perform the GATT_read from the context of the simple_central task,

    Best Regards,

    Jan

  • Thank you so much Jan.  I just created another task with a clock and continued to call the button event and it works like a charm.  I was stuck on this for awhile.  Thank you for the ideas.