base-bearer: implement support for 'uplink-speed' and 'downlink-speed'
We let protocol implementations provide the uplink and downlink speeds agreed with the network as part of the connect result, and we then move them to the bearer stats in DBus.
This commit is contained in:
+43
-4
@@ -315,6 +315,8 @@ bearer_reset_ongoing_interface_stats (MMBaseBearer *self)
|
||||
mm_bearer_stats_set_tx_bytes (self->priv->stats, 0);
|
||||
mm_bearer_stats_set_rx_bytes (self->priv->stats, 0);
|
||||
mm_bearer_stats_set_start_date (self->priv->stats, 0);
|
||||
mm_bearer_stats_set_uplink_speed (self->priv->stats, 0);
|
||||
mm_bearer_stats_set_downlink_speed (self->priv->stats, 0);
|
||||
bearer_update_interface_stats (self);
|
||||
}
|
||||
|
||||
@@ -446,7 +448,9 @@ stats_update_cb (MMBaseBearer *self)
|
||||
}
|
||||
|
||||
static void
|
||||
bearer_stats_start (MMBaseBearer *self)
|
||||
bearer_stats_start (MMBaseBearer *self,
|
||||
guint64 uplink_speed,
|
||||
guint64 downlink_speed)
|
||||
{
|
||||
/* Start duration timer */
|
||||
g_assert (!self->priv->duration_timer);
|
||||
@@ -459,6 +463,9 @@ bearer_stats_start (MMBaseBearer *self)
|
||||
self);
|
||||
|
||||
mm_bearer_stats_set_start_date (self->priv->stats, (guint64)(g_get_real_time() / G_USEC_PER_SEC));
|
||||
mm_bearer_stats_set_uplink_speed (self->priv->stats, uplink_speed);
|
||||
mm_bearer_stats_set_downlink_speed (self->priv->stats, downlink_speed);
|
||||
bearer_update_interface_stats (self);
|
||||
|
||||
/* Load initial values */
|
||||
stats_update_cb (self);
|
||||
@@ -531,7 +538,9 @@ bearer_update_status_connected (MMBaseBearer *self,
|
||||
gboolean multiplexed,
|
||||
gint profile_id,
|
||||
MMBearerIpConfig *ipv4_config,
|
||||
MMBearerIpConfig *ipv6_config)
|
||||
MMBearerIpConfig *ipv6_config,
|
||||
guint64 uplink_speed,
|
||||
guint64 downlink_speed)
|
||||
{
|
||||
mm_gdbus_bearer_set_profile_id (MM_GDBUS_BEARER (self), profile_id);
|
||||
mm_gdbus_bearer_set_multiplexed (MM_GDBUS_BEARER (self), multiplexed);
|
||||
@@ -560,7 +569,7 @@ bearer_update_status_connected (MMBaseBearer *self,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATUS]);
|
||||
|
||||
/* Start statistics */
|
||||
bearer_stats_start (self);
|
||||
bearer_stats_start (self, uplink_speed, downlink_speed);
|
||||
|
||||
/* Start connection monitor, if supported */
|
||||
connection_monitor_start (self);
|
||||
@@ -901,7 +910,9 @@ connect_ready (MMBaseBearer *self,
|
||||
mm_bearer_connect_result_get_multiplexed (result),
|
||||
mm_bearer_connect_result_get_profile_id (result),
|
||||
mm_bearer_connect_result_peek_ipv4_config (result),
|
||||
mm_bearer_connect_result_peek_ipv6_config (result));
|
||||
mm_bearer_connect_result_peek_ipv6_config (result),
|
||||
mm_bearer_connect_result_get_uplink_speed (result),
|
||||
mm_bearer_connect_result_get_downlink_speed (result));
|
||||
mm_bearer_connect_result_unref (result);
|
||||
}
|
||||
|
||||
@@ -1871,6 +1882,8 @@ struct _MMBearerConnectResult {
|
||||
MMBearerIpConfig *ipv6_config;
|
||||
gboolean multiplexed;
|
||||
gint profile_id;
|
||||
guint64 uplink_speed;
|
||||
guint64 downlink_speed;
|
||||
};
|
||||
|
||||
MMBearerConnectResult *
|
||||
@@ -1938,6 +1951,32 @@ mm_bearer_connect_result_get_profile_id (MMBearerConnectResult *result)
|
||||
return result->profile_id;
|
||||
}
|
||||
|
||||
void
|
||||
mm_bearer_connect_result_set_uplink_speed (MMBearerConnectResult *result,
|
||||
guint64 speed)
|
||||
{
|
||||
result->uplink_speed = speed;
|
||||
}
|
||||
|
||||
guint64
|
||||
mm_bearer_connect_result_get_uplink_speed (MMBearerConnectResult *result)
|
||||
{
|
||||
return result->uplink_speed;
|
||||
}
|
||||
|
||||
void
|
||||
mm_bearer_connect_result_set_downlink_speed (MMBearerConnectResult *result,
|
||||
guint64 speed)
|
||||
{
|
||||
result->downlink_speed = speed;
|
||||
}
|
||||
|
||||
guint64
|
||||
mm_bearer_connect_result_get_downlink_speed (MMBearerConnectResult *result)
|
||||
{
|
||||
return result->downlink_speed;
|
||||
}
|
||||
|
||||
MMBearerConnectResult *
|
||||
mm_bearer_connect_result_new (MMPort *data,
|
||||
MMBearerIpConfig *ipv4_config,
|
||||
|
||||
@@ -54,6 +54,14 @@ void mm_bearer_connect_result_set_profile_id (MMBearerConnec
|
||||
gint profile_id);
|
||||
gint mm_bearer_connect_result_get_profile_id (MMBearerConnectResult *result);
|
||||
|
||||
/* speed, for stats */
|
||||
void mm_bearer_connect_result_set_uplink_speed (MMBearerConnectResult *result,
|
||||
guint64 speed);
|
||||
guint64 mm_bearer_connect_result_get_uplink_speed (MMBearerConnectResult *result);
|
||||
void mm_bearer_connect_result_set_downlink_speed (MMBearerConnectResult *result,
|
||||
guint64 speed);
|
||||
guint64 mm_bearer_connect_result_get_downlink_speed (MMBearerConnectResult *result);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Default timeout values to be used in the steps of a connection or
|
||||
|
||||
Reference in New Issue
Block a user