2022-01-25 05:11 AM
Hello,
I am building an application using STM32WB55 ( 1 MB Flash) series microcontroller and planning to use BLE 5.0 to make secure connection with a device.
In our use case, I am trying to compute how many keys/Bonding Info can be stored to speed up pairing.
I was wondering if you someone can confirm my calculations below as something doesn't feel right.
From what I read in AN5289 Rev 6, on Page 97, there is a formula to compute maximum bonded device info, which is
N = (total_size_of_nvm – 1) / [(size_of_sec_record + 1) + (size_of_gatt_record + 1)]
In my case, after plugging in the values for
total_size_of_nvm : 253 Bytes ( 507 words of 4 Byte each)
size_of_sec_record : 80 Bytes
size_of_gatt_record : 12 Bytes
N comes to be : 252/94 ~= 2.
Is this correct? that we can only store maximum of 2 bonded devices?
Help!!!
Thanks
2022-03-17 09:57 AM
Hello,
The formula to compute maximum bonded device info is the following, you have right:
N = (total_size_of_nvm – 1) / [(size_of_sec_record + 1) + (size_of_gatt_record + 1)]
The values to be used are:
size_of_sec_record = 20 words (of 4 bytes) = 80 bytes
total_size_of_nvm = 507 words (of 4 bytes) = 2028 bytes
size_of_gatt_record = 12 words (of 4 bytes) = 48 bytes Default GATT configuration without adding services
N = (2027) / (81 + 49) = 15
So, you can store maximum of 15 bonded devices.
To take into account your services and characteristics to compute size_of_gatt_record value, see part 7.6.6 of AN5289:
The GATT record in NVM is composed:
· Per service:
– 2 bytes for handle
– 3 bytes if 16-bit UUID or 17 bytes if 128-bit UUID
· Per characteristic attribute:
– 2 bytes for handle
– 3 bytes if 16-bit UUID or 17 bytes if 128-bit UUID
– 2 bytes for CCCD value (only if the attribute is a CCCD)
Best Regards