diff --git a/df_datalink_sp/src/networking/link_layer/scan.c b/df_datalink_sp/src/networking/link_layer/scan.c index 77ce0b6..1776942 100644 --- a/df_datalink_sp/src/networking/link_layer/scan.c +++ b/df_datalink_sp/src/networking/link_layer/scan.c @@ -26,7 +26,9 @@ /************************** Constant Definitions *****************************/ #define ADV_LISTEN_TIMEOUT 40 -#define CFM_LISTEN_TIMEOUT 40 +#define CFM_LISTEN_TIMEOUT 25 +#define ADV_FRAME_SLOTS 4 +#define CFM_FRAME_SLOTS 4 /***************** Macros (In-line Functions) Definitions *********************/ /**************************** Type Definitions *******************************/ @@ -193,15 +195,16 @@ static int32_t Scan_CfmHandler(L2_INST *instPtr) { DBG_WARNING("Cmf timeout, restart net scan from L2_SCAN_INIT_STAGE.\n"); L2_Scan_Reset(scanFsmPtr); + return SUCCESS; } - else + if (L2_GetNextSlotNum(instPtr) % CFM_FRAME_SLOTS == 0) { + // using pull mode to receive confirm frame + // since first time sync procedure is accomplished in ADV stage. + Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL); + L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME); scanFsmPtr->cfmTimeout++; // increase counter. } - // using pull mode to receive confirm frame - // since first time sync procedure is accomplished in BM stage. - Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL); - L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME); return SUCCESS; }