#include #include #include #include #include #include "lte.h" char *input_file_name = NULL; int nof_slots=100; float corr_peak_threshold=2.5; int ntime = 4; int nfreq = 10; int file_binary = 0; int force_N_id_2=-1; filesource_t fsrc; cf_t *input_buffer, *fft_buffer; pbch_t pbch; dft_plan_t fft_plan; chest_t chest; sync_t synch; void usage(char *prog) { printf("Usage: %s [onlt] -i input_file\n", prog); printf("\t-n number of frames [Default %d]\n", nof_slots); printf("\t-t correlation threshold [Default %g]\n", corr_peak_threshold); printf("\t-v [set verbose to debug, default none]\n"); printf("\t-b Input files is binary [Default %s]\n", file_binary?"yes":"no"); printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2); } void parse_args(int argc, char **argv) { int opt; while ((opt = getopt(argc, argv, "intvbf")) != -1) { switch(opt) { case 'i': input_file_name = argv[optind]; break; case 'n': nof_slots = atoi(argv[optind]); break; case 't': corr_peak_threshold = atof(argv[optind]); break; case 'b': file_binary = 1; break; case 'v': verbose++; break; case 'f': force_N_id_2 = atoi(argv[optind]); break; default: usage(argv[0]); exit(-1); } } if (!input_file_name) { usage(argv[0]); exit(-1); } } int base_init() { file_data_type_t type = file_binary?COMPLEX_FLOAT_BIN:COMPLEX_FLOAT; if (filesource_init(&fsrc, input_file_name, type)) { fprintf(stderr, "Error opening file %s\n", input_file_name); exit(-1); } input_buffer = malloc(4 * 960 * sizeof(cf_t)); if (!input_buffer) { perror("malloc"); exit(-1); } fft_buffer = malloc(CPNORM_NSYMB * 128 * sizeof(cf_t)); if (!fft_buffer) { perror("malloc"); return -1; } /* Init FFT plan */ if (dft_plan_c2c(128, FORWARD, &fft_plan)) { fprintf(stderr, "Error initiating FFT plan\n"); return -1; } fft_plan.options = DFT_DC_OFFSET | DFT_MIRROR_POS | DFT_NORMALIZE; DEBUG("Memory init OK\n",0); return 0; } int mib_decoder_init(int cell_id) { /* if (chest_LTEDL_init(&chest, ntime, nfreq, CPNORM_NSYMB, cell_id, 6)) { fprintf(stderr, "Error initiating LTE equalizer\n"); return -1; } */ DEBUG("Channel estimation initiated ntime=%d nfreq=%d\n", ntime, nfreq); if (pbch_init(&pbch, cell_id, CPNORM)) { fprintf(stderr, "Error initiating PBCH\n"); return -1; } DEBUG("PBCH initiated cell_id=%d\n", cell_id); return 0; } void fft_run_slot(dft_plan_t *fft_plan, cf_t *input, cf_t *output) { int i; for (i=0;i= 4) { state = SYNC; } } mib_attempts++; } break; case DONE: INFO("State Done, Slot idx=%d\n", slot_idx); pbch_mib_fprint(stdout, &mib); printf("Done\n"); break; } if (read_length) { slot_idx++; if (slot_idx == 20) { slot_idx = 0; } } } sync_free(&synch); filesource_close(&fsrc); free(input_buffer); printf("Done\n"); exit(0); }