From 8694cc63ecf98a6b20130f8f7847c1783b95cd70 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Tue, 11 Jan 2022 19:47:21 +0100 Subject: [PATCH] Added SSB configuration conversion to string --- lib/include/srsran/phy/sync/ssb.h | 2 ++ lib/src/phy/sync/ssb.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/include/srsran/phy/sync/ssb.h b/lib/include/srsran/phy/sync/ssb.h index 5f6043742..c718350d3 100644 --- a/lib/include/srsran/phy/sync/ssb.h +++ b/lib/include/srsran/phy/sync/ssb.h @@ -269,4 +269,6 @@ SRSRAN_API uint32_t srsran_ssb_candidate_sf_idx(const srsran_ssb_t* q, uint32_t */ SRSRAN_API uint32_t srsran_ssb_candidate_sf_offset(const srsran_ssb_t* q, uint32_t ssb_idx); +SRSRAN_API uint32_t srsran_ssb_cfg_to_str(const srsran_ssb_cfg_t* cfg, char* str, uint32_t str_len); + #endif // SRSRAN_SSB_H diff --git a/lib/src/phy/sync/ssb.c b/lib/src/phy/sync/ssb.c index 738d25613..5492862c8 100644 --- a/lib/src/phy/sync/ssb.c +++ b/lib/src/phy/sync/ssb.c @@ -1453,3 +1453,25 @@ uint32_t srsran_ssb_candidate_sf_offset(const srsran_ssb_t* q, uint32_t ssb_idx) return cp_sz_0 + l * (q->symbol_sz + q->cp_sz); } + +uint32_t srsran_ssb_cfg_to_str(const srsran_ssb_cfg_t* cfg, char* str, uint32_t str_len) +{ + uint32_t n = 0; + + n = srsran_print_check(str, + str_len, + n, + "srate=%.2f MHz; c-freq=%.3f MHz; ss-freq=%.3f MHz; scs=%s; pattern=%s; duplex=%s;", + cfg->srate_hz / 1e6, + cfg->center_freq_hz / 1e6, + cfg->ssb_freq_hz / 1e6, + srsran_subcarrier_spacing_to_str(cfg->scs), + srsran_ssb_pattern_to_str(cfg->pattern), + cfg->duplex_mode == SRSRAN_DUPLEX_MODE_FDD ? "fdd" : "tdd"); + + if (cfg->periodicity_ms > 0) { + n = srsran_print_check(str, str_len, n, " period=%d ms;", cfg->periodicity_ms); + } + + return n; +}