GAPC_DISCONNECT_IND gets consumed before reaching user_app_disconnect

4 posts / 0 new
Last post
ankitdaf
Offline
Last seen:2 years 9 months ago
加入:2015-09-03 20:14
GAPC_DISCONNECT_IND gets consumed before reaching user_app_disconnect

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:

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi ankitdaf,

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

ankitdaf
Offline
Last seen:2 years 9 months ago
加入:2015-09-03 20:14
Hi MT_dialog

Hi MT_dialog

我做了一些挖掘,olated 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

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi ankitdaf,

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