Skip to main content
vd_it
Associate II
Jul 22, 2022 5:09 AM UTC
Question

stm32wb configure ble as observer in middleware without overridden by cubemx

I have generated ble middleware using cubemx with application type set to the server profile. I'd like the device to be able to advertise and scan for non-connectable ad's. Hence in the ble_conf.h I have set BLE_CFG_PERIPHERAL as well as BLE_CFG_CENTRAL to 1. However, in the Ble_Tl_Init( ), app_ble.c, I have overridden the ble central to use the observer role as shown below.

#if (BLE_CFG_PERIPHERAL == 1)
 role |= GAP_PERIPHERAL_ROLE;
#endif
 
#if (BLE_CFG_CENTRAL == 1)
 role |= GAP_OBSERVER_ROLE;//GAP_CENTRAL_ROLE;
#endif

I did the above so I can configure the device to advertise as well as scan for non-connectable advertisements using the aci_gap_start_observation_proc( ) API.

How do I prevent cubemx from overriding this change or is there a way I can achieve the same without having to manually make this change every time cubemx generates code?

PS: I did try configuring calling aci_gap_init( ) separately, to override the role settings but for some reason, it ends up in a fault handler, I don't remember exactly which one though. Before I go about trying to figure out why this happens, I'd like to check if there's an easier way out of this.

This topic has been closed for replies.

2 replies

vd_it
vd_itAuthor
Associate II
Jul 26, 2022 11:04 PM UTC

Isn't there anyone here that's come across this issue or advice on this?

Remy ISSALYS
ST Technical Moderator
Aug 24, 2022 1:15 PM UTC

Hello,

Indeed, there isn't any possibility to prevent cubeMX from overriding the modification. A user section will be added in order to manage the GAP role in the next version.

Best Regards