cancel
Showing results for 
Search instead for 
Did you mean: 

Number of bonding/bonded devices and validation ( and typo )

DS.4
Senior II

For our validation:

I would like to verify my computation for the capacity of the bonding list size. I did have some characteristics created so it's not the default , but its a number close to that. ( Sources in the bottom) 

It would be disastrous if entire bonding list is cleared. (when full, and I need to prevent it )

Also , I do not have the amount of devices to verify that!

 

Please support.

 

Pro bono publico, I also I believe you have a typo in AN5270:

 

DS4_0-1715074921411.png

 

Here are my sources:

 

How many keys stack can hold:
https://community.st.com/t5/stm32-mcus-wireless/how-many-pairing-device-information-can-the-stm32wb-has-at-most/td-p/123506
https://community.st.com/t5/stm32-mcus-wireless/storing-ble-bonding-information-keys-on-external-flash/td-p/120158

How to read the actual key from stack:
https://community.st.com/t5/interface-and-connectivity-ics/where-and-how-to-store-application-security-keys-on-the-bluenrg/m-p/210330

What happens when stack bonding list gets full:
AN5270 : Section: ACI_GAP_CLEAR_SECURITY_DB https://www.st.com/resource/en/application_note/an5270-stm32wb-bluetooth-low-energy-wireless-interface-stmicroelectronics.pdf :

1 ACCEPTED SOLUTION

Accepted Solutions
_Joe_
ST Employee

Hi,
In case NVM is full, only the last bonding is kept and all the previous bonding are deleted (to save space)
Normally there is an hardware_error_event message before NVM is full (NVM_Warning).

By the way, it is possible to get all the devices bond using ACI_GAP_GET_BONDED_DEVICES command.

BR, Joé

View solution in original post

6 REPLIES 6
STTwo-32
ST Employee

Hello @DS.4 

First, thank you for reporting this Typo, I've escalated it to the concerned team for correction ASAP (under internal ticket number 183137).

For such a specific support, I suggest you contact one of our local FAEs. They should help you on that case.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

_Joe_
ST Employee

Hi,
In case NVM is full, only the last bonding is kept and all the previous bonding are deleted (to save space)
Normally there is an hardware_error_event message before NVM is full (NVM_Warning).

By the way, it is possible to get all the devices bond using ACI_GAP_GET_BONDED_DEVICES command.

BR, Joé

@_Joe_  Thanks for that , that exactly what I've seen , saved me a question!

 

For validation, I did manage to fill STM32WB bonding list to max size. Did it by changing my (single) client address on each connection. 

 Issue is that my max size calculation are somehow wrong  !?

 

2 services, UUID_128

each with:

1 charct UUID_128 CCCD ( NOTIF+ INDIC+ READ)

1 charct UUID_128  (WRITE)

 

Set : SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM and SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC to get maximum free space!

 

So I suppose size of gatt record is 17(UUID length) time two ?

 

according to n = (total_size_of_nvm-1) / [ (size_of_sec_record+1) + (size_of_gatt record+1) ]

 

n  = 2027 / ( 81  +  [(17*2) +1] ??)  = 17 

 

When actually from testing I get max 7.. ( on next bonding  I see what @_Joe_  described..)

I also still see the service-changed-descriptor when I discover characteristics.. what I might be missing here?

 

 

 

 

 

 

Hi,
I just did the calculations with your gatt info, I have the impression that by doing the calculations as if you had a FULL_GATTDB_NVM configuration, we end up with 7 bonded devices max. (see NVM_-_FULL_GATTDB_NVM_flag )
That would be consistent with what you're seeing:
>> "I also still see the service-changed-descriptor when I discover characteristics.. what I might be missing here?"

Are you sure that your configurations on this point are correct?

these are my options from code:


#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3)

@_Joe_ @STTwo-32 
Putting here everything I tested: 

 

What I observe on overflow looks like an issue:

<<Got if full >>
2024-06-04 17:16:53.500 Ble: Type: 0, Mac: 30 67 7e 50 a0 00 , status: 0x0 // 1
2024-06-04 17:16:53.500 Ble: Type: 0, Mac: 31 67 7e 50 a0 00 , status: 0x0 // 2
2024-06-04 17:16:53.501 Ble: Type: 0, Mac: 32 67 7e 50 a0 00 , status: 0x0 // 3
2024-06-04 17:16:53.502 Ble: Type: 0, Mac: 33 67 7e 50 a0 00 , status: 0x0 // 4
2024-06-04 17:16:53.503 Ble: Type: 0, Mac: 34 67 7e 50 a0 00 , status: 0x0 // 5
2024-06-04 17:16:53.504 Ble: Type: 0, Mac: 35 67 7e 50 a0 00 , status: 0x0 // 6

2024-06-04 17:16:53.504 Ble: Type: 0, Mac: 36 67 7e 50 a0 00 , status: 0x0  // 7 ( FULL)


<<Bonding another device.>>

Reading:
2024-06-04 17:17:03.677 Ble: Type: 0, Mac: 36 67 7e 50 a0 00 , status: 0x0 // 7
should be another one here? or is it supposed behavior?


For full database with service changed, did the math and I got : 8  ( might have missed something, its been a while...😅., here all: )

Default: 

 5 bytes for the GATT service (2 bytes for handle + 3 bytes for service 16-bit UUID)

+ 7 bytes for the Service Changed characteristic (2 bytes for handle + 3 bytes for service 16-bit UUID + 2 bytes for CCCD)

+ 5 bytes for the GAP service (2 bytes for handle + 3 bytes for service 16-bit UUID)

+ 5 bytes for the Device Name characteristic (2 bytes for handle + 3 bytes for service 16-bit UUID)

+ 5 bytes for the Appearance characteristic (2 bytes for handle + 3 bytes for service 16-bit UUID)

+ 5 bytes for the Peripheral Preferred Connection Parameters characteristic (2 bytes for handle + 3 bytes for service 16-bit UUID) = 32 

For each service ( I have 2 of them) : 
Service 128 : 2 (handle) + 17(UUID_128) = 19 
Custom characteristic CCCD: 2(handle) + 17(UUID_128)  + 2(cccd) = 21
Custom characteristic NON CCCD: 2(handle) + 17(UUID_128)  = 19

size_of_gatt record: 32 + 2 * (  19 + 21 + 19 ) = 150

 n  = 2027 / ( 81  +  [150+1] )  = 8