This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
代码如下:
if(events & SBP_BLE_SLEEP_EVT)
{
SBP_BLE_Sleep_Func();
return (events ^ SBP_BLE_SLEEP_EVT);
}
void SBP_BLE_Sleep_Func(void)
{
if(Ble_rf.Ble_EnableSleepFlg != false)
{
U8 Adv_Status;
os_env.BLE_statu = 2;
os_env.lock_Comm_Mone = 4;
Adv_Status = false;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof(U8), &Adv_Status);
GAPRole_TerminateConnection();
Ble_rf.Ble_EnableSleepFlg = false;
osal_stop_timerEx(gu8_simpleBLEPeripheral_TaskID,SBP_BLE_SLEEP_EVT);
}
}
从机断开后,有时候会出现无法进入GAP_LINK_TERMINATED_EVENT的情况,请问这是为什么呢?
使用GAPRole_TerminateConnection,要进入GAP_LINK_TERMINATED_EVENT的话,要传入参数,检查下传入参数是否正确
* @brief Terminates the existing connection.
*
* Public function defined in peripheral.h.
*/
bStatus_t GAPRole_TerminateConnection(void)
{
if ((gapRole_state == GAPROLE_CONNECTED) ||
(gapRole_state == GAPROLE_CONNECTED_ADV))
{
return (GAP_TerminateLinkReq(selfEntity, gapRole_ConnectionHandle,
HCI_DISCONNECT_REMOTE_USER_TERM));
}
else
{
return (bleIncorrectMode);
}
}