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.

CC2745P10-Q1: How to implement a custom BLE bonding process

Part Number: CC2745P10-Q1
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi TI,

I am currently developing a BLE 6 solution using the Android phone system's Bluetooth combined with a TI CC2745 chip. This solution includes implementing a feature where, during the first connection, the user is prompted to confirm whether they allow this device to automatically connect to the TI CC2745 next time. This involves BLE device pairing, bonding, and whitelist operations.

Specifically: When the phone's Bluetooth connects to the TI CC2745 for the first time, upon receiving the connection notification, the TI CC2745 sends a message via CAN to prompt the user to confirm whether bonding with this device and adding it to the whitelist is permitted.
If the TI CC2745 receives the user's confirmation, it bonds the device and adds it to the whitelist. The next time, the phone's Bluetooth can then automatically connect to the TI CC2745.
If the user's response is negative, device bonding and whitelisting are not allowed.

Additionally, if the number of bonded devices exceeds the maximum allowed limit, existing bonded devices need to be deleted and removed from the whitelist before the new device can be added.

I referenced the following link CC2745P10-Q1: Add custom functionality to the bonding process - Bluetooth forum - Bluetooth®︎ - TI E2E support forums, but the approach doesn't seem correct: When initiating the first connection from the phone, a popup appears on the phone requesting the user to input a PIN. On the TI CC2745 side (with the bonding flag unchecked in syscfg), we get the BLEAPPUTIL_LINK_ESTABLISHED_EVENT and notify the user to wait for confirmation. ​​However, by the time the user confirms, the pairing process seems already completed(the phone is already bonded​​ and connected). Subsequent attempts to call GAPBondMgr_Pair result in the device ​​not​​ being bonded (the phone cannot reconnect automatically next time).

