STM32WB: Handle re-init case of transport layer

Issue was seen when running BLE_GAP example from
mbed-os-example-ble.

In STM32WB, the M0 core cannot be reset except if the whole target
is reset. So in case of re-initialization of the BLE stack, the
transport layer should not be initialized again. The HCI reset
command will do the job.
pull/10326/head
Laurent Meunier 2019-03-20 18:40:14 +01:00 committed by Martin Kojtal
parent d50f6e2690
commit e6cecda33b
1 changed files with 26 additions and 6 deletions

View File

@ -64,7 +64,6 @@
/* activate to add debug traces */
#define PRINT_HCI_DATA 1
/******************************************************************************
* BLE config parameters
******************************************************************************/
@ -76,6 +75,7 @@ static bool acl_data_wait(void);
static void init_debug( void );
static bool get_bd_address( uint8_t* bd_addr );
static bool sysevt_wait( void);
static bool sysevt_check( void);
namespace ble {
@ -439,10 +439,15 @@ public:
* @see CordioHCITransportDriver::initialize
*/
virtual void initialize() {
/* Check whether M0 sub-system was started already by
* checking if the system event was already received
* before. If it was not, then go thru all init. */
if(!sysevt_check()) {
init_debug();
stm32wb_reset();
transport_init();
}
}
/**
* @see CordioHCITransportDriver::terminate
@ -752,6 +757,21 @@ static bool sysevt_wait( void) {
if(sys_event_sem.wait(10000) < 1) {
return false;
} else {
/* release immmediately, now that M0 runs */
sys_event_sem.release();
return true;
}
}
/* returns true if ssyevt was already received, which means M0 core is
* already up and running */
static bool sysevt_check( void) {
/* Check if system is UP and runing already */
if(sys_event_sem.wait(10) < 1) {
return false;
} else {
/* release immmediately as M0 already runs */
sys_event_sem.release();
return true;
}
}