cancel
Showing results for 
Search instead for 
Did you mean: 

How do you implement pairing and authentication with the STM32WB?

Louis Loving
Senior

I have read AN5289 and it does touch on the subject but there is not enough detail in it to get to a working solution.

From my code:

 /**
   * Initialize authentication
   */
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.mitm_mode = CFG_MITM_PROTECTION;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.OOB_Data_Present = 0;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.encryptionKeySizeMin = 8;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.encryptionKeySizeMax = 16;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Use_Fixed_Pin = 1;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Fixed_Pin = 111111;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.bonding_mode = 2;
 

I would infer that a fixed pin is required and that fixed pin is 0x111111 but that is not the case.

Thanks for any help.

-Louis

8 REPLIES 8
Louis Loving
Senior

I found some details in AN5270.

0690X000009ZhfAQAS.png

So now I know what the settings mean but still can't require the use of a pin to connect.

I also set the bonding mode back to 1.

Louis Loving
Senior

I still do not seem to be able to get the STM32WB55 into a pairing mode. Here is a snippet of my code:

  /**
   * Initialize authentication
   */
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.mitm_mode = CFG_MITM_PROTECTION;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.OOB_Data_Present = 0;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.encryptionKeySizeMin = 8;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.encryptionKeySizeMax = 16;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Use_Fixed_Pin = 0;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Fixed_Pin = 111111;
  BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.bonding_mode = 1;
  for (index = 0; index < 16; index++)
  {
    BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.OOB_Data[index] = (uint8_t) index;
  }
 
  ret = aci_gap_set_authentication_requirement(BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.bonding_mode,
                                         BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.mitm_mode,
                                         1,
                                         0,
                                         BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.encryptionKeySizeMin,
                                         BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.encryptionKeySizeMax,
                                         BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Use_Fixed_Pin,
                                         BleApplicationContext.BleApplicationContext_legacy.bleSecurityParam.Fixed_Pin,
                                         0
  );
 
  if (ret != BLE_STATUS_SUCCESS)
  {
     Error_Handler();
  }

Bonding mode is set to 1 to enable bonding mode.

Use_Fixed_Pin is set to 0 to use a fixed pin.

MITM is set to 1 to require MITM protection.

Is there anything else that needs to be done to require the use of a fixed pin for bonding?

No matter what I do I seem to be stuck in the just works mode and my scanning software can connect with using a fixed pin.

Thanks for any help.

Here's a PDF (STM32WB_Pairing.pdf) that I got from STM that has helped with this question.

FMunc.1
Associate

Hi there. Did you actually made this happen? I am trying to create an Android App which communicates with the STM32WB55 Nucleo Board. I have set CFG to legacy mode, use fixed pin to 0 and fixed pin to 111111.

I am not able to force a popup to appear in my app, when I try to connect to STM32WB55. It always just connects directly.

I have found in the documentation, that a command called ACI_GAP_SET_AUTHORIZATION_REQUIREMENT maybe should do something for this?

Did you solved to make the microcontroller ask for a pin each time you tried to connect through an Android App?

~ Frederik

Hey Frederik,

I was eventually able to get everything that I needed working. I am not sure that it was what you are looking for though.

Several things really helped me figure out what was going on in my setup. Nordic Semiconductor makes some really nice tools that helped with my debug. Nordic RF Connect for desktop, Nordic RF for Mobile, and nRF52 DK were all critical for me to debug my setup. Using nRF52 as a BLE sniffer was an exceptionally nice find. Sometime the problem was with the STM32WB55 and other times it was the app. Having a sniffer lets you see how they are interacting.

It has been a while since I looked at this. I will take a look and see if anything else stands out that I can pass along.

-Louis

Hi there. Thanks for quick answer!

Did you use STM32WB55 Nucleo Board? In that case - did you not receive a USB Dongle with the nucleo board? I might think, that it is possible to use the USB dongle to debug the wireless connection - but I am not totally sure. I can see that NordicSemi have developed a dongle called nRF52840 which I believe is able to act just like the USB dongle that came with the STM32WB55 board.

https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-desktop

I guess a software sniffer will be a must for me to document the communication between the Nucleo board and my Android App.

~ Frederik​

Louis Loving
Senior

Sorry for the absence Frederik, I have been away for the last few days.

I used the nRF52-DK as my BLE sniffer. I did purchase the STM32WB55 Nucleo Board set and it has been helpful as well but, for me, it was lacking in some areas. The Nordic RF app for mobile running on my Android phone was also a big help. Once I learned how to use its features, they were very helpful.

Let me know if you hit any more roadblocks.

-Louis

Frederik, see my reply below.