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