mirror of https://github.com/PentHertz/srsLTE.git
Cell search example looks for 3 cells per frequency
This commit is contained in:
parent
3844d19916
commit
182c9958bb
|
@ -53,7 +53,7 @@ int band = -1;
|
|||
int earfcn_start=-1, earfcn_end = -1;
|
||||
int nof_frames_total = 50;
|
||||
int nof_frames_detected = 10;
|
||||
float threshold = -1;
|
||||
float threshold = CS_FIND_THRESHOLD;
|
||||
|
||||
|
||||
float uhd_gain = 60.0;
|
||||
|
@ -171,7 +171,7 @@ int decode_pbch(void *uhd, cf_t *buffer, ue_celldetect_result_t *found_cell)
|
|||
return LIBLTE_SUCCESS;
|
||||
}
|
||||
|
||||
int find_cell(void *uhd, ue_celldetect_t *s, cf_t *buffer, ue_celldetect_result_t *found_cell)
|
||||
int find_cell(void *uhd, ue_celldetect_t *s, cf_t *buffer, ue_celldetect_result_t found_cell[3])
|
||||
{
|
||||
int n;
|
||||
|
||||
|
@ -190,7 +190,7 @@ int find_cell(void *uhd, ue_celldetect_t *s, cf_t *buffer, ue_celldetect_result_
|
|||
return LIBLTE_ERROR;
|
||||
}
|
||||
|
||||
n = ue_celldetect_scan(s, buffer, flen, found_cell);
|
||||
n = ue_celldetect_scan(s, buffer, flen, &found_cell[nof_scanned_cells]);
|
||||
switch(n) {
|
||||
case CS_FRAME_UNALIGNED:
|
||||
printf("Realigning frame\n");
|
||||
|
@ -200,10 +200,12 @@ int find_cell(void *uhd, ue_celldetect_t *s, cf_t *buffer, ue_celldetect_result_
|
|||
}
|
||||
return LIBLTE_ERROR;
|
||||
case CS_CELL_DETECTED:
|
||||
if (found_cell->peak > 0) {
|
||||
if (found_cell[nof_scanned_cells].peak > 0) {
|
||||
printf("\n\tCELL ID: %d, CP: %s, Peak: %.2f, Mode: %d/%d\n",
|
||||
found_cell->cell_id, lte_cp_string(found_cell->cp),
|
||||
found_cell->peak, found_cell->mode, s->nof_frames_detected);
|
||||
found_cell[nof_scanned_cells].cell_id,
|
||||
lte_cp_string(found_cell[nof_scanned_cells].cp),
|
||||
found_cell[nof_scanned_cells].peak, found_cell[nof_scanned_cells].mode,
|
||||
s->nof_frames_detected);
|
||||
}
|
||||
|
||||
nof_scanned_cells++;
|
||||
|
@ -216,7 +218,7 @@ int find_cell(void *uhd, ue_celldetect_t *s, cf_t *buffer, ue_celldetect_result_
|
|||
fprintf(stderr, "Error calling cellsearch_scan()\n");
|
||||
return LIBLTE_ERROR;
|
||||
}
|
||||
} while(nof_scanned_cells < 3 && n != CS_CELL_DETECTED);
|
||||
} while(nof_scanned_cells < 3);
|
||||
|
||||
INFO("Stopping receiver...\n", 0);
|
||||
cuhd_stop_rx_stream(uhd);
|
||||
|
@ -229,7 +231,7 @@ int main(int argc, char **argv) {
|
|||
int n;
|
||||
void *uhd;
|
||||
ue_celldetect_t s;
|
||||
ue_celldetect_result_t found_cell;
|
||||
ue_celldetect_result_t found_cells[3];
|
||||
cf_t *buffer;
|
||||
int nof_freqs;
|
||||
lte_earfcn_t channels[MAX_EARFCN];
|
||||
|
@ -286,18 +288,22 @@ int main(int argc, char **argv) {
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
n = find_cell(uhd, &s, buffer, &found_cell);
|
||||
n = find_cell(uhd, &s, buffer, found_cells);
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "Error searching cell\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (n == CS_CELL_DETECTED) {
|
||||
if (decode_pbch(uhd, buffer, &found_cell)) {
|
||||
for (int i=0;i<3;i++) {
|
||||
if (found_cells[i].peak > threshold/2) {
|
||||
if (decode_pbch(uhd, buffer, &found_cells[i])) {
|
||||
fprintf(stderr, "Error decoding PBCH\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ue_celldetect_free(&s);
|
||||
cuhd_close(uhd);
|
||||
|
|
|
@ -280,8 +280,8 @@ int sync_find(sync_t *q, cf_t *input, uint32_t find_offset, uint32_t *peak_posit
|
|||
ret = LIBLTE_SUCCESS;
|
||||
}
|
||||
|
||||
INFO("SYNC ret=%d pos=%d peak=%.2f energy=%.3f threshold=%.2f sf_idx=%d\n",
|
||||
ret, peak_pos, q->peak_value, energy, q->threshold, q->sf_idx);
|
||||
INFO("SYNC ret=%d N_id_2=%d pos=%d peak=%.2f energy=%.3f threshold=%.2f sf_idx=%d\n",
|
||||
ret, q->N_id_2, peak_pos, q->peak_value, energy, q->threshold, q->sf_idx);
|
||||
|
||||
} else if (lte_N_id_2_isvalid(q->N_id_2)) {
|
||||
fprintf(stderr, "Must call sync_set_N_id_2() first!\n");
|
||||
|
|
|
@ -211,7 +211,7 @@ int ue_celldetect_scan(ue_celldetect_t * q,
|
|||
for (uint32_t nf=0;nf<nof_input_frames;nf++) {
|
||||
sync_set_N_id_2(&q->sfind, q->current_N_id_2);
|
||||
|
||||
printf("[%3d/%3d]: Searching cells with N_id_2=%d. %d frames\n",
|
||||
DEBUG("[%3d/%3d]: Searching cells with N_id_2=%d. %d frames\n",
|
||||
q->current_nof_detected, q->current_nof_total, q->current_N_id_2, nof_input_frames);
|
||||
|
||||
/* Find peak and cell id */
|
||||
|
|
Loading…
Reference in New Issue