2025-04-22 1:47 PM
Hello.
I have problems turning BLE on and off on STM32WB55.
Many examples with BLE start with the lines
MX_APPE_Config();
MX_IPCC_Init();
MX_RF_Init();
MX_APPE_Init();
I do the same, and it turns on right away. I don't know how to initialize the sequencer and timeservers by themselves without BLE, so for now, I found a workaround. I turn it off using the RTC timer using the code the esteemed @FilipKremen provided me
static void BLE_exit()
{
tBleStatus ret;
if (BleApplicationContext.Device_Connection_Status != APP_BLE_IDLE)
{
ret = aci_gap_terminate(BleApplicationContext.BleApplicationContext_legacy.connectionHandle, 0x13);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG("aci_gap_terminate(), Failed \r\n\r");
}
else
{
APP_DBG_MSG("aci_gap_terminate(), Successfully \r\n\r");
}
}
ret = aci_hal_stack_reset();
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG("aci_hal_stack_reset(), Failed \r\n\r");
}
else
{
APP_DBG_MSG("aci_hal_stack_reset(), Successfully \r\n\r");
}
}
Then I have buttons on the sequencer tasks, and the time server is still working, and I don't really understand how to enable Bluetooth with a button. Should I somehow reinitialize everything? But how can I not affect the logic of the sequencer and time server? I try to use this function
appe_Tl_Init(); /* Initialize all transport layers */
from MX_APPE_Init in the button handler, but nothing happens, and sometimes it even hits the error handler.
Also, maybe there is a more correct way to initialize the sequencer and timeserver without initializing the BLE? How should it be turned on correctly, then?
Also, I wonder how good the idea of using a sequencer and timeserver is for processing the logic of buttons and LEDs? I think that's what it was intended for?
I would be extremely grateful for your help.
Solved! Go to Solution.
2025-04-28 6:07 AM
Hello,
you can do it by not calling the appe_Tl_Init() function in MX_APPE_init().
Please note, if you're first time enabling BLE, the appe_Tl_Init() function should be called without SHCI_C2_Reinit().
Once the CPU2 is running and the second time you will be enabling BLE, call the SHCI_C2_Reinit() function before appe_Tl_Init().
Best regards,
ST support
2025-04-23 12:46 AM
Hello,
can you please describe more in detail what are you trying to achieve in your project?
Thank you.
Best regards,
Filip Kremen
2025-04-24 4:28 AM - edited 2025-04-24 4:30 AM
Hello
Thank you very much for your reply
I am trying to make the logic work like this: I turn on the device with a button (it does some work unrelated to the BLE, but it works in conjunction with the sequencer and the timeserver, which handles buttons and LEDs and triggering tasks with a timer), then I can press another button and the BLE turns on. Then I can turn off the BLE using the same button (or turn off the entire device using the on/off button). So I have two buttons, one to turn the device on/off and the other to turn the BLE on/off. Let me know if I misunderstood the question.
2025-04-25 3:56 AM
Hello,
if you want to enable BLE again, please try to call SHCI_C2_Reinit() function before appe_Tl_Init().
Best regards,
ST support
2025-04-25 10:08 AM
Hello,
It helped to enable BLE again, thank you. Is there a correct way to prevent BLE from turning on when starting the device? Would it be correct to call the function to disable BLE at the end of APPE_SysUserEvtRx, as you suggested in the neighboring thread, or is there another more correct approach?
2025-04-28 4:06 AM
Hello.
I'm sorry. I replied on Friday evening, so the work day is over, and I'm wondering if you saw my message.
2025-04-28 6:07 AM
Hello,
you can do it by not calling the appe_Tl_Init() function in MX_APPE_init().
Please note, if you're first time enabling BLE, the appe_Tl_Init() function should be called without SHCI_C2_Reinit().
Once the CPU2 is running and the second time you will be enabling BLE, call the SHCI_C2_Reinit() function before appe_Tl_Init().
Best regards,
ST support
2025-04-29 11:46 AM
Thank you very much! You are a savior in this section of the forum.