cancel
Showing results for 
Search instead for 
Did you mean: 

Add Scan_Request to BLE_Custom example

Francesco1234
Associate II

Sono partito dall'esempio BLE personalizzato per il core WB55RG, che esegue regolarmente Advertising. Tuttavia, ora vorrei aggiungere una scan_request (sto cercando di replicare l'esempio P2P_router partendo da un esempio BLE_custom per avere servizi e caratteristiche personalizzabili con CubeMX, ma ogni volta che lancio una richiesta di scansione ottengo un errore, più precisamente, aci_gap_start_general_discovery_proc() restituisce 0x0c [non consentito].

 

Qualcuno ha dei suggerimenti???

Ho allegato il mio app_ble.c dove, rispetto all'esempio BLE_custom, ho aggiunto solo la funzione Scan_Request (alla fine del file) che viene chiamata quando premo il pulsante sw1.

4 REPLIES 4
Francesco1234
Associate II

Sorry, i traslate in english.

 

I started from the custom BLE example for the WB55RG core, which is regularly performing Advertising. However, now I would like to add a scan_request (I'm trying to replicate the P2P_router example starting from a BLE_custom example to have customizable services and characteristics with CubeMX, but every time I launch a scan request I get an error, more precisely, aci_gap_start_general_discovery_proc() returns 0x0c [not allowed] .

Does anyone have any suggestions???

I have attached my app_ble.c where, compared to the BLE_custom example, I have only added the Scan_Request function (at the end of the file) which is called when I press the sw1 button.

Lubos KOUDELKA
ST Employee

Hello,
could you please check your application log - receiving 0x0c on aci_gap_start_general_discovery_proc would be expected if you call aci_gap_start_general_discovery_proc while discovery is already ongoing. It's expected first aci_gap_start_general_discovery_proc call will be successful, then before next call you need either terminate scanning or wait for previous scanning timeout (10.24 s).
What is the status for first call of aci_gap_start_general_discovery_proc?
I'm expecting you have set both peripheral and central role in aci_gap_init, right? Ensured by having set in ble_conf.h

#define BLE_CFG_PERIPHERAL                                                     1
#define BLE_CFG_CENTRAL                                                        1

Best regards,
Lubos

Thank you for your response. I had configured the following settings in STM32CubeMX:

  • Peripheral: Advertise and connectable → Yes
  • Central: Scan and connect → Yes

(as indicated in the following wiki: https://wiki.st.com/stm32mcu/wiki/Connectivity:STM32WB_BLE_STM32CubeMX)

However, every time I make a change with CubeMX and update the code, I notice that:

  • #define BLE_CFG_PERIPHERAL remains set to 1
  • #define BLE_CFG_CENTRAL reverts to 0

This means I hadn’t realized that BLE_CFG_CENTRAL was actually 0. I must have misunderstood something. How can I ensure that BLE_CFG_CENTRAL remains set to 1 even when updating the code with CubeMX?

Hello @Francesco1234 

To guarantee that both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL macro still be set to 1, you should set the BLE Application Type to Router profil on your CubeMX .ioc file:

STTwo32_0-1742815135734.png

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.