From b99f4ca2d8517d99cdf8aa183dbfda7b233bb781 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 31 Oct 2019 13:35:22 +0100 Subject: gsm_04_08.h: Introduce API osmo_gsm48_rfpowercap2powerclass() Related: OS#4244 Change-Id: I32e9cc1c2397b44f0d48db2acdf782a821365b63 --- src/gsm/gsm48.c | 21 +++++++++++++++++++++ src/gsm/libosmogsm.map | 1 + 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index 2d6deb56..17b0829d 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -1390,4 +1390,25 @@ int osmo_gsm48_classmark_supports_a5(const struct osmo_gsm48_classmark *cm, uint } } +/*! Decode power class from Classmark1/2 RF power capability field. + * \param[in] rf_power_cap The RF power capability field (3 bits). + * \param[in] band the band of the arfcn from where the classmark was received + * \return the MS power class on success, negative on error. + */ +int8_t osmo_gsm48_rfpowercap2powerclass(enum gsm_band band, uint8_t rf_power_cap) +{ + switch (band) { + case GSM_BAND_1800: + case GSM_BAND_1900: + if (rf_power_cap > 2) + return -1; + return rf_power_cap + 1; + default: + if (rf_power_cap > 4) + return -1; + return rf_power_cap + 1; + } +} + + /*! @} */ diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 724fe5b1..a0e3b324 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -646,6 +646,7 @@ osmo_gsm48_classmark_a5_name; osmo_gsm48_classmark_a5_name_buf; osmo_gsm48_classmark_a5_name_c; osmo_gsm48_classmark_update; +osmo_gsm48_rfpowercap2powerclass; cbsp_msg_type_names; cbsp_iei_names; -- cgit v1.2.3