broadband-modem-mbim: add support for setting up thresholds on v1 MBIM modems
On MBIM modems that do not support mbimex v2, extra steps are required to retrieve 3G/4G signal quality markers from the modem when using thresholds to trigger signal quality indications.
This commit is contained in:

committed by
Aleksander Morgado

parent
dee307d2cf
commit
3a76cb29ef
@@ -2153,7 +2153,15 @@ signal_state_query_ready (MbimDevice *device,
|
|||||||
g_autoptr(MbimRsrpSnrInfoArray) rsrp_snr = NULL;
|
g_autoptr(MbimRsrpSnrInfoArray) rsrp_snr = NULL;
|
||||||
guint32 rsrp_snr_count = 0;
|
guint32 rsrp_snr_count = 0;
|
||||||
guint32 rssi;
|
guint32 rssi;
|
||||||
|
guint32 error_rate = 99;
|
||||||
guint quality;
|
guint quality;
|
||||||
|
MbimDataClass data_class;
|
||||||
|
g_autoptr(MMSignal) cdma = NULL;
|
||||||
|
g_autoptr(MMSignal) evdo = NULL;
|
||||||
|
g_autoptr(MMSignal) gsm = NULL;
|
||||||
|
g_autoptr(MMSignal) umts = NULL;
|
||||||
|
g_autoptr(MMSignal) lte = NULL;
|
||||||
|
g_autoptr(MMSignal) nr5g = NULL;
|
||||||
|
|
||||||
self = g_task_get_source_object (task);
|
self = g_task_get_source_object (task);
|
||||||
|
|
||||||
@@ -2168,7 +2176,7 @@ signal_state_query_ready (MbimDevice *device,
|
|||||||
if (!mbim_message_ms_basic_connect_v2_signal_state_response_parse (
|
if (!mbim_message_ms_basic_connect_v2_signal_state_response_parse (
|
||||||
response,
|
response,
|
||||||
&rssi,
|
&rssi,
|
||||||
NULL, /* error_rate */
|
&error_rate,
|
||||||
NULL, /* signal_strength_interval */
|
NULL, /* signal_strength_interval */
|
||||||
NULL, /* rssi_threshold */
|
NULL, /* rssi_threshold */
|
||||||
NULL, /* error_rate_threshold */
|
NULL, /* error_rate_threshold */
|
||||||
@@ -2182,7 +2190,7 @@ signal_state_query_ready (MbimDevice *device,
|
|||||||
if (!mbim_message_signal_state_response_parse (
|
if (!mbim_message_signal_state_response_parse (
|
||||||
response,
|
response,
|
||||||
&rssi,
|
&rssi,
|
||||||
NULL, /* error_rate */
|
&error_rate,
|
||||||
NULL, /* signal_strength_interval */
|
NULL, /* signal_strength_interval */
|
||||||
NULL, /* rssi_threshold */
|
NULL, /* rssi_threshold */
|
||||||
NULL, /* error_rate_threshold */
|
NULL, /* error_rate_threshold */
|
||||||
@@ -2195,6 +2203,14 @@ signal_state_query_ready (MbimDevice *device,
|
|||||||
if (error)
|
if (error)
|
||||||
g_task_return_error (task, error);
|
g_task_return_error (task, error);
|
||||||
else {
|
else {
|
||||||
|
/* Best guess of current data class */
|
||||||
|
data_class = self->priv->highest_available_data_class;
|
||||||
|
if (data_class == 0)
|
||||||
|
data_class = self->priv->available_data_classes;
|
||||||
|
if (mm_signal_from_mbim_signal_state (data_class, rssi, error_rate, rsrp_snr, rsrp_snr_count,
|
||||||
|
self, &cdma, &evdo, &gsm, &umts, <e, &nr5g))
|
||||||
|
mm_iface_modem_signal_update (MM_IFACE_MODEM_SIGNAL (self), cdma, evdo, gsm, umts, lte, nr5g);
|
||||||
|
|
||||||
quality = mm_signal_quality_from_mbim_signal_state (rssi, rsrp_snr, rsrp_snr_count, self);
|
quality = mm_signal_quality_from_mbim_signal_state (rssi, rsrp_snr, rsrp_snr_count, self);
|
||||||
g_task_return_int (task, quality);
|
g_task_return_int (task, quality);
|
||||||
}
|
}
|
||||||
@@ -4437,6 +4453,41 @@ modem_3gpp_set_nr5g_registration_settings (MMIfaceModem3gpp *_self,
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Signal state updates */
|
/* Signal state updates */
|
||||||
|
|
||||||
|
static void
|
||||||
|
atds_signal_query_after_indication_ready (MbimDevice *device,
|
||||||
|
GAsyncResult *res,
|
||||||
|
MMBroadbandModemMbim *_self) /* full reference! */
|
||||||
|
{
|
||||||
|
g_autoptr(MMBroadbandModemMbim) self = _self;
|
||||||
|
g_autoptr(MbimMessage) response = NULL;
|
||||||
|
g_autoptr(MMSignal) gsm = NULL;
|
||||||
|
g_autoptr(MMSignal) umts = NULL;
|
||||||
|
g_autoptr(MMSignal) lte = NULL;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
guint32 rssi;
|
||||||
|
guint32 error_rate;
|
||||||
|
guint32 rscp;
|
||||||
|
guint32 ecno;
|
||||||
|
guint32 rsrq;
|
||||||
|
guint32 rsrp;
|
||||||
|
guint32 snr;
|
||||||
|
|
||||||
|
response = mbim_device_command_finish (device, res, &error);
|
||||||
|
if (!response ||
|
||||||
|
!mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error) ||
|
||||||
|
!mbim_message_atds_signal_response_parse (response, &rssi, &error_rate, &rscp, &ecno, &rsrq, &rsrp, &snr, &error)) {
|
||||||
|
mm_obj_warn (self, "ATDS signal query failed: %s", error->message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mm_signal_from_atds_signal_response (rssi, rscp, ecno, rsrq, rsrp, snr, &gsm, &umts, <e)) {
|
||||||
|
mm_obj_warn (self, "No signal details given");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_iface_modem_signal_update (MM_IFACE_MODEM_SIGNAL (self), NULL, NULL, gsm, umts, lte, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
basic_connect_notification_signal_state (MMBroadbandModemMbim *self,
|
basic_connect_notification_signal_state (MMBroadbandModemMbim *self,
|
||||||
MbimDevice *device,
|
MbimDevice *device,
|
||||||
@@ -4446,7 +4497,7 @@ basic_connect_notification_signal_state (MMBroadbandModemMbim *self,
|
|||||||
g_autoptr(MbimRsrpSnrInfoArray) rsrp_snr = NULL;
|
g_autoptr(MbimRsrpSnrInfoArray) rsrp_snr = NULL;
|
||||||
guint32 rsrp_snr_count = 0;
|
guint32 rsrp_snr_count = 0;
|
||||||
guint32 coded_rssi;
|
guint32 coded_rssi;
|
||||||
guint32 coded_error_rate;
|
guint32 coded_error_rate = 99;
|
||||||
guint32 quality;
|
guint32 quality;
|
||||||
MbimDataClass data_class;
|
MbimDataClass data_class;
|
||||||
g_autoptr(MMSignal) cdma = NULL;
|
g_autoptr(MMSignal) cdma = NULL;
|
||||||
@@ -4484,6 +4535,18 @@ basic_connect_notification_signal_state (MMBroadbandModemMbim *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mm_obj_dbg (self, "processed signal state indication");
|
mm_obj_dbg (self, "processed signal state indication");
|
||||||
|
if (self->priv->is_atds_signal_supported) {
|
||||||
|
g_autoptr(MbimMessage) message = NULL;
|
||||||
|
|
||||||
|
mm_obj_dbg (self, "triggering ATDS signal query");
|
||||||
|
message = mbim_message_atds_signal_query_new (NULL);
|
||||||
|
mbim_device_command (device,
|
||||||
|
message,
|
||||||
|
5,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)atds_signal_query_after_indication_ready,
|
||||||
|
g_object_ref (self));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quality = mm_signal_quality_from_mbim_signal_state (coded_rssi, rsrp_snr, rsrp_snr_count, self);
|
quality = mm_signal_quality_from_mbim_signal_state (coded_rssi, rsrp_snr, rsrp_snr_count, self);
|
||||||
@@ -6566,50 +6629,7 @@ atds_signal_query_ready (MbimDevice *device,
|
|||||||
|
|
||||||
result = g_slice_new0 (SignalLoadValuesResult);
|
result = g_slice_new0 (SignalLoadValuesResult);
|
||||||
|
|
||||||
if (rscp <= 96) {
|
if (!mm_signal_from_atds_signal_response (rssi, rscp, ecno, rsrq, rsrp, snr, &result->gsm, &result->umts, &result->lte)) {
|
||||||
result->umts = mm_signal_new ();
|
|
||||||
mm_signal_set_rscp (result->umts, -120.0 + rscp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ecno <= 49) {
|
|
||||||
if (!result->umts)
|
|
||||||
result->umts = mm_signal_new ();
|
|
||||||
mm_signal_set_ecio (result->umts, -24.0 + ((gdouble) ecno / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rsrq <= 34) {
|
|
||||||
result->lte = mm_signal_new ();
|
|
||||||
mm_signal_set_rsrq (result->lte, -19.5 + ((gdouble) rsrq / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rsrp <= 97) {
|
|
||||||
if (!result->lte)
|
|
||||||
result->lte = mm_signal_new ();
|
|
||||||
mm_signal_set_rsrp (result->lte, -140.0 + rsrp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snr <= 35) {
|
|
||||||
if (!result->lte)
|
|
||||||
result->lte = mm_signal_new ();
|
|
||||||
mm_signal_set_snr (result->lte, -5.0 + snr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RSSI may be given for all 2G, 3G or 4G so we detect to which one applies */
|
|
||||||
if (rssi <= 31) {
|
|
||||||
gdouble value;
|
|
||||||
|
|
||||||
value = -113.0 + (2 * rssi);
|
|
||||||
if (result->lte)
|
|
||||||
mm_signal_set_rssi (result->lte, value);
|
|
||||||
else if (result->umts)
|
|
||||||
mm_signal_set_rssi (result->umts, value);
|
|
||||||
else {
|
|
||||||
result->gsm = mm_signal_new ();
|
|
||||||
mm_signal_set_rssi (result->gsm, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result->gsm && !result->umts && !result->lte) {
|
|
||||||
signal_load_values_result_free (result);
|
signal_load_values_result_free (result);
|
||||||
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||||
"No signal details given");
|
"No signal details given");
|
||||||
|
@@ -1247,6 +1247,68 @@ mm_signal_from_mbim_signal_state (MbimDataClass data_class,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_signal_from_atds_signal_response (guint32 rssi,
|
||||||
|
guint32 rscp,
|
||||||
|
guint32 ecno,
|
||||||
|
guint32 rsrq,
|
||||||
|
guint32 rsrp,
|
||||||
|
guint32 snr,
|
||||||
|
MMSignal **out_gsm,
|
||||||
|
MMSignal **out_umts,
|
||||||
|
MMSignal **out_lte)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (rscp <= 96) {
|
||||||
|
*out_umts = mm_signal_new ();
|
||||||
|
mm_signal_set_rscp (*out_umts, -120.0 + rscp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ecno <= 49) {
|
||||||
|
if (!*out_umts)
|
||||||
|
*out_umts = mm_signal_new ();
|
||||||
|
mm_signal_set_ecio (*out_umts, -24.0 + ((gdouble) ecno / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rsrq <= 34) {
|
||||||
|
*out_lte = mm_signal_new ();
|
||||||
|
mm_signal_set_rsrq (*out_lte, -19.5 + ((gdouble) rsrq / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rsrp <= 97) {
|
||||||
|
if (!*out_lte)
|
||||||
|
*out_lte = mm_signal_new ();
|
||||||
|
mm_signal_set_rsrp (*out_lte, -140.0 + rsrp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snr <= 35) {
|
||||||
|
if (!*out_lte)
|
||||||
|
*out_lte = mm_signal_new ();
|
||||||
|
mm_signal_set_snr (*out_lte, -5.0 + snr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RSSI may be given for all 2G, 3G or 4G so we detect to which one applies */
|
||||||
|
if (rssi <= 31) {
|
||||||
|
gdouble value;
|
||||||
|
|
||||||
|
value = -113.0 + (2 * rssi);
|
||||||
|
if (*out_lte)
|
||||||
|
mm_signal_set_rssi (*out_lte, value);
|
||||||
|
else if (*out_umts)
|
||||||
|
mm_signal_set_rssi (*out_umts, value);
|
||||||
|
else {
|
||||||
|
*out_gsm = mm_signal_new ();
|
||||||
|
mm_signal_set_rssi (*out_gsm, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!out_gsm && !out_umts && !out_lte) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -144,6 +144,16 @@ gboolean mm_signal_from_mbim_signal_state (MbimDataClass data_class,
|
|||||||
MMSignal **out_lte,
|
MMSignal **out_lte,
|
||||||
MMSignal **out_nr5g);
|
MMSignal **out_nr5g);
|
||||||
|
|
||||||
|
gboolean mm_signal_from_atds_signal_response (guint32 rssi,
|
||||||
|
guint32 rscp,
|
||||||
|
guint32 ecno,
|
||||||
|
guint32 rsrq,
|
||||||
|
guint32 rsrp,
|
||||||
|
guint32 snr,
|
||||||
|
MMSignal **out_gsm,
|
||||||
|
MMSignal **out_umts,
|
||||||
|
MMSignal **out_lte);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* RF utilities */
|
/* RF utilities */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user