This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/15924 ) Change subject: gsm: gsm_utils: Introduce API ms_max_pwr_dbm ...................................................................... gsm: gsm_utils: Introduce API ms_max_pwr_dbm Related: OS#4244 Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995 --- M TODO-RELEASE M include/osmocom/gsm/gsm_utils.h M src/gsm/gsm_utils.c M src/gsm/libosmogsm.map M tests/gsm0408/gsm0408_test.c 5 files changed, 49 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/24/15924/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index 9af92c1..9905057 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -10,3 +10,4 @@ core osmo_tdef_get() change val_if_not_present arg from unsigned long to long to allow passing -1 core struct osmo_tdef fields min_val,max_val added, ABI break (arrays of structs used in programs) gsm API added osmo_gsm48_rfpowercap2powerclass() +gsm API added ms_max_pwr_dbm() diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 7a5da9a..4414563 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -118,6 +118,7 @@ unsigned int ms_class_gmsk_dbm(enum gsm_band band, int ms_class); +int ms_max_pwr_dbm(enum gsm_band band, uint8_t ms_power_class); int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm); int ms_pwr_dbm(enum gsm_band band, uint8_t lvl); diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 365920f..9f8aa8e 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -542,6 +542,34 @@ return -EINVAL; } +/*! Determine maximum output power for given band based on MS Power class, as + * indicated by the tables in chapter 4.1.1 of GSM TS 05.05 + * \param[in] band GSM frequency band + * \param[in] ms_power_class Power class of the MS (1-5) + * \returns RF power level in dBm, negative on error. */ +int ms_max_pwr_dbm(enum gsm_band band, uint8_t ms_power_class) +{ + /* TS 05.05 provides no value for GSM900 class1, but TS 02.06 provides + value of 20W (43.01 dBm) */ + int col_dbm_def[5] = {44, 39, 37, 33, 29}; + int col_dbm_1800[3] = {30, 24, 36}; + + if (ms_power_class == 0) + return -EINVAL; + + switch (band) { + case GSM_BAND_1800: + case GSM_BAND_1900: + if (ms_power_class > 3) + return -EINVAL; + return col_dbm_1800[ms_power_class - 1]; + default: + if (ms_power_class > 5) + return -EINVAL; + return col_dbm_def[ms_power_class - 1]; + } +} + /*! determine power control level for given dBm value, as indicated * by the tables in chapter 4.1.1 of GSM TS 05.05 * \param[in] GSM frequency band diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index a0e3b32..a56fda5 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -485,6 +485,7 @@ milenage_opc_gen; ms_class_gmsk_dbm; +ms_max_pwr_dbm; ms_pwr_ctl_lvl; ms_pwr_dbm; diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index 2488024..5003d41 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -1136,6 +1136,7 @@ static void test_power_ctrl() { int8_t rc8; + int rc; rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_850, 0x00); VERIFY(rc8, ==, 1); @@ -1153,6 +1154,23 @@ VERIFY(rc8, <, 0); rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_900, 0xf2); VERIFY(rc8, <, 0); + + rc = ms_max_pwr_dbm(GSM_BAND_850, 0); + VERIFY(rc, <, 0); + rc = ms_max_pwr_dbm(GSM_BAND_850, 1); + VERIFY(rc, ==, 44); + rc = ms_max_pwr_dbm(GSM_BAND_900, 3); + VERIFY(rc, ==, 37); + rc = ms_max_pwr_dbm(GSM_BAND_1800, 2); + VERIFY(rc, ==, 24); + rc = ms_max_pwr_dbm(GSM_BAND_1900, 3); + VERIFY(rc, ==, 36); + rc = ms_max_pwr_dbm(GSM_BAND_1900, 4); + VERIFY(rc, <, 0); + rc = ms_max_pwr_dbm(GSM_BAND_900, 5); + VERIFY(rc, ==, 29); + rc = ms_max_pwr_dbm(GSM_BAND_900, 6); + VERIFY(rc, <, 0); } int main(int argc, char **argv) -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15924 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995 Gerrit-Change-Number: 15924 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191031/9eb8a13b/attachment.htm>