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.

Long Task Ruins BLE Communication

Other Parts Discussed in Thread: CC2540

Hello All,

I am working on my hobby project. I have CC2540 Keyfob with SimpleBLEPeripheral example. Currently, I have written an Android Application that sends and receives information to/from my Keyfob. When I run the Android Application and Keyfob I successfully connect Keyfob to Android phone. Afterwards, I successfully discover services. 

The purpose of my application is to send long array of data from Android application to CC2540 and then to I2C module. In the end I2C device sends back information to CC2540 and CC2540 send the information to Android device. I implement I2C with bit-banging.

The problem is here, I lost the BLE synchronization after CC2540 send information to I2C module since it takes aprx 200 msec. After couple of second from starting I2C data transfer CC2540 lost connection from Android phone and disconnected. 

However, I am processing this function on Application Task. AFAIK, Application Task (SimpleBLEPeripheral) which is initilized in "void osalInitTasks( void ) in OSAL_SimpleBLEPeripheral.c" has lowest priority and it should not interfere with Bluetooth Stack.

Does anyone have some idea about how to implement a long task in OSAL?

I would appreciate if you share some thoughts and ideas. 

Have a great day!

Deniz

  • Hi Dnz,

    Once you start I2C communication, you stall the Radio as you indicate. The reason is that the OSAL is not pre-emptive and will not allow the Radio (LL) to regain control when it wants to.

    I think the best thing you could do is try to fragment your data into several packets before sending it over I2C and then schedule so that the Radio (LL) gets time slots to maintain the connection.

    Best Regards

    Joakim

  • Hi Joakim,

    Thanks for the help. This is what I am doing. I think this will help me. So, the lesson in the end of the day is

    "Don't block a task with while loops" :)

    Have a great day everyone!