Please advise on what the TI CC2745 needs to do to achieve the desired functionality.

  • Hello,

    What is the pairing mode set to in sysconfig?

    Best,

    Nima Behmanesh

  • Hi Nima,

    The pairing mode was set to "Wait for a pairing request" in sysconfig 

    I also set the pairing mode to "Initiate a pairing request" and test, it seen still can't bond the device after calling GAPBondMgr_Pair 

    Note: The SKD version in use is "simplelink_lowpower_f3_sdk_9_11_00_18"

    Thank you

  • Hello,

    To clarify, the pairing mode was set to "wait for a pairing request" but the pairing request is still sent out by the TI device?

    Some more questions:

    Is the TI device a central or peripheral role?

    Can you provide an Ellisys log of what's happening over the air?

    Where are you calling GAPBondMgr_Pair?

    Do you have any authenticated/encrypted characteristics that are being read before pairing/bonding?

    What kind of phone are you using?

    Best,

    Nima Behmanesh

  • Hi Nima,

    Thank you for your prompt reply.

    1. The TI device role is "Peripheral + Central"

    2. Sorry, I don't have Ellisys device but WCH BLE analyzer, is the WCH log OK for you?

    WCH log viewer:    https:// wch.cn/downloads/WCH_BLEAnalyzer_zip.html

    3. I call the GAPBondMgr_Pair  when receive the user's positive confirm CAN msg after BLEAPPUTIL_LINK_ESTABLISHED_EVENT event.

      

    4. No, but when the phone initiate the connection, a pop-up window will appear on the mobile device asking for the PIN code. and the 2745 will get the established event even if the user did not input the PIN code.

    5. I use android phone for test(eg. OnePlus Ace 2V-android15, Xiao Mi Mix 4-android12)

    Note:

    My target process is as follows:

    1. The mobile phone initiates the first connection;

    2. 2745 receives the connection event and sends information through CAN to the user;

    3. The user confirms and replies to the information, sending it back to 2745;

    4. If the user replies with confirmation, then the 2745 site will perform device binding and add it to the whitelist. After the mobile phone enters the correct PIN code, the binding will be successful;

    5. If the user replies with denial, then the 2745 site will not perform device binding and whitelist operation, and the mobile phone will fail to bind;

    6. If the binding is successful, restarting the mobile phone's Bluetooth can automatically connect to 2745 BLE. If the binding is not successful, it cannot automatically connect.

    Thank you

  • Hello,

    Thank you for your thorough explanation and outlining your process. I believe I understand the issue now. I will take a look at the logs tomorrow.

    Some comments:

    2. 2745 receives the connection event and sends information through CAN to the user;

    3. The user confirms and replies to the information, sending it back to 2745

    Just want to clarify here, the phone is the device sending the pairing request? I want to make sure the CC27xx is not sending the request since it shouldn’t be in this scenario. 

    I will replicate your process and see if I see the issue on my end and provide an update by EOD Wednesday. Specifically, I will do the following:

    1. Connect a mobile phone to the CC27xx (in peripheral role)

    2. Once the devices connect, I will have the phone initiate pairing/bonding.

    3. Have the CC27xx confirm/deny the request.

    4. If confirmed, bond the devices and add the phone to the whitelist

    5. Otherwise, fail bonding.

    Does that sound right to you?

    5. If the user replies with denial, then the 2745 site will not perform device binding and whitelist operation, and the mobile phone will fail to bind

    I do want to note that though the devices are paired and bonded, they will not automatically connect. This will need to be implemented separately.

    Best,

    Nima Behmanesh

  • Hi Nima,

    Thanks for your support.

         Nima said:

        I will replicate your process and see if I see the issue on my end and provide an update by EOD Wednesday. Specifically, I will do the following:

        1. Connect a mobile phone to the CC27xx (in peripheral role)

        2. Once the devices connect, I will have the phone initiate pairing/bonding.

        3. Have the CC27xx confirm/deny the request.

        4. If confirmed, bond the devices and add the phone to the whitelist

        5. Otherwise, fail bonding.

        Does that sound right to you?

    A: Yes it is right to me.

        Nima said:

        I do want to note that though the devices are paired and bonded, they will not automatically connect. This will need to be implemented separately.

    A: Yes, I have verified this function. The procedure is to add an HID service at port 2745, and after binding, it can automatically connect.

  • Hi Nima,

    Additional information for you:

    In my current environment(with the bonding flag unchecked in syscfg), As I mentioned above when the phone initiate a connection, a pop-up window will appear on the mobile device asking for the PIN code:

    1. If enter the PIN code immediately, then have the CC27xx confirm the request and call "GAPBondMgr_Pair", it will fail to bond device

    2  If  have the CC27xx confirm the request and call "GAPBondMgr_Pair" before pairing timeout first, then enter the PIN code at phone side, the 2475 can bond device successfully(Pairing Status: Bond saved) 

    Additionally, after the binding was successfully completed and saved, I attempted to call the below API to delete the binding record, but it failed and returned 0x34. Could you please inform me about which interfaces are available for the operation of deleting both the binding and whitelist records?

    Thank you very match.

  • Hello,

    I apologize for the long delay here. I have not forgotten about this issue, and I am in the process of reproducing it. 

    Though, going through trying to implement the procedure, and the information provided, I have some more questions:

    1. The peripheral (cc27xx) is the one initiating pairing. So when the phone is connected, you're requesting pairing immediately

    2. The user is supposed to confirm/deny pairing on the peripheral device (i.e. CC27xx) correct? Shouldn't this occur before the pairing request is sent? 

    What you've outlined above, from how I understand it, is the following:

        1. Phone (central) and CC27xx (peripheral) connect.

        2. Immediately after the devices connect, the CC27xx requests pairing. (This causes the pop-up on the phone asking for pin upon connection).

        3. The user is then prompted if they want to pair (confirm/deny) on the CC27xx.

        4. If they confirm, then they need to input the pin on the phone.

    However, why not on initial connection, prompt the user if they want to pair before sending out the pairing request from the peripheral?

    For instance:

        1. Phone (central) and CC27xx (peripheral) connect.

        2. CC27xx prompts user if they want to pair/bond.

        3. If yes, CC27xx sends a pairing request to the phone.

        4. User inputs pin from CC27xx to the phone.

        5. Otherwise, take some action (i.e. terminate the connect, continue without bonding, only pair... etc.)

    The above would remove any timing related to the user having to confirm/deny within the SMP timeout period.

    3. I call the GAPBondMgr_Pair  when receive the user's positive confirm CAN msg after BLEAPPUTIL_LINK_ESTABLISHED_EVENT event.

      

    Additionally, I would like to see the code in BLEAPPUTIL_LINK_ESTABLISHED_EVENT, because what I see from this log:

    Is that the pairing has started before the user confirm msg and after link establishment. This doesn't seem to match the order that you're expecting.

    1. The mobile phone initiates the first connection;

    2. 2745 receives the connection event and sends information through CAN to the user;

    3. The user confirms and replies to the information, sending it back to 2745;

    4. If the user replies with confirmation, then the 2745 site will perform device binding and add it to the whitelist. After the mobile phone enters the correct PIN code, the binding will be successful;

    Are you calling gapBondMgr_ReqPair and gapEnable_Bonding in BLEAPPUTIL_LINK_ESTABLISHED_EVENT? 

    Additionally, after the binding was successfully completed and saved, I attempted to call the below API to delete the binding record, but it failed and returned 0x34. Could you please inform me about which interfaces are available for the operation of deleting both the binding and whitelist records?

    0x34 means that the bond was not found. It could be that the address type is incorrect.

    Best,

    Nima Behmanesh

  • Hi Nima,

    Thank you for your feadback.

        Nima said:

        1. The peripheral (cc27xx) is the one initiating pairing. So when the phone is connected, you're requesting pairing immediately

    No, when I use the phone to connect to the peripheral (cc27xx), it will immediately start a pairing on its own. I just want to request a pairing after user confirmed.

        Nima said:

        2. The user is supposed to confirm/deny pairing on the peripheral device (i.e. CC27xx) correct? Shouldn't this occur before the pairing request is sent? 

    Yes, it is correct. The user confirm/deny pairing on the peripheral device before the pairing request is sent.  

    I used the car_node example code in SDK  simplelink_lowpower_f3_sdk_9_11_00_18 as peripheral and it seems what you mention " Immediately after the devices connect, the CC27xx requests pairing. (This causes the pop-up on the phone asking for pin upon connection)."  is the original process in the car_node example. It need to be changed so that the process that meets expectations(prompt the user if they want to pair before sending out the pairing request from the peripheral on initial connection).

        Nima said:

        Is that the pairing has started before the user confirm msg and after link establishment. This doesn't seem to match the order that you're expecting

    Yes, there is a pairing has started before the user confirm msg and after link establishment. Please refer to the [2.] above.

     1. I call CAN API(processBleBondMsg) to send msg to user in  BLEAPPUTIL_LINK_ESTABLISHED_EVENT:

        

    2.Call gapEnable_Bonding and gapBondMgr_ReqPair  in CAN task once receive the user's confirm msg

    As we know the current issue is that a pairing started immediately when the phone connected. would you please help to check and show how to do in syscfg to prevent starting the pairing immediately when the phone connected, so that I can requesting a pairing after user confirm and act as the flow you mention:

        For instance:

            1. Phone (central) and CC27xx (peripheral) connect.

            2. CC27xx prompts user if they want to pair/bond.

            3. If yes, CC27xx sends a pairing request to the phone.

            4. User inputs pin from CC27xx to the phone.

            5. Otherwise, take some action (i.e. terminate the connect, continue without bonding, only pair... etc.)

    Thank you 

    Yang

  • Hello,

    I believe we should transition this to a call/over email. I've reached out to your TI representative to setup communications.

    Best,

    Nima Behmanesh 

  • Hello Nima,

    Thank you for your support.

    After internal discussion, it was confirmed that instead of modifying the complex pairing control process, we can first consider using another method. That is, after device was binding, we will ask the user to confirm(at 27xx side). If the user refuses, the binding record will be removed without adding to the whitelist. If the user agrees, the binding record will be keep and  whitelist will be newly added.

    Thank you 

    Yang

  • Hello,

    That sounds like a good solution. That way, you don't run the risk of a pairing timeout due to a lack of user input. 

    Let me know if you run into any issues.

    Best,

    Nima Behmanesh

  • Hello Nima,

    Thank you for your comment

    If I run into any issues, I will update here and ask you to help again.

    Thank you

    Yang