core: implement Access Technology reporting
For 3GPP modems only for now..
This commit is contained in:
@@ -48,3 +48,42 @@ mm_common_get_capabilities_string (MMModemCapability caps)
|
|||||||
|
|
||||||
return g_string_free (str, FALSE);
|
return g_string_free (str, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech)
|
||||||
|
{
|
||||||
|
GFlagsClass *flags_class;
|
||||||
|
GString *str;
|
||||||
|
|
||||||
|
str = g_string_new ("");
|
||||||
|
flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_ACCESS_TECHNOLOGY));
|
||||||
|
|
||||||
|
if (access_tech == MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN) {
|
||||||
|
GFlagsValue *value;
|
||||||
|
|
||||||
|
value = g_flags_get_first_value (flags_class, access_tech);
|
||||||
|
g_string_append (str, value->value_nick);
|
||||||
|
} else {
|
||||||
|
MMModemAccessTechnology it;
|
||||||
|
gboolean first = TRUE;
|
||||||
|
|
||||||
|
for (it = MM_MODEM_ACCESS_TECHNOLOGY_GSM; /* first */
|
||||||
|
it <= MM_MODEM_ACCESS_TECHNOLOGY_LTE; /* last */
|
||||||
|
it = it << 1) {
|
||||||
|
if (access_tech & it) {
|
||||||
|
GFlagsValue *value;
|
||||||
|
|
||||||
|
value = g_flags_get_first_value (flags_class, it);
|
||||||
|
g_string_append_printf (str, "%s%s",
|
||||||
|
first ? "" : ", ",
|
||||||
|
value->value_nick);
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
first = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_type_class_unref (flags_class);
|
||||||
|
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
|
}
|
||||||
|
@@ -20,5 +20,6 @@
|
|||||||
#define MM_COMMON_HELPERS_H
|
#define MM_COMMON_HELPERS_H
|
||||||
|
|
||||||
gchar *mm_common_get_capabilities_string (MMModemCapability caps);
|
gchar *mm_common_get_capabilities_string (MMModemCapability caps);
|
||||||
|
gchar *mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech);
|
||||||
|
|
||||||
#endif /* MM_COMMON_HELPERS_H */
|
#endif /* MM_COMMON_HELPERS_H */
|
||||||
|
@@ -1134,7 +1134,9 @@ reg_state_changed (MMAtSerialPort *port,
|
|||||||
|
|
||||||
/* Report new registration state */
|
/* Report new registration state */
|
||||||
state = get_consolidated_reg_state (self);
|
state = get_consolidated_reg_state (self);
|
||||||
mm_iface_modem_3gpp_update_registration_state (MM_IFACE_MODEM_3GPP (self), state);
|
mm_iface_modem_3gpp_update_registration_state (MM_IFACE_MODEM_3GPP (self),
|
||||||
|
state,
|
||||||
|
act);
|
||||||
|
|
||||||
/* If registration is finished (either registered or failed) but the
|
/* If registration is finished (either registered or failed) but the
|
||||||
* registration query hasn't completed yet, just remove the timeout and
|
* registration query hasn't completed yet, just remove the timeout and
|
||||||
@@ -1337,7 +1339,8 @@ register_in_network_timed_out (MMBroadbandModem *self)
|
|||||||
|
|
||||||
/* Report IDLE registration state */
|
/* Report IDLE registration state */
|
||||||
mm_iface_modem_3gpp_update_registration_state (MM_IFACE_MODEM_3GPP (self),
|
mm_iface_modem_3gpp_update_registration_state (MM_IFACE_MODEM_3GPP (self),
|
||||||
MM_MODEM_3GPP_REGISTRATION_STATE_IDLE);
|
MM_MODEM_3GPP_REGISTRATION_STATE_IDLE,
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
|
||||||
|
|
||||||
g_simple_async_result_take_error (
|
g_simple_async_result_take_error (
|
||||||
self->priv->pending_reg_request,
|
self->priv->pending_reg_request,
|
||||||
@@ -1602,10 +1605,10 @@ registration_status_check_ready (MMBroadbandModem *self,
|
|||||||
|
|
||||||
/* Report new registration state */
|
/* Report new registration state */
|
||||||
mm_iface_modem_3gpp_update_registration_state (MM_IFACE_MODEM_3GPP (self),
|
mm_iface_modem_3gpp_update_registration_state (MM_IFACE_MODEM_3GPP (self),
|
||||||
get_consolidated_reg_state (self));
|
get_consolidated_reg_state (self),
|
||||||
|
act);
|
||||||
|
|
||||||
/* TODO: report LAC/CI location */
|
/* TODO: report LAC/CI location */
|
||||||
/* TODO: report access technology, if available */
|
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gboolean (operation_result, TRUE);
|
g_simple_async_result_set_op_res_gboolean (operation_result, TRUE);
|
||||||
}
|
}
|
||||||
|
@@ -460,9 +460,22 @@ bearer_3gpp_connection_forbidden (MMIfaceModem3gpp *self)
|
|||||||
g_object_unref (bearer_list);
|
g_object_unref (bearer_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ALL_3GPP_ACCESS_TECHNOLOGIES_MASK \
|
||||||
|
(MM_MODEM_ACCESS_TECHNOLOGY_GSM | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_GSM_COMPACT | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_GPRS | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_EDGE | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_UMTS | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_HSDPA | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_HSUPA | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_HSPA | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS | \
|
||||||
|
MM_MODEM_ACCESS_TECHNOLOGY_LTE)
|
||||||
|
|
||||||
void
|
void
|
||||||
mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self,
|
mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self,
|
||||||
MMModem3gppRegistrationState new_state)
|
MMModem3gppRegistrationState new_state,
|
||||||
|
MMModemAccessTechnology access_tech)
|
||||||
{
|
{
|
||||||
MMModem3gppRegistrationState old_state;
|
MMModem3gppRegistrationState old_state;
|
||||||
|
|
||||||
@@ -519,13 +532,19 @@ mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self,
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* TODO: Update signal quality */
|
/* TODO: Update signal quality */
|
||||||
/* TODO: Update access technology */
|
|
||||||
|
mm_iface_modem_update_access_tech (MM_IFACE_MODEM (self),
|
||||||
|
access_tech,
|
||||||
|
ALL_3GPP_ACCESS_TECHNOLOGIES_MASK);
|
||||||
|
|
||||||
mm_iface_modem_update_state (MM_IFACE_MODEM (self),
|
mm_iface_modem_update_state (MM_IFACE_MODEM (self),
|
||||||
MM_MODEM_STATE_REGISTERED,
|
MM_MODEM_STATE_REGISTERED,
|
||||||
MM_MODEM_STATE_REASON_NONE);
|
MM_MODEM_STATE_REASON_NONE);
|
||||||
break;
|
break;
|
||||||
case MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING:
|
case MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING:
|
||||||
|
mm_iface_modem_update_access_tech (MM_IFACE_MODEM (self),
|
||||||
|
0,
|
||||||
|
ALL_3GPP_ACCESS_TECHNOLOGIES_MASK);
|
||||||
bearer_3gpp_connection_forbidden (self);
|
bearer_3gpp_connection_forbidden (self);
|
||||||
mm_iface_modem_update_state (MM_IFACE_MODEM (self),
|
mm_iface_modem_update_state (MM_IFACE_MODEM (self),
|
||||||
MM_MODEM_STATE_SEARCHING,
|
MM_MODEM_STATE_SEARCHING,
|
||||||
@@ -534,6 +553,9 @@ mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self,
|
|||||||
case MM_MODEM_3GPP_REGISTRATION_STATE_IDLE:
|
case MM_MODEM_3GPP_REGISTRATION_STATE_IDLE:
|
||||||
case MM_MODEM_3GPP_REGISTRATION_STATE_DENIED:
|
case MM_MODEM_3GPP_REGISTRATION_STATE_DENIED:
|
||||||
case MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN:
|
case MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN:
|
||||||
|
mm_iface_modem_update_access_tech (MM_IFACE_MODEM (self),
|
||||||
|
0,
|
||||||
|
ALL_3GPP_ACCESS_TECHNOLOGIES_MASK);
|
||||||
bearer_3gpp_connection_forbidden (self);
|
bearer_3gpp_connection_forbidden (self);
|
||||||
mm_iface_modem_update_state (MM_IFACE_MODEM (self),
|
mm_iface_modem_update_state (MM_IFACE_MODEM (self),
|
||||||
MM_MODEM_STATE_ENABLED,
|
MM_MODEM_STATE_ENABLED,
|
||||||
|
@@ -179,7 +179,8 @@ void mm_iface_modem_3gpp_shutdown (MMIfaceModem3gpp *self);
|
|||||||
* the interface asks to run registration state checks.
|
* the interface asks to run registration state checks.
|
||||||
* Returns FALSE if registration process is still ongoing. */
|
* Returns FALSE if registration process is still ongoing. */
|
||||||
void mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self,
|
void mm_iface_modem_3gpp_update_registration_state (MMIfaceModem3gpp *self,
|
||||||
MMModem3gppRegistrationState new_state);
|
MMModem3gppRegistrationState new_state,
|
||||||
|
MMModemAccessTechnology access_tech);
|
||||||
|
|
||||||
/* Run all registration checks */
|
/* Run all registration checks */
|
||||||
void mm_iface_modem_3gpp_run_all_registration_checks (MMIfaceModem3gpp *self,
|
void mm_iface_modem_3gpp_run_all_registration_checks (MMIfaceModem3gpp *self,
|
||||||
|
@@ -245,6 +245,43 @@ handle_list_bearers (MmGdbusModem *skeleton,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
mm_iface_modem_update_access_tech (MMIfaceModem *self,
|
||||||
|
MMModemAccessTechnology new_access_tech,
|
||||||
|
guint32 mask)
|
||||||
|
{
|
||||||
|
MmGdbusModem *skeleton = NULL;
|
||||||
|
MMModemAccessTechnology access_tech;
|
||||||
|
gchar *old_access_tech_string;
|
||||||
|
gchar *new_access_tech_string;
|
||||||
|
const gchar *dbus_path;
|
||||||
|
|
||||||
|
g_object_get (self,
|
||||||
|
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
access_tech = mm_gdbus_modem_get_access_technologies (skeleton);
|
||||||
|
old_access_tech_string = mm_common_get_access_technologies_string (access_tech);
|
||||||
|
|
||||||
|
/* Clear the flags to be set */
|
||||||
|
access_tech &= ~mask;
|
||||||
|
/* And set our new flags */
|
||||||
|
access_tech |= new_access_tech;
|
||||||
|
mm_gdbus_modem_set_access_technologies (skeleton, access_tech);
|
||||||
|
|
||||||
|
/* Log */
|
||||||
|
new_access_tech_string = mm_common_get_access_technologies_string (access_tech);
|
||||||
|
dbus_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (self));
|
||||||
|
mm_info ("Modem %s: access technology changed (%s -> %s)",
|
||||||
|
dbus_path,
|
||||||
|
old_access_tech_string,
|
||||||
|
new_access_tech_string);
|
||||||
|
g_free (old_access_tech_string);
|
||||||
|
g_free (new_access_tech_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bearer_list_count_connected (MMBearer *bearer,
|
bearer_list_count_connected (MMBearer *bearer,
|
||||||
guint *count)
|
guint *count)
|
||||||
|
@@ -296,4 +296,9 @@ void mm_iface_modem_update_state (MMIfaceModem *self,
|
|||||||
MMModemState new_state,
|
MMModemState new_state,
|
||||||
MMModemStateReason reason);
|
MMModemStateReason reason);
|
||||||
|
|
||||||
|
/* Allow reporting new access tech */
|
||||||
|
void mm_iface_modem_update_access_tech (MMIfaceModem *self,
|
||||||
|
MMModemAccessTechnology access_tech,
|
||||||
|
guint32 mask);
|
||||||
|
|
||||||
#endif /* MM_IFACE_MODEM_H */
|
#endif /* MM_IFACE_MODEM_H */
|
||||||
|
Reference in New Issue
Block a user