cancel
Showing results for 
Search instead for 
Did you mean: 

[BLE RSSI] Reading RSSI value uint8_t

Portilha
Associate II

Hello, I am working with STM32WBA52CG as a central and I want to read the RSSI from the incoming advertising packets. The RSSI value should be a negative value in dBm, however it is defined as uint8_t in the AdvertisingReport_t structure. Can someone explain me how to get the correct RSSI value? I am getting the values shown on the terminal below.

... } bleAppContext.BleApplicationContext_legacy.connectionHandle = p_conn_complete->Connection_Handle; GATT_CLIENT_APP_Set_Conn_Handle(0, p_conn_complete->Connection_Handle); /* USER CODE BEGIN HCI_EVT_LE_CONN_COMPLETE */ /* USER CODE END HCI_EVT_LE_CONN_COMPLETE */ break; /* HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE */ } case HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE: { hci_le_advertising_report_event_rp0 *p_adv_report; p_adv_report = (hci_le_advertising_report_event_rp0 *) p_meta_evt->data; UNUSED(p_adv_report); /* USER CODE BEGIN HCI_EVT_LE_ADVERTISING_REPORT */ uint8_t rssi = p_adv_report->Advertising_Report[0].RSSI; LOG_INFO_APP("RSSI from struct: %d , ", rssi); /* USER CODE END HCI_EVT_LE_ADVERTISING_REPORT */ break; /* HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE */ } ...

 Screenshot from 2024-02-12 10-41-02.png

17 REPLIES 17
_Joe_
ST Employee

Ok perfect, I mean, have you tried starting from a new code (ex : p2pClient), without any modification except the macro to get the RSSI?

Yes, I took the ST P2PClient with version 1.2.0 and I only added the following line codes:

APP_BLE_Init(void)

... /* USER CODE BEGIN APP_BLE_Init_2 */ APP_BLE_Procedure_Gap_Central(PROC_GAP_CENTRAL_SCAN_START); /* USER CODE END APP_BLE_Init_2 */ ...

SVCCTL_App_Notification(void)

... case HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE: { hci_le_advertising_report_event_rp0 *p_adv_report; p_adv_report = (hci_le_advertising_report_event_rp0 *) p_meta_evt->data; UNUSED(p_adv_report); /* USER CODE BEGIN HCI_EVT_LE_ADVERTISING_REPORT */ int8_t rssi = HCI_LE_ADVERTISING_REPORT_RSSI_0(p_meta_evt->data); LOG_INFO_APP("RSSI: %d\r\n", rssi); /* USER CODE END HCI_EVT_LE_ADVERTISING_REPORT */ break; /* HCI_LE_ADVERTISING_REPORT_SUBEVT_CODE */ } ...

 The RSSI just keeps returning 0. There must be some kind of bug on your library, is it possible to provide a fix or any kind of solution to read the RSSI value from incoming packets while the STM is working as a central?

The problem arises because you are using the examples from STM32WBA55 of release v1.2.0 while you have an STM32WBA52.
With the STM32WBA52 examples, which you can find in release v1.1.1, you should no longer encounter the RSSI problem after adding the previously given macro.

BR,
Joé

I have build the p2pClient project from the github you have sent me but the problem remains. I added the macro and the code line to start scanning. RSSI always returns 0.

Screenshot from 2024-02-15 14-51-42.png

_Joe_
ST Employee

In the bottom of your screenshot, we can see that your project still uses v1.2.0.

But how can I use the 1.1.1? I used the .ioc file in the Github link that you provided and it still generates 1.2.0 version on the project.

Even if I delete the firmware files and replace them by version 1.1.1 the STM32CubeIDE automatically downloads the 1.2.0 version and replaces it, making it Impossible to use that version.

Have you found any solution for the RSSI problem?