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.

RTOS/LAUNCHXL-CC2640R2: Server device (simplePeripheralDevice) - strange behaviour when connecting with BTool

Part Number: LAUNCHXL-CC2640R2

Tool/software: TI-RTOS

Hi E2E

I have a very strange issue, and I can't figure out why my custom server application acts this strange way. It's a bit hard to explain, but I'll try my best. 

It seems that my application needs 30 secs or so, to be fully setup after connection is established. 

I've developed a custom application, based on the ble5_simple_peripheral example. I've added a few services, with a few characteristics each, and I've confirmed that this part works as intentioned. I need a timer based interrupt with a semaphore block, and when I compile my application with the timer, tasks, mailboxes and a few other drivers implemented, the application works fine => I can connect to it right after power on, and read all of it's services right after connection is established.

But my problem then occurs, when I try to implement the semaphore module ONLY by including the library, and the following code: 

/*************************************************************************************************
                                         Semaphore START
**************************************************************************************************/
Semaphore_Params semaphoreParams;
Semaphore_Handle LEDsem_handle;
Semaphore_Struct LEDsem_struct;
/*************************************************************************************************
                                          Semaphore END
**************************************************************************************************/

void main()
{
/* ... */ 
    /* Create semaphore for LED control */
    Semaphore_Params_init(&semaphoreParams);
    semaphoreParams.mode = Semaphore_Mode_BINARY;
    Semaphore_construct(&LEDsem_struct, 0, &semaphoreParams);
    LEDsem_handle = Semaphore_handle(&LEDsem_struct);
/* ... */ 
}

After these few lines are inserted to the project, I can't discover any of the services, right after the connection is established between the server (my application) and client (BTool with ble5_project_zero). I have to wait for around 30 seconds before the discovery can be successful. If the discovery have failed, I can see the following Log events/opcodes: 

event: "TX: GATT_DiscAllPrimaryServices" 
event: "RX: GAP_HCI_ExtentionCommandStatus" 
event: "RX: ATT_ReadByGrpTypeRsp" 
event: "RX: ATT_ReadByGrpTypeRsp" 
opcode: "TX: GATT_DiscAllCharDescs" 
event: "RX: GAP_HCI_ExtentionCommandStatus"

After this, I can se the following on BTool, like some of the discovery is succesful: 

If this unsuccessful discovery has occurred, I have to terminate the connection, and connect again. 

If I connect, wait for 30 seconds, and do the service discovery, there are no problems. 

Another weird thing is, that if I switch the GPTimerxx26XX.h module, with a knl.clock module, and implement the semaphore driver, there seem to be no problems either. But if I then implement another task than I already have, the same problem occurs. 

To me it seems like a memory problem or another kind of data corruption, but I don't know how to check that.
According to the .map file for the application, I have 10 k left on the flash, from a 127k total. This is when my application has problems. When there's no problems, I have 11 k left. I don't know if this has anything to do with my problem. 

I hope it makes sense, and that some of you guys are able to figure out what kind of a problem this is, and how to solve it. 

Kind regards, Peter

  • Hi Peter,
    Sounds odd, probably something missing in the way you use the semaphore. Could you please elaborate a bit further on what you are trying to achieve, so we can guide you in the right direction?
  • If you simply want to add another RTOS task, please see this documentation;
    dev.ti.com/.../creating-a-custom-bluetooth-low-energy-application.html
  • Hi Joakim,

    Sorry for my late respons.
    I tried some different methods, but I've used the same semaphore library in a different project with success, and I've used it the same way here, so I don't think that's the problem.

    I'm trying to post a mail to a mailbox from a valueChangeCB function, so that a thread from my serverApp is invoked as a BLE char is changed from the clientApp. Within this thread, a function needs to be called, and as some stuff in this function is clock dependent, I need a semaphore block for the function to be 100 % finished before moving on with the thread. I've tried to setup the callback in a different way, with the semaphore implemented, and this seems to be working. But with this new callback setup, I can't support som of my other features in the project unfortunately. Right now, I've done the thread/function-block with another message to the thread's mailbox, but I still think it's weird that the original error happened, as it was doing the setup function, and had nothing to do with the current thread or semaphore initialized within it.