mirror of https://gerrit.osmocom.org/libosmocore
gsm_04_08.h: Introduce API osmo_gsm48_rfpowercap2powerclass()
Related: OS#4244 Change-Id: I32e9cc1c2397b44f0d48db2acdf782a821365b63
This commit is contained in:
parent
2ceb758ba4
commit
b99f4ca2d8
|
@ -9,3 +9,4 @@
|
|||
#library what description / commit summary line
|
||||
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()
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <osmocom/core/endian.h>
|
||||
|
||||
struct gsm_lchan;
|
||||
enum gsm_band;
|
||||
|
||||
/* Chapter 10.5.1.5 */
|
||||
struct gsm48_classmark1 {
|
||||
|
@ -73,7 +74,7 @@ const char *osmo_gsm48_classmark_a5_name(const struct osmo_gsm48_classmark *cm);
|
|||
char *osmo_gsm48_classmark_a5_name_buf(char *buf, size_t buf_len, const struct osmo_gsm48_classmark *cm);
|
||||
char *osmo_gsm48_classmark_a5_name_c(const void *ctx, const struct osmo_gsm48_classmark *cm);
|
||||
void osmo_gsm48_classmark_update(struct osmo_gsm48_classmark *dst, const struct osmo_gsm48_classmark *src);
|
||||
|
||||
int8_t osmo_gsm48_rfpowercap2powerclass(enum gsm_band band, uint8_t rf_power_cap);
|
||||
/* Chapter 10.5.2.1b.3 */
|
||||
#if OSMO_IS_LITTLE_ENDIAN == 1
|
||||
struct gsm48_range_1024 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! @} */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <osmocom/gsm/gsm48_ie.h>
|
||||
#include <osmocom/gsm/gsm48.h>
|
||||
#include <osmocom/gsm/gsm48_arfcn_range_encode.h>
|
||||
#include <osmocom/gsm/gsm_utils.h>
|
||||
#include <osmocom/gsm/mncc.h>
|
||||
#include <osmocom/core/backtrace.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
|
@ -1132,6 +1133,28 @@ static void test_si_range_helpers()
|
|||
VERIFY(f0, ==, 1);
|
||||
}
|
||||
|
||||
static void test_power_ctrl()
|
||||
{
|
||||
int8_t rc8;
|
||||
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_850, 0x00);
|
||||
VERIFY(rc8, ==, 1);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_900, 0x02);
|
||||
VERIFY(rc8, ==, 3);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_1800, 0x02);
|
||||
VERIFY(rc8, ==, 3);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_1900, 0x02);
|
||||
VERIFY(rc8, ==, 3);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_1900, 0x04);
|
||||
VERIFY(rc8, <, 0);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_900, 0x04);
|
||||
VERIFY(rc8, ==, 5);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_900, 0x05);
|
||||
VERIFY(rc8, <, 0);
|
||||
rc8 = osmo_gsm48_rfpowercap2powerclass(GSM_BAND_900, 0xf2);
|
||||
VERIFY(rc8, <, 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_bearer_cap();
|
||||
|
@ -1147,6 +1170,7 @@ int main(int argc, char **argv)
|
|||
test_arfcn_filter();
|
||||
test_print_encoding();
|
||||
test_range_encoding();
|
||||
test_power_ctrl();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue