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-CC2650: Receive BLE data in one task and send data for another

Part Number: LAUNCHXL-CC2650

Hi!

I have a ProjectZero-based application. Actually, I'm receiving BLE data by means of 'ProjectZero_taskFxn'. When that happens, I wake-up another task ('task_B') using an event, I process some data and I need to send the result of this process by BLE to the device of which I previously received the first data, which remains connected.

Originally, I tried to 'send' the data from 'task_B' to 'ProjectZero_taskFxn', and from the last one send the data to the BLE device using the function 'DataService_SetParameter(DS_STRING_ID,<sizeOfData>,<ptrToData>). This approach doesn't work for me. I had problems to use properly communication and synchronization mechanisms between tasks. 'task_B' only has to be executed when it is signaled from 'ProjectZero_taskFxn' and after executing once it must be blocked until it is signaled again by 'ProjectZero_taskFxn'. Therefore, what I intend to do is:

	while(1){
		/* Wait for the event */
		events = Event_pend(myEvent, Event_Id_NONE,Event_Id_00,BIOS_WAIT_FOREVER);
		/* Process all the events that have occurred */
		if (events & Event_Id_00) {
                    //Do my stuff here
                    DataService_SetParameter(DS_STRING_ID, sizeof(stringToSendByBLE), stringToSendByBLE);
			}
		}

My question is what should I do in order to be able to use DataService_SetParameter() function in 'task_B' using the same BLE Stack instantiated in 'ProjectZero_taskFxn'??

I was reading swru393d.pdf and Bluetooth Low Energy Protocol Stack User Guide, but I'm confuse about ICall, GAP and GATT service. 

I would appreciate your help!

  • Hi Martin,

    First thing is to send data back to the device when the characteristic you're updating changes you want to enable notifications or indications on that characteristic. Project0 contains characteristics that already do this for sending button press notifications so you can reference those for doing this.

    As for doing this from multiple Tasks, if your new Task is calling any stack APIs you need to make sure it is registered with ICall. Therefore if you're calling DataService_SetParameter() to send a notification back from task_B you will need to register task_B with ICall. The process for doing that can be found here:
    http://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_00_00_22/docs/blestack/html/ble-stack/index.html#creating-additional-tasks

    Hope that helps,
    Gerardo

  • Hi Gerardo, thanks for answering.

    I needed a hot-fix for my app and I tried unsuccessfully register the second task with iCall.

    In the same project_zero_task where I receive and decode BLE data, I activily wait until task_B do its thing:

     while(!getDisplayDataReady());
     DataService_SetParameter(DS_STRING_ID, sizeof(decoded), decoded);

    decoded is a global variable and task_B priority is greather in one than project_zero_task priority.

    I know that I'm breaking all recommended practices, I'm not proud of my solution but that allowed me to move forward with other urgent things.

    I will try again with the information you provided me and I will post the result here.

    Thanks again.