Commit c7439dcc authored by Nick Ho's avatar Nick Ho

Add state machine into rach

parent 7bdee0c7
......@@ -99,6 +99,13 @@
/*!\brief LCID of padding LCID for DLSCH */
#define SHORT_PADDING 31
typedef enum rach_state_e
{
initial_access = 0,
rach_for_auth_rsp,
rach_for_next,
}rach_state_t;
typedef enum tone_type_e
{
......
......@@ -36,7 +36,6 @@
unsigned char str20[] = "DCI_uss";
unsigned char str21[] = "DATA_uss";
int second_flag = 0;
// scheduling UL
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info,uint32_t subframe, uint32_t frame, uint32_t H_SFN, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info){
......@@ -235,10 +234,6 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
{
LOG_I(MAC,"Find UE in CE 2 list, update ul_total_buffer to %d bytes\n",BSR_table[BSR_index]);
UE_info->ul_total_buffer = BSR_table[BSR_index];
if (UE_info->ul_total_buffer >= 10 && UE_info->ul_total_buffer <= 20)
{
second_flag = 1;
}
}
else
LOG_E(MAC,"UE info empty\n");
......@@ -287,7 +282,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
case DCCH0_NB_IoT:
case DCCH1_NB_IoT:
LOG_I(MAC,"DCCH PDU Here\n");
if(second_flag == 0)
if((UE_state_machine == initial_access)||(UE_state_machine == rach_for_next))
{
mac_rlc_data_ind(
module_id,
......@@ -308,7 +303,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
UE_info->direction = 1; //1 for DL scheduler
LOG_I(MAC,"After receive Msg5, change the UE scheduling direction to DL\n");
}
}else if (second_flag == 1)
}else if (UE_state_machine == rach_for_auth_rsp)
{
LOG_N(MAC,"Here we are for the DCI N0 generating \n");
if (UE_info != NULL)
......@@ -316,7 +311,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
UE_info->direction = 0; //1 for DL scheduler
LOG_I(MAC,"Change direction into 0\n");
}
second_flag = 0;
UE_state_machine = rach_for_next;
}
break;
......
......@@ -113,6 +113,8 @@ extern const int dl_rep[3];
extern const uint32_t dci_rep[3];
extern const uint32_t harq_rep[3];
extern rach_state_t UE_state_machine;
//SIBs
extern int extend_space[2];
extern int extend_alpha_offset[2];
......
......@@ -140,6 +140,8 @@ int extend_alpha_offset[2] = {10, 10};
int uss_space = 320;
int uss_alpha_offset = 10;
rach_state_t UE_state_machine = initial_access;
const int si_repetition_pattern[4] = {20, 40, 80, 160};
#endif
......
......@@ -3,7 +3,7 @@
#include "LAYER2/MAC/extern_NB_IoT.h"
int tmp = 0;
int block_rach = 0;
//int block_rach = 0;
int first_msg4 = 0;
void simulate_preamble(UL_IND_NB_IoT_t *UL_INFO, int CE, int sc)
......@@ -94,7 +94,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
//for(i=0;i<UL_INFO->nrach_ind.number_of_initial_scs_detected;i++)
for(i=0;i<1;i++)
{
if(block_rach == 0 )
if(UE_state_machine == initial_access )
{
// initiate_ra here, some useful inforamtion :
LOG_D(MAC,"Init_RA_NB_IoT in, index of sc = %d\n",(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc);
......@@ -105,7 +105,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
//timing_offset = Timing_advance * 16
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
);
}else if (block_rach == 1)
}else if (UE_state_machine == rach_for_auth_rsp)
{
LOG_N(MAC,"It is the second time that this UE try to rach\n");
init_RA_NB_IoT(mac_inst,
......@@ -154,7 +154,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
LOG_I(MAC,"This UE get the response of HARQ DL : ACK, update the UL buffer for next message\n");
ue_info->direction=-1;
//ue_info->ul_total_buffer = 11;
block_rach = 1;
UE_state_machine = rach_for_auth_rsp;
//LOG_I(MAC,"This UE get the response of HARQ DL : NACK, and will start the next harq round : %d\n",ue_info->HARQ_round);
//ue_info->direction=1;
//ue_info->HARQ_round++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment