BdAddress - Bonding options and functions

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PhDi_1589426
Level 3
Level 3
First like received First like given

Hello everyone,

I tried to get the peer bd address but it does not work.

My guess is that it is related to the whole bonding, pairing procedures.

I originally wanted to have a connection without any authentication and encryption.

     -> Gap Settings -> Security level: No Security  ;  Bonding requirement: Bonding

When connected to a peer central device I wanted to get the peer bluetooth address by calling

     Cy_BLE_GAP_GetPeerBdAddr(&peerBdAdd);

     cy_stc_ble_gap_peer_addr_info_t peerBdAdd;

The next step would be to have an encrypted connection without any authentication.

I know the meaning of the Security Levels: What is the difference between Bluetooth LE Secure Connections LE security mode 1 and level 3 and 4?...

Difference between Secure Simple Pairing and Secure Connections in Bluetooth? - Information Security...

What I do not know are the available (working) functions depending on the Security Level and what actions need to be taken.

Could you write a knowledge based article about this topic with code examples for each setting? If so please do not add any other functionality because it is confusing to have multiple options without knowning how they effect each other.

Thanks and best regards

Philipp

0 Likes
1 Solution
PhDi_1589426
Level 3
Level 3
First like received First like given

Hi everyone,

I found my failur by studying the CE212742 example.

I wanted to use the function cy_en_ble_api_result_t  Cy_BLE_GAP_GetPeerBdAddr (cy_stc_ble_gap_peer_addr_info_t  * param);

In the PDL (which I really, really love working with) the parameter cy_stc_ble_gap_peer_addr_info_t  * param is defined as follows:

    parameter is of type cy_stc_ble_gap_peer_addr_info_t, where

    param->bdHandle: Peer bdHandle

    param->bdAddr: Empty buffer where the peer Bluetooth device address will be stored.

That means:

  1. that a variable has to be declared of type cy_stc_ble_gap_peer_addr_info_t
  2. (and for me it was not really obvious, but it could be me ) that I have to copy the bdHandle into this structur under .bdHandle.
  3. Then I can give this structur to the function to get the bdAdress.

This could look like this:

        case CY_BLE_EVT_GATT_CONNECT_IND :                             

            uint8 returns;

           

            connectionIndParameter = *(cy_stc_ble_conn_handle_t*) eventParam;     // parameter given by the connection event of type                                                                                                                                        cy_stc_ble_conn_handle_t

           

            peerBdAdd.bdHandle = connectionIndParameter.bdHandle;                         // Is of type cy_stc_ble_gap_peer_addr_info_t

           

            returns = Cy_BLE_GAP_GetPeerBdAddr(&peerBdAdd);

            printf("\r\n Error: %x",returns);

           

            printf( "\r\n   - > Device bdAddress:");

   

            for(uint i=CY_BLE_BD_ADDR_SIZE ; i>0 ; i--){

                printf( " %x", peerBdAdd.bdAddr.bdAddr[i-1]);

            }

           printf("\r\n"); // Don't forget this one

           break;

Best regards

Philipp

View solution in original post

0 Likes
1 Reply
PhDi_1589426
Level 3
Level 3
First like received First like given

Hi everyone,

I found my failur by studying the CE212742 example.

I wanted to use the function cy_en_ble_api_result_t  Cy_BLE_GAP_GetPeerBdAddr (cy_stc_ble_gap_peer_addr_info_t  * param);

In the PDL (which I really, really love working with) the parameter cy_stc_ble_gap_peer_addr_info_t  * param is defined as follows:

    parameter is of type cy_stc_ble_gap_peer_addr_info_t, where

    param->bdHandle: Peer bdHandle

    param->bdAddr: Empty buffer where the peer Bluetooth device address will be stored.

That means:

  1. that a variable has to be declared of type cy_stc_ble_gap_peer_addr_info_t
  2. (and for me it was not really obvious, but it could be me ) that I have to copy the bdHandle into this structur under .bdHandle.
  3. Then I can give this structur to the function to get the bdAdress.

This could look like this:

        case CY_BLE_EVT_GATT_CONNECT_IND :                             

            uint8 returns;

           

            connectionIndParameter = *(cy_stc_ble_conn_handle_t*) eventParam;     // parameter given by the connection event of type                                                                                                                                        cy_stc_ble_conn_handle_t

           

            peerBdAdd.bdHandle = connectionIndParameter.bdHandle;                         // Is of type cy_stc_ble_gap_peer_addr_info_t

           

            returns = Cy_BLE_GAP_GetPeerBdAddr(&peerBdAdd);

            printf("\r\n Error: %x",returns);

           

            printf( "\r\n   - > Device bdAddress:");

   

            for(uint i=CY_BLE_BD_ADDR_SIZE ; i>0 ; i--){

                printf( " %x", peerBdAdd.bdAddr.bdAddr[i-1]);

            }

           printf("\r\n"); // Don't forget this one

           break;

Best regards

Philipp

0 Likes