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.

CC2540 can't connect automatically from previous saved bond

Other Parts Discussed in Thread: CC2540

Hi

I wrote a program on CC2540 with pairing and bonding. My devicy work as a slave. Program based on SimpleBLEPeripherial. I wrote functions to GAP Bond Manager Callbacs (passcode and pairstate). They work ok. My device advertise, pair and create bond with my phone with Android. I have connection bonded after write proper key on Android earlier displayed od device LCD.

1. My first issue is that when I reconnect or power reset the connection device doesn't connect automatically again. I think that I doesn't support some functionality. I don't know what I should enable further and what I'm doing wrong?

2. What is the alghorithm to automatically connect device from prevoius saved bond?

3. Is device always work as a slave is capable to automatic reconnect form saved bond?

4. In what function or functionality or callback in code device enter after start the program with saved bond? Where is the point of checking saved bond after start?

Please help.
This is my configuration:

    uint32 passkey = 0;
    uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
    uint8 mitm = TRUE;
    uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
    uint8 bonding = TRUE;
    GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof( uint32 ), &passkey );
    GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof( uint8 ), &pairMode );
    GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof( uint8 ), &mitm );
    GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof( uint8 ), &ioCap );
    GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof( uint8 ), &bonding );

In passkey function in Bond Manager Callback I change my key with generator the same as in SimpleBLECentral. Program enter the GAPBOND_PAIRINGSTATE_BONDED.

5. My second issue concern problem that I can read my characteristics by BLE other device without bonding only connected. My characteristics are in some kind of public mode. I don't know why there are visible without bonding and don't know how I can get the not visible without pairing and bonding.

  • I'm not understanding what you are trying to do here. After you bond and disconnect, you need to advertise again and then wait for a central device connect. This is not handled by the GAPBondMgr. It is handled by the application and peripheral GAPRole.

    Alternatively, you could try direct advertising.
  • If the bond is saved after power on the device should connect automatically like in eg. bluetooth hands car systems or bluetooth headphones

    The problem is that the device after reconnect hangs in the advertising mode and don't want to connect again automatically (from previously saved bond). When I'm debbuging my program I don't see any notification from GAPRole except advertising. I guess that GAPRole should change the role state to GAPROLE_CONNECTED but that doesn't happen (when try to reconnect). I don't know what I'm doing wrong.First connection with creation the bond works fine.

  • It is important to understand that it is the central that initiates the connection; not the peripheral. So you need to make sure the central is send connection requests.
  • I understand this but when you connect bluetooth hand car system or other bluetooth device to eg. mobile phone previously making a bond this bluetooth devices connect automaticaly just after power on the device. So mobile phone working as a central send connection requests. Why isn't it happening with my device? I can see on mobile phone after power on my ble device that name of my bonded device go in first position of bonded device. Something happens. Mobile phone see my ble device and prevously saved bond and reacts. I still thinking that I'm not supporting something in my program because despite of advertising mobile phone doesn't connect automatically. I don't know why GAPRole doesn't react?
  • I'm not understanding your system here. If you have verified that your device is advertising, you need to next verify that your Android App is attempting to connect. If you need help in doing this, I would recommend posting on an Android forum or looking at the Sensor Tag sample app source code:
    git.ti.com/sensortag-20-android
  • HI Freelex,

    What you are mentioning is with Bluetooth Classic, which supports HFP, HSP, A2DP, and so on, not Bluetooth LE.

    Even though the same or similar terminologies and pairing methods are being used, internally the operations could be different.

    On Bluetooth Classic operation, a command is available to attempt to reconnect profiles to most recently paired and connected device.

    while Bluetooth LE operation always should be handled and initiated by central device as master device against the peripheral device advertising.

    So, on BLE, most recently paired concept doesn't exist. Just connection is made by central device's application handling.

    It seems that your product is using a Bluetooth module including Classic(BR/EDR v2.x) and LE(v4.0 or else).

    Anyway, you need to have a different connection operation according to each mode.

    BR,

    Ji Won

  • Have you found the answer?