Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE there is no way of finding out the address type of the bonced peripheral if the IRK is not forwarded. (IDFGH-13287) #13872

Closed
3 tasks done
sergiutigu opened this issue May 28, 2024 · 3 comments
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@sergiutigu
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v4.3

Espressif SoC revision.

ESP32

Operating System used.

Windows

How did you build your project?

Command line with Make

If you are using Windows, please specify command line type.

None

Development Kit.

custom board

Power Supply used.

USB

What is the expected behavior?

We need to filter to allow connection only from bonded devices.
For that purpotse we are using esp_ble_gap_update_whitelist() which requires address type.
Bonded peripheral address type to be available in the bonding information without the IRK being sent by the peripheral.

What is the actual behavior?

Bonded peripheral address type is only available in the bonding information if the peripheral sents IRK.

Steps to reproduce.

We need to filter the conection to allow connection only of the bonded devices.
For that we are using :
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda, esp_ble_wl_addr_type_t wl_addr_type)
the last parameter is the address type.
Now we are getting this information from the bonded list:
esp_err_t esp_ble_get_bond_device_list(int dev_num, esp_ble_bond_dev_t dev_list)
Definition of:
/

  • @brief struct type of the bond device value
    /
    typedef struct
    {
    esp_bd_addr_t bd_addr; /
    !< peer address /
    esp_ble_bond_key_info_t bond_key; /
    !< the bond key information /
    } esp_ble_bond_dev_t; /
    !< the ble bond device type */

/**

  • @brief struct type of the bond key information value
    /
    typedef struct
    {
    esp_ble_key_mask_t key_mask; /
    !< the key mask to indicate witch key is present /
    esp_ble_penc_keys_t penc_key; /
    !< received peer encryption key /
    esp_ble_pcsrk_keys_t pcsrk_key; /
    !< received peer device SRK /
    esp_ble_pid_keys_t pid_key; /
    !< peer device ID key /
    } esp_ble_bond_key_info_t; /
    !< ble bond key information value type */

/**

  • @brief BLE pid keys
    /
    typedef struct
    {
    esp_bt_octet16_t irk; /
    !< The irk value /
    esp_ble_addr_type_t addr_type; /
    !< The address type /
    esp_bd_addr_t static_addr; /
    !< The static address */
    } esp_ble_pid_keys_t;

Basically you can get the addr_type only if the :
** esp_ble_pid_keys_t pid_key; /*!< peer device ID key /* is filled. Which only happens if the IRK is being sent.
But as standard mentions, IRK is optional and only required for privacy.
The address type should be available regardless.
What is happening right now is that one of the peripheral that we connect to, doesn't provide the IRK. We can pair it, but then we can't re-connect to it since we need to filter at the reconnect only the bonded devices.
So either whitelist doesn't require the address type( don't know if that is possible) or the BLE stack needs to provied address type whithout IRK being sent.

Debug Logs.

No response

More Information.

No response

@sergiutigu sergiutigu added the Type: Bug bugs in IDF label May 28, 2024
@sergiutigu
Copy link
Author

is there any input expected from me on this issue?

@github-actions github-actions bot changed the title BLE there is no way of finding out the address type of the bonced peripheral if the IRK is not forwarded. BLE there is no way of finding out the address type of the bonced peripheral if the IRK is not forwarded. (IDFGH-13287) Jul 18, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 18, 2024
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Aug 7, 2024
@esp-zhp
Copy link
Collaborator

esp-zhp commented Aug 7, 2024

We no longer maintain version 4.3. so, I have created a patch based on the latest master (commit 3276831). This patch allows you to retrieve the address types of devices in the bond list.

 git am ~/esp/esp-idf/0001-feat-ble-bluedroid-Support-getting-BLE-address-type-.patch

0001-feat-ble-bluedroid-Support-getting-BLE-address-type-.zip

@esp-zhp
Copy link
Collaborator

esp-zhp commented Aug 7, 2024

If you encounter any issues during use this patch, please let me know.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: In Progress Work is in progress labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants