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: How to pair with peripheral iOS as it requires encryption/pairing to be after reading/writing/subscribing on an encrypted characteristic.

Part Number: CC2540

Hello TI experts,

I have a CC2540 USB dongle working as the central and GATT client and an iOS peripheral. The characteristics of the primary service on the peripheral are encrypted. I found that iOS says:

The pairing process starts by peripheral only if the central starts reading/writing/subscribing on an encrypted characteristic.

First of all, I do not know how to set the following parameters:

GAPBOND_PAIRING_MODE

GAPBOND_MITM_PROTECTION

If I set GAPBOND_PAIRING_MODE_WAIT_FOR_REQ, no pairing would happen. If I set GAPBOND_PAIRING_MODE_INITIATE, CC2540 initiates the pairing before characteristic discovery and when I try to write to a characteristic, I received the error shown in the attached sniffer log (INSUF_AUTHENTICATION).

Second, I do not know how to manage the pairing after characteristic discovery. I am following SimpleBLECentral project.

I'd be grateful to hear any hints/suggestion or if there is any sample code/project dealing with the same situation. I am in a taught situation approaching a demo and would appreciate any help.

Bests,

2117.sniff.psd

  • H. Sh,

    To your first question, GAPBOND_PAIRING_MODE & GAPBOND_MITM_PROTECTION are set in SimpleBLECentral_Init() in simpleBLECentral.c.

    What are all of these variables set to?

        uint32 passkey = DEFAULT_PASSCODE;
        uint8 pairMode = DEFAULT_PAIRING_MODE;
        uint8 mitm = DEFAULT_MITM_MODE;
        uint8 ioCap = DEFAULT_IO_CAPABILITIES;
        uint8 bonding = DEFAULT_BONDING_MODE;
        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 );

    This thread also has a good discussion about these params on CC2540. 

    https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/304055

    It may also be helpful to reference the BLE Spec on what is possible given your applications and the settings that you give for MITM, IO CAP and others.

  • This is actually my question from you. I have tried all possible combinations of these parameters, but I think there should be some API to be called after writing to an encrypted characteristic. I am currently using these parameters:

    #define PAIRING_MODE GAPBOND_PAIRING_MODE_WAIT_FOR_REQ

    #define MITM_MODE TRUE

    // Default bonding mode, TRUE to bond
    #define BONDING_MODE TRUE

    // Default GAP bonding I/O capabilities
    #define IO_CAPABILITIES GAPBOND_IO_CAP_KEYBOARD_ONLY
  • H. Sh,

    Is your CC2540 the initiator or the responder? I'm assuming the responder but let me know if I'm wrong.

    if responder, what is the MTIM, IO CAP and Bonding_Mode for your initiator?
  • CC2540 is my central/scanner (responder?) and GATT client. The peripheral is an iOS device. There is no control over these parameters in iOS, the only setting we applied is encryption for read/write characteristics. 

    Is there any TI sample code/project that works with an iOS peripheral with encrypted communication?

    Thanks.

  • Hi H. Sh,

    For your central device, we recommend that you use: #define PAIRING_MODE GAPBOND_PAIRING_MODE_WAIT_FOR_REQ.
    When pairing with smartphone Central devices, it is recommended to use GAPBOND_PAIRING_MODE_WAIT_FOR_REQ as undefined behavior may occur when a Slave Security Request is sent by the Peripheral. Both iOS and Android will initiate pairing when the device responds with an Insufficient Authentication error response when a GATT secure characteristic is accessed.

    It seems that your initiator is your phone and the responder is your cc2540. I recommend that you reference the BLE Spec for selecting your pairing method. Spec 4.0 Vol. 3 Part H Section 2.3.
    www.bluetooth.com/.../archived-specifications

    I think researching the IO Capabilities section (Section 2.3.2) will be very helpful for you when trying to determine what you need to be using. For the USB Dongle, you don't have any display capabilities or keyboard capabilities so, I would assume that you should use No Input/No output.

    Because of this, MITM should probably be false.

    Therefore you will likely end up using Just Works unauthenticated pairing.

    This should move on to Section 2.3.5.5.

    If I remember right, in your app (like light blue) connection the central and try to read the encrypted service, which will initiate the pairing/bonding.
  • I would also read Section 5.3 "Gap Bond Manager" of the TI_Software_developers_guide located in the Documents/ folder of the SDK for BLE 1.4.2.2 for more information on using the GapBondMgr.
  • I'm going to close this post due to inactivity. To reopen this thread, just post a follow up question. Otherwise, after 30-days of inactivity from this post, this thread will lock.