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.

Access to the HCI Events?

Other Parts Discussed in Thread: CC2650

Hello,

for an application based on the SimpleBLEPeriperal using BLE 2.1 on an cc2650 I need to get the current connection parameters and I need to get informed when the LL connection parameters change (according to the core spec, "LE Connection Update Complete Event" is exactly what I'm looking for).

From what I've read (this forum, SWRU393 and the "Bluetooth Smart Wiki."), it looks like, the TI BLE Stack distributes this informations as GAP Events.

According to "SWRU393; I. GAP API" GAP_RegisterForMsgs() is to be called to receive extra (unprocessed) HCI status and complete events. In the same chapter is the event, I'm looking for documented: GAP_LINK_PARAM_UPDATE_EVENT

The same chapter states that: "Some of these events will be passed directly to the application and some will be handled by the GAPRole or GAPBondMgr layers."

I tried to enable the link layer event by calling GAP_RegisterForMsgs() in a service task, but I do not receive any GAP_LINK_PARAM_UPDATE_EVENT event in that task.

Poking around a little bit, I found that the peripheral task is receiving this events, but is not calling GAP_RegisterForMsgs(). So it looks like, the peripheral task is implementing the GAPRole and the GAP_LINK_PARAM_UPDATE_EVENT is not "passed directly to the application".

Now this is all very confusing to me and I have some questions: 

- Is it possible to receive the original link layer HCI events ("LE Connection Update Complete Event")? This would make my live easy.

- Is it possible to additional receive the GAP events that are received by the peripheral task in an other task? If that would be easy, I would be happy too.

- How can I tell, which events are passed directly to the application and which are not?

- How does the BLE stack knows, that the peripheral task is implementing the GAPRole? (and thus sends the events)

Thank you very much for any tipp or pointer!

Kind regards,

Torsten

  • Hi Torsten,

    If you look at peripheral.c you'll see that it has a handler for processing GAP messages. This is called gapRole_processGAPMsg. There is a case within this function for handling GAP_LINK_PARAM_UPDATE_EVENT. 

    Here is an excerpt of code from that function:

              // Make sure there's no pending connection update procedure
              if(Util_isActive(&startUpdateClock) == FALSE)
              {
                // Notify the application with the new connection parameters
                if (pGapRoles_ParamUpdateCB != NULL)
                {
                  (*pGapRoles_ParamUpdateCB)(gapRole_ConnInterval, 
                                             gapRole_ConnSlaveLatency, 
                                             gapRole_ConnTimeout);
                }
              }

    So long as you've registered your app for connection parameter update callbacks, you will get notified at the app level about changes to connection interval, slave latency, and connection timeout.

    Does this answer your question? In this case, the application will only be notified via callback if you have registered the callback. Else the peripheral role handles the connection housekeeping and returns.

    What I would recommend is to create callbacks for the info you need to process within the app, and then register them using GAPRole_RegisterAppCBs.

  • Hi Sean,

    thank you for replying. Yes, of cause I've seen that the GAP_LINK_PARAM_UPDATE_EVENT events are already handled by some part of the sample application. And yes, there is a callback mechanism implemented that is used to update the display in an other part of the application. And yes, I could extend this interface to accept more then one callback.

    Now I want to write a service that has an as small as possible interface to other parts of the application to be as reusable as possible. Applications that integrate that service usually do not need to interface with that service (the application will not need to provide any informations to the service, nor will the service provide any informations to the application; a little bit like the Bond Management Service).

    That service interfaces already with the BLE Stack to receive ATT Handle Value Confirmations Events and now I need to receive link layer events and I would love to do so without introducing an additional dependency.

    All that multi tasking, message dispatching, multi imageing and "callbacking" are technics used to decouple different parts of the software to reduce dependencies. All the used technics introduce costs in terms of complexity and resources.

    And now, I would love to see some benefits from all that and would love to see that two parts of the application can subscribe to GAP_LINK_PARAM_UPDATE_EVENT events :-) Is this possible? If not, is it possible to receive directly HCI Events?

    Kind regards,

    Torsten

  • And by adding the ability to install multiple callbacks, I would have to either change your BLE stack ( that would complicate updates of the BLE stack) or I would have to add an addition layer that would install one callback and would forward the callback call to other callbacks (that's ugly).
  • Hi Torsten,

    Have you tried to follow section 5.6.2 of the software developer's guide exactly. You should be able to subscribe to HCI events in the same manner that SimpleBLEPeripheral subuscribes to HCI_COMMAND_COMPLETE_EVENT_CODE in the example. If you are not getting this event in your application then it is likely not being passed all the way up to the app. Try to find where it stops being passed up.

    As far as registering multiple callbacks to stack elements, you should follow the provided callback structure provided as the low level stack code (along with the callbacks it can trigger are generally unchangeable). What I would suggest instead is to have one callback registered and post a message in each thread's queue that needs to be notified. Remember that callbacks run from an SWI perspective, so it is best to keep them short.
  • Hi Sean,
    well, 5.6.2. just says, that I have to register the task who should receive the event by using the GAP_RegisterForMsgs() function. I did so and I received no events. To make sure, that I not just screwed up the message interpretation or filtering, I've set a breakpoint direct behind ICall_fetchServiceMsg() and that break point was never reached.

    HCI_COMMAND_COMPLETE_EVENT_CODE and GAP_LINK_PARAM_UPDATE_EVENT (the event, I'm after) are processed in two different tasks and the task that receives the GAP_LINK_PARAM_UPDATE_EVENT event does not call GAP_RegisterForMsgs().

    But anyway, I'm using the provided callback now and it works.

    Thank you for offering help and listening,

    Cheers,
    Torsten