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.

CC2541 HCI over serial interface programming model

Other Parts Discussed in Thread: CC2541, CC2640

Hi,

I am developing an embedded application which needs to communicate with some other hardware over BLE. The Bluetooth adapter used on both sides is a CC2541. Communication with the CC2541 takes place over a serial interface. The operating system is Linux. Even if this seems simple at the first glance, there a some points, which are still not clear to me. So I hope I can clearify them now. For communication the vendor specific extensions from TI are used. Basically there are:

  • Commands sent by the application
  • Events generated either directly as response to a command or indirectly i.e. when something is received

For technical reasons, the application consists of two threads. One handles the commands, which are enqueued in a FIFO queue and sent to the controller and one thread, which handles the events. My assumptions are that:

  • There is no specific order how events arrive.
  • Commands can fail when the internal state of the controller has changed and is out of sync with the application (i.e. a connection handle is not valid anymore)

Is this right ? Or is there some recommended way how this could be prevented ? I ask for the following reasons. I want to establish a link to a device. However when the link has not been established after some time, I cancel the request. If the above is true, it could happen, that the link is still established, so I need to handle this somehow.

Best regards,
Stefan

  • Hello. So you want to use the CC2541 as a network processor? I don't really understand your concerns. In the example you describe where you want to cancel the link request, you can just send a link terminate command. This will return an event if the link was successfully terminated. If the link is established before it was able to be terminated, you will receive a link established event followed by an "unable to terminate" event. This is because a special connection handle is required in order to terminate a connection request and will thus fail if a connection is already established. See the GAPCentralRole_TerminateLink() in the GAPRoleCentralAPI of the software developer's guide for more information:

    www.ti.com/.../swru393

    FYI that guide is for the CC2640 but the API's and all profile / application information still apply for the cc2541.

    In terms of how to implement a network processor, there are generally two methods:
    - use the network processor project (HostTestRelease). In this scenario, you will be using the Bluetooth spec defined HCI interface. This will require your host processor to act as the profiles / application. Advantage: interface is already defined. Disadvantage: more host processor interaction needed since you need to implement the profiles and applicaiton.
    - modify an embedded project and add a custom UART / SPI interface to implement functionality. Advantage: less host processor interaction. Disadvantage: need to implement custom interface.

    When the device is acting as a peripheral, I would recommend the second solution. However, it sounds like your device will be acting as a central device since you are establishing connections. In this case, you will need to write a good deal of code regardless so I would recommend using the standard network processor project. As reference, there are some python examples here: processors.wiki.ti.com/.../CC254X_PC_Examples
  • Hello,

    yes actually it is a Rasbperry Pi like box with an integrated CC2541, which acts as a central device and needs to handle notifications from multiple other devices, which can be connected and disconnected dynamically by the user. I have no access to the firmware (I guess this is HostTestRelease) und some BTool-Logs. Since BlueZ seems not to be compatible I need to handle it myself and trying to get a overview. But what you said already gave me some valueable pointers. Thank you.

    Best
    Stefan