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.

CC2640R2F: Disconnect from app not happening when ANCS is added to simple peripheral

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640

Tool/software: Code Composer Studio

SDK --> simplelink_cc2640r2_sdk_4_10_00_10

I am working on "Simple peripheral" project.

BLEstack -> Simple peripheral

-----------------------------------------------------------------------

Hi, 

Description of my application:

Normal Simple peripheral example code is used on top of that ANCS example code from GitHub is integrated.

1. The Data transfer via ANCS is happening correctly and Call missed call, SMS, etc notification is received on the BLE side also.

2. I am also trying to send data from the iOS phone side via GATT characteristics also, the data transfer here also is happening seamlessly.

ISSUE:

Now, when I am trying to disconnect from the ios app & BLE  then the disconnect is shown just in-app, not proper disconnect is happening.

The connection is still established b/w phone and BLE from behind (checked in phone's Bluetooth section).

Observation:

When I am taking back the ANCS changes and connecting the iOS app & BLE the disconnect from the app is happening as expected.

What can be the issue here?

Need to get it fixed ASAP.

ANCS code imported from the below example in GitHub:

https://github.com/ti-simplelink/ble_examples/tree/simplelink_cc2640r2_sdk-2.20/examples/rtos/CC2640R2_LAUNCHXL/bleapps/ancs/src/app

Regards,

Saurav

  • Hi Saurav,

    Thank you for the details provided here.

    It would be nice to use a Bluetooth LE analyzer (e.g. Ellisys) to verify if the connection events still happen.

    The peripheral can terminate the connection using the function GAP_TerminateLinkReq() [this function may be called inside GAPRole_TerminateConnection()]

    Best regards,

  • Hi Clement,

    Actually, the disconnect is initiated from the APP's side, not the BLE side.

    So the terminate function is of no use to me I guess in this context.

    Whenever APP disconnects, the complete disconnection should happen, but the connection in the background is still present.

    When the app is disconnecting then I should receive "GAP_LINK_TERMINATED_EVENT", but I am not receiving that in the case when ANCS is running along with simple peripheral code.

    .

    Regards,

    Saurav

  • Hi Saurav,

    I understand, thanks.

    A BLE trace should help to identify if the link termination is properly sent by the smartphone.Could you please provide it?

    Thanks and regards,

  • Hi Clement,

    I will provide the sniffer logs by coming Monday.

    Needed one information in meanwhile, here BLE is a gatt client and as well as the normal simple peripheral connection is also there, So, will the ble get two disconnect requests from the ios application?

    Here I am not getting a terminate link event in my ble code, it can be a app issue or not ?

    .

    Regards,

    Saurav

  • Hi Saurav,

    The link termination is triggered at the Link Layer (LL) level. Here you do have only one Bluetooth link between the phone and the device, so only one link termination should be required. In other words, only one link termination is required.

    The thing is, the central device (i.e. the phone) does not need any acknowledgement from the peripheral (TI device) to terminate a connection. So, per your description, it seems weird to have the phone still considering the connection active. The sniffer log should clear all of this :)

    Best regards,

  • Hi Clement,

    In the case of ANCS parallelly working with simple peripheral.

    Is there any other termination link like "GAP_LINK_TERMINATED_EVENT", I mean to ask is there another event like GATT termination link ?

    Coz here ble acting as GATT client also.

    Just want to know is it the case that we will recieve other termination link event also?

    .

    Regards,

    Saurav

  • Hi Saurav,

    The GATT layer is not responsible for any form of connection establishment - i.e. there is no "GATT termination link".

    In addition, the same event (GAP_LINK_TERMINATED_EVENT) is triggered no matter if the device acts as a GATT server or GATT client.

    With that said, make sure the phone does not expect the GATT client (i.e. TI device) to terminate the link. If this is the case, then refer to my previous message.

    Regards,

  • Hi Clement,

    Thanks for the clarification.

    Here as you said that the "make sure the phone does not expect the GATT client (i.e. TI device) to terminate the link".

    As I am not receiving the indication that the app wants to terminate the connection via "GAP_LINK_TERMINATED_EVENT", so how will i be able to terminate the connection from BLE side as it is GATT client.

    I think I need to get "GAP_LINK_TERMINATED_EVENT" first on BLE side then only ble can do other diconnects.

    Please let me know if I am wrong here!

    .

    Regards,

    Saurav

  • Hi Saurav,

    I was basically offering a solution to close the connection.

    If you wish the connection to be closed by the phone then there is nothing else you can do.

    The BLE traces will help a lot.

    Regards,

  • Hi Clément

    I wish you are doign well.

    I am team mate of Saurav negi working in the same project.

    (this problem is only of iOS device where we are using ANCS parallel to service mobile client also)

    I would like to explain the technical details so you understand the current implementation first clearly which i think is missing from the post.

    We are using CC2640 as simple peripheral and in simple peripheral we have "one GATT client" and "one GATT server" both running concurrently.

    GATT Server is running in the simple peripheral is used by the mobile application (which is GATT client) and mobile application is also the Master of the connection (who initiate the connection.)

    GATT client (in simple peripheral) is connected to the ANCS GATT server (in iOS device).

    So basically, single phone is having single BLE connection and running two GATT instance at both end.

    Connectivity, data transfer works fine concurrently, there is not problem.

    see the architecture here (cluster is using TI BLE IC)

     

    But when mobile app (who is GATT client) initiate the disconnect, the mobile does not terminate the link as ANCS is still connected - this is my pure assumption.

    Now to know if mobile app has disconnected, we must know that my client (i.e. mobile app) has disconnected from my GATT server (BLE peripheral), so from my BLE device i can trigger the disconnection for ANCS and complete BLE link can be disconnected. - i am not sure if i am thinking in right direction here too.

    We are attaching the logs here for your reference.

    Let us know your input/ feedbacks.

    With_ANCS_disconnect_logs.psd

    For the debugging:

    We disabled the BLE GATT client (which we connect to the ANCS GATT server ) and tried the disconnect from mobile app, and it works fine (this is the reason we are thinking, ANCS is blocking the complete disconnection as it is still connected and iOS is making sure an uninterrupted connection :)

  • Hi,

    Thank you for the details.

    Could you please specify which tool should be used to open the log you provided?

    Regards,

  • Hi Clement,

    Download SW from this link (https://www.ti.com/tool/PACKET-SNIFFER)

    Select the highlighted version for downloading:

    Regards,

    Saurav

  • Hi Saurav,

    I cannot opened the file provided for the moment - this is because I am working from home and cannot get the proper configuration on my computer.

    Could you please look into the file to find the disconnection command sent by the phone?

    Regards,

  • Hi Clement,

    The terminate/disconnect command is nowhere to be seen in the log.

    And when the ANCS code part is taken back then the Terminate packet is received always from the phone.

    Regards,

    Saurav

  • Hi Saurav,

    Thank you for this information.

    The terminate/disconnect command is nowhere to be seen in the log. ==> This is the root cause of the error. If the disconnect is not sent by the phone, then there is no way the CC26xx device disconnects. In other words, the issue should be searched on the phone side.

    As a workaround, you could consider to let the CC26xx device trigger the disconnection (see previous messages).

    Regards,