Search code examples
bluetoothbluez

Bluez Can i manually control initiator key distribution of peripheral?


Kernel: Linux 4.9.84 armv7l on board
Bluez: 5.65
Peer: Android 12 & IOS 16.6
Role: Central is my phone, Peripheral is my board
Application:

  • use btmgmt create a bondable agent and io-cap set to NoInputNoOutput
btmgmt power off
btmgmt connectable on
btmgmt pairable on
btmgmt le on
btmgmt bondable on
btmgmt power on
btmgmt advertising on
  • use phone to pair the board.

Result:

My phone successfully connected to my board and added encryption to the link, but after the pairing process, the IRK was not distributed by the central device. Without the IRK, I cannot resolve the central resolvable MAC address.

Expectation:
I want to use the LTK, which was generated last time, to handle re-pairing issues. However, without the IRK, I can't index those LTKs. Therefore, I want to get the IRK distributed and store it locally to handle re-pairing issues.

I already know that if the initiator key distribution of the peripheral do not include IdKey, the central device will not send the IRK.
I have already tried changing the peripheral's IO capability and pairing mode (from Legacy to Secure Connections), but I still cannot change the initiator key distribution of the peripheral.

ps: See at Core v5.4 vol3,Part H. page 1602

Any help on this matter would be greatly appreciated!


Solution

  • btmgmt already provides a method to handle the distribution of peripheral IdKeys(IRK).

    btmgmt privacy on // 'btmgmt power off' first or this command will be rejected 
    

    Then, your peripheral will distribute its IRK and receive the Central's IRK, which will help resolve the Central's Random Resolvable Address.