Sample code for Signal Quality

//--------------------------------------------------------------------------------------------------
/**
* Test: Network Registration State + Signal Quality.
*
*/
//--------------------------------------------------------------------------------------------------
static void Testle_mrc_GetStateAndQual
(
void
)
{
le_mrc_NetRegState_t state;
uint32_t quality;
 
res = le_mrc_GetNetRegState(&state);
LE_ASSERT(res == LE_OK);
LE_ASSERT((state>=LE_MRC_REG_NONE) && (state<=LE_MRC_REG_UNKNOWN));
 
res = le_mrc_GetSignalQual(&quality);
LE_ASSERT(res == LE_OK);
LE_ASSERT(quality<=5);
}
 
 
//--------------------------------------------------------------------------------------------------
/**
* Test: Get Signal Metrics.
*
*/
//--------------------------------------------------------------------------------------------------
static void Testle_mrc_GetSignalMetrics
(
void
)
{
le_mrc_Rat_t rat;
int32_t rxLevel = 0;
uint32_t er = 0;
int32_t ecio = 0;
int32_t rscp = 0;
int32_t sinr = 0;
int32_t rsrq = 0;
int32_t rsrp = 0;
int32_t snr = 0;
int32_t io = 0;
 
le_mrc_MetricsRef_t metricsRef = le_mrc_MeasureSignalMetrics();
LE_ASSERT(metricsRef != NULL);
 
rat = le_mrc_GetRatOfSignalMetrics(metricsRef);
LE_INFO("RAT of signal metrics is %d",rat);
switch(rat)
{
case LE_MRC_RAT_GSM:
res = le_mrc_GetGsmSignalMetrics(metricsRef, &rxLevel, &er);
LE_ASSERT(res == LE_OK);
LE_INFO("GSM metrics rxLevel.%ddBm, er.%d", rxLevel, er);
break;
 
case LE_MRC_RAT_UMTS:
case LE_MRC_RAT_TDSCDMA:
res = le_mrc_GetUmtsSignalMetrics(metricsRef, &rxLevel, &er, &ecio, &rscp, &sinr);
LE_ASSERT(res == LE_OK);
LE_INFO("UMTS/TD-SCDMA metrics rxLevel.%ddBm, er.%d, ecio.%010.1fdB,"
"rscp.%ddBm, sinr.%ddB", rxLevel, er, ((double)ecio/10), rscp, sinr);
break;
 
case LE_MRC_RAT_LTE:
res = le_mrc_GetLteSignalMetrics(metricsRef, &rxLevel, &er, &rsrq, &rsrp, &snr);
LE_ASSERT(res == LE_OK);
LE_INFO("LTE metrics rxLevel.%ddBm, er.%d, rsrq.%010.1fdB, "
"rsrp.%010.1fdBm, snr.%010.1fdB",
rxLevel, er, ((double)rsrq/10), ((double)rsrp/10), ((double)snr/10));
break;
 
case LE_MRC_RAT_CDMA:
res = le_mrc_GetCdmaSignalMetrics(metricsRef, &rxLevel, &er, &ecio, &sinr, &io);
LE_ASSERT(res == LE_OK);
LE_INFO("CDMA metrics rxLevel.%ddBm, er.%d, ecio.%010.1fdB, "
"sinr.%ddB, io.%ddBm",
rxLevel, er, ((double)ecio/10), sinr, io);
break;
 
default:
LE_FATAL("Unknown RAT!");
break;
}
 
}