/** * * \section COPYRIGHT * * Copyright 2013-2015 Software Radio Systems Limited * * \section LICENSE * * This file is part of the srsLTE library. * * srsLTE is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * srsLTE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * A copy of the GNU Affero General Public License can be found in * the LICENSE file in the top-level directory of this distribution * and at http://www.gnu.org/licenses/. * */ #include #include #include #include #include #include #include #include #include #include "srslte/srslte.h" #include "srslte/phy/rf/rf_utils.h" #ifndef DISABLE_RF #include "srslte/phy/rf/rf.h" #endif #define MHZ 1000000 #define SAMP_FREQ 1920000 #define FLEN 9600 #define FLEN_PERIOD 0.005 #define MAX_EARFCN 1000 int band = -1; int earfcn_start=-1, earfcn_end = -1; cell_search_cfg_t cell_detect_config = { SRSLTE_DEFAULT_MAX_FRAMES_PBCH, SRSLTE_DEFAULT_MAX_FRAMES_PSS, SRSLTE_DEFAULT_NOF_VALID_PSS_FRAMES, 0 }; struct cells { srslte_cell_t cell; float freq; int dl_earfcn; float power; }; struct cells results[1024]; float rf_gain = 70.0; char *rf_args=""; void usage(char *prog) { printf("Usage: %s [agsendtvb] -b band\n", prog); printf("\t-a RF args [Default %s]\n", rf_args); printf("\t-g RF gain [Default %.2f dB]\n", rf_gain); printf("\t-s earfcn_start [Default All]\n"); printf("\t-e earfcn_end [Default All]\n"); printf("\t-n nof_frames_total [Default 100]\n"); printf("\t-v [set srslte_verbose to debug, default none]\n"); } void parse_args(int argc, char **argv) { int opt; while ((opt = getopt(argc, argv, "agsendvb")) != -1) { switch(opt) { case 'a': rf_args = argv[optind]; break; case 'b': band = atoi(argv[optind]); break; case 's': earfcn_start = atoi(argv[optind]); break; case 'e': earfcn_end = atoi(argv[optind]); break; case 'n': cell_detect_config.max_frames_pss = atoi(argv[optind]); break; case 'g': rf_gain = atof(argv[optind]); break; case 'v': srslte_verbose++; break; default: usage(argv[0]); exit(-1); } } if (band == -1) { usage(argv[0]); exit(-1); } } int srslte_rf_recv_wrapper(void *h, cf_t *data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t *t) { DEBUG(" ---- Receive %d samples ---- \n", nsamples); void *ptr[SRSLTE_MAX_PORTS]; for (int i=0;i 0) { for (int i=0;i<3;i++) { if (found_cells[i].psr > 10.0) { srslte_cell_t cell; cell.id = found_cells[i].cell_id; cell.cp = found_cells[i].cp; int ret = rf_mib_decoder(&rf, 1, &cell_detect_config, &cell, NULL); if (ret < 0) { fprintf(stderr, "Error decoding MIB\n"); exit(-1); } if (ret == SRSLTE_UE_MIB_FOUND) { printf("Found CELL ID %d. %d PRB, %d ports\n", cell.id, cell.nof_prb, cell.nof_ports); if (cell.nof_ports > 0) { memcpy(&results[n_found_cells].cell, &cell, sizeof(srslte_cell_t)); results[n_found_cells].freq = channels[freq].fd; results[n_found_cells].dl_earfcn = channels[freq].id; results[n_found_cells].power = found_cells[i].peak; n_found_cells++; } } } } } } printf("\n\nFound %d cells\n", n_found_cells); for (int i=0;i