Hello,
I use GAPRole_TerminateConnection() to terminate a link immediately after connection was created.
However, I see that the link remains connected so I'm obviously missing something here... :~\
Follow is the disconnect method:
void BLEDisconnect() { uint8 advert; bStatus_t status; status = GAPRole_TerminateConnection(); // disconnect link advert = false; GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advert ); // force stop advertising }
This code is being called within osal event that has been triggered upon receiving GAPROLE_CONNECTED event in peripheralStateNotificationCB() in the following manner:
static void peripheralStateNotificationCB( gaprole_States_t newState ) { switch ( newState ) { case GAPROLE_STARTED: { // do something break; case GAPROLE_ADVERTISING: // do something break; case GAPROLE_CONNECTED: // do something break; } StateChangeMessage_t *msgPtr; msgPtr = (StateChangeMessage_t*)osal_msg_allocate(sizeof(StateChangeMessage_t)); if(msgPtr) { msgPtr->Header.event = STATE_CHANGE_MESSAGE_TYPE; msgPtr->Payload.gapState = newState; osal_msg_send(peripheral_TaskID , (uint8*) msgPtr); // when creating a connection osal_message is sent.
// The message processing loop intercepts the message and calls to BLEDisconnect() described above.
// Is there any chance that the message is being processed BEFORE } gapProfileState = newState; }
My questions regarding link termination are:
1. Is GAPRole_TerminateConnection() executed immediately when called or its deferred by the stack ?
2. If deferred, can it be cancelled before being executed ?
3. If deferred, Is it scheduled by the BLE stack using osal-like scheduling (non-preemptive) or is it done in a more 'preemptive manner' using HW interrupts ?
Another general BLE question regarding re-connection of a terminated link:
4. If link was terminated by the peripheral as described above and supervision timeout has not elapsed, can the peripheral re establish connection without advertising ?
Many thanks for any support