cancel
Showing results for 
Search instead for 
Did you mean: 

BLE: How can I get a SCAN REQUEST event?

A&A
Associate II

Hello,

Recently I started working with Nucleo board with STM32WB55 and I would appreciate if somebody could help me with this issue about BLE. I never worked with the BLE stack before and I am quite lost and confused.

I am working in a project where I only need to detect the SCAN REQUEST. In the learning process of STM32WB, I found the very useful MOOCs and more specifically “STM32WB Workshop – 3 How to add BLE funcionality�?. It Works with the project “HandsOn2�? supplied by ST.

https://www.youtube.com/watch?v=zNfIGh30kSs&list=PLnMKNibPkDnGRfqUO1Q_-1nW-tOKfDQbc&index=4

Among other things, it explains how to blink a LED every time a radio RF activity finishes, using Radio Activity Event. I thought following the steps of this event would be a good way to get a SCAN REQUEST event, but unfortunately so far I have not achieved anything.

Please find below the pseudo code of app_ble.c file, where the radio RF activity is mentioned.

-         In the APP_BLE_Init() funtion the radio activity event mask is defined:

aci_hal_set_radio_activity_mask(0x0006);

-         In the SVCCTL_App_Notification() function you could find ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE, and here is where the previously mentioned LED blink is set.

//==========================================
void APP_BLE_Init( void )
{
	...
#if(RADIO_ACTIVITY_EVENT != 0)										
  aci_hal_set_radio_activity_mask(0x0006);
#endif
	....
}
 
//==========================================
SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
{
  hci_event_pckt *event_pckt;
  evt_blue_aci *blue_evt;
 
  event_pckt = (hci_event_pckt*) ((hci_uart_pckt *) pckt)->data;
 
  switch (event_pckt->evt)
  {
     case EVT_DISCONN_COMPLETE:
    	...
    	break; 
     case EVT_LE_META_EVENT:
    	...
    	break; 
     case EVT_VENDOR:
       blue_evt = (evt_blue_aci*) event_pckt->data;
       switch (blue_evt->ecode)
       {
           // SPECIFIC to P2P Server APP
           case EVT_BLUE_L2CAP_CONNECTION_UPDATE_RESP:
		...
      		break;
        
           case EVT_BLUE_GAP_PROCEDURE_COMPLETE:
	        ...
                break; 
 
	   #if(RADIO_ACTIVITY_EVENT != 0)
           case ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE:
        	/* USER CODE BEGIN RADIO_ACTIVITY_EVENT*/
		// Blink Green LED every time radio RF activity finishes.
                HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET);	
        	HAL_Delay(5);																															
        	HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET);		
         	/* USER CODE END RADIO_ACTIVITY_EVENT*/
               break; 
	  #endif
      }// switch (blue_evt->ecode)
      
      break; /* EVT_VENDOR */
 
     default:
  	break;
  }// switch (event_pckt->evt)
  return (SVCCTL_UserEvtFlowEnable);
}

So, how should I define scan request event mask?.

Should I use aci_hal_set_event_mask()?

In that case, should it be aci_hal_set_event_mask(5) or aci_hal_set_event_mask(1)?

Where should I locate case ACI_HAL_SCAN_REQ_REPORT_VSEVT_CODE: in switch (event_pckt->evt) or in switch (blue_evt->ecode).

 

0693W000008wGbQQAU.jpg 

The point is that I tried every combinations but it doesn´t work. I´m afraid I´m wrong and I´m missing something, but I don´t know what? Any help will be appreciated. 

Thank you in advance.

0 REPLIES 0