Skip to main content

GAPC_DISCONNECT_IND gets consumed before reaching user_app_disconnect

4 years ago

GAPC_DISCONNECT_IND gets consumed before reaching user_app_disconnect

Posted byankitdaf0 points 3 replies
0 upvotes

Hi

My application has an Android app that talks to the 583. The code is based on the ble_app_barebone example and I have implemented custs1_task profile as well.

I am looking to toggle an LED when the Android app connectors or disconnects from the 583. I am able to get the connection part right and the LED goes on. However, if the Android app initiates the disconnect, the custs1_task.c consumes the GAPC_DISCONNECT_IND message, and it never bubbles up to the user_app_disconnect method in user_barebone.c

Is it possible to make the user_app_disconnect receive this message as well ? There are some variables and tasks defined in user_barebone.c that are not available in custs1_task.c so I cannot exactly execute that code anywhere except user_barebone.c

Commenting out "return (KE_MSG_CONSUMED)" did not help

Can you tell me what I might be doing wrong here ? Thanks !
Keywords:

4 years ago

MT_dialog -30 points

Hi ankitdaf,

You can check either the ble_app_profile, or the ble_app_peripheral, they both implement the custs1 profile and the indication at the application on disconnection is triggered in both the application and at the custs profile disconnection implementation. Try checking with breakpoints instead of toggling leds.

Thanks MT_dialog

accepted answer!

4 years ago

ankitdaf 0 points

Hi MT_dialog

I did some digging, and have isolated the cause of the problem.

I had implemented the following lines in user_app_connection() because I wanted to advertise while connected.
Commenting out the lines below made user_app_disconnect() trigger again.
--
gapm_env.connections = 0;
user_app_adv_start();
--

So I know how to trigger the user_app_disconnect now, but it doesn't help because with the above fix, it is not possible to advertise while connected. Is there any way around this?

Thanks
Ankit

accepted answer!

4 years ago

MT_dialog -30 points

Hi ankitdaf,

The reason for not being able to get the user_app_disconnect() while advertising is because the state of your device is APP_CONNECTABLE since you are advertising, the callback user_app_disconnect is called in the gapc_disconnect_ind_handler() and the code checks the state of your application before calling the callback.

Thanks MT_dialog