utility functions to convert RXLEV into dBm and vice versa

This commit is contained in:
Harald Welte 2009-12-12 15:37:54 +01:00
parent 854b9b33af
commit 4bb4738d21
2 changed files with 26 additions and 0 deletions

View File

@ -33,5 +33,9 @@ int gsm_7bit_encode(u_int8_t *result, const char *data);
int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm);
int ms_pwr_dbm(enum gsm_band band, u_int8_t lvl);
/* According to TS 08.05 Chapter 8.1.4 */
int rxlev2dbm(u_int8_t rxlev);
u_int8_t dbm2rxlev(int dbm);
void generate_backtrace();
#endif

View File

@ -160,6 +160,28 @@ int ms_pwr_dbm(enum gsm_band band, u_int8_t lvl)
return -EINVAL;
}
/* According to TS 08.05 Chapter 8.1.4 */
int rxlev2dbm(u_int8_t rxlev)
{
if (rxlev > 63)
rxlev = 63;
return -110 + rxlev;
}
/* According to TS 08.05 Chapter 8.1.4 */
u_int8_t dbm2rxlev(int dbm)
{
int rxlev = dbm + 110;
if (rxlev > 63)
rxlev = 63;
else if (rxlev < 0)
rxlev = 0;
return rxlev;
}
void generate_backtrace()
{
int i, nptrs;