summaryrefslogtreecommitdiff
path: root/libmm-glib/mm-bearer-stats.c
diff options
context:
space:
mode:
authorSom_SP <somashekhar.puttagangaiah@intel.com>2021-10-21 11:06:24 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-11-03 12:41:51 +0100
commit511859ef0afe049870581e3a55365bc3d3866566 (patch)
treea27b16356a7e24239224f917e2511e13864a8e64 /libmm-glib/mm-bearer-stats.c
parentd71a0bcf8eba9d7c6ec7949004c806be4f3f3f0d (diff)
downloadModemManager-511859ef0afe049870581e3a55365bc3d3866566.tar.gz
api,bearer: add 'uplink-speed' and 'downlink-speed' stats
These values show the rates that have been negotiated with the network during the PS domain attach. These are not the current ongoing data rates associated to the network usage at some given moment. Includes updates by Aleksander Morgado to fix coding style issues and add missing documentation items.
Diffstat (limited to 'libmm-glib/mm-bearer-stats.c')
-rw-r--r--libmm-glib/mm-bearer-stats.c89
1 files changed, 87 insertions, 2 deletions
diff --git a/libmm-glib/mm-bearer-stats.c b/libmm-glib/mm-bearer-stats.c
index f7e339c6f..61b24de36 100644
--- a/libmm-glib/mm-bearer-stats.c
+++ b/libmm-glib/mm-bearer-stats.c
@@ -10,8 +10,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
- * Copyright (C) 2015 Azimut Electronics
- * Copyright (C) 2015-2020 Aleksander Morgado <aleksander@aleksander.es>
+ * Copyright (C) 2015-2021 Azimut Electronics
+ * Copyright (C) 2015-2021 Aleksander Morgado <aleksander@aleksander.es>
+ * Copyright (C) 2021 Intel Corporation
*/
#include <string.h>
@@ -42,6 +43,8 @@ G_DEFINE_TYPE (MMBearerStats, mm_bearer_stats, G_TYPE_OBJECT)
#define PROPERTY_TOTAL_DURATION "total-duration"
#define PROPERTY_TOTAL_RX_BYTES "total-rx-bytes"
#define PROPERTY_TOTAL_TX_BYTES "total-tx-bytes"
+#define PROPERTY_UPLINK_SPEED "uplink-speed"
+#define PROPERTY_DOWNLINK_SPEED "downlink-speed"
struct _MMBearerStatsPrivate {
guint duration;
@@ -53,6 +56,8 @@ struct _MMBearerStatsPrivate {
guint total_duration;
guint64 total_rx_bytes;
guint64 total_tx_bytes;
+ guint64 uplink_speed;
+ guint64 downlink_speed;
};
/*****************************************************************************/
@@ -349,6 +354,70 @@ mm_bearer_stats_set_total_tx_bytes (MMBearerStats *self,
/*****************************************************************************/
/**
+ * mm_bearer_stats_get_uplink_speed:
+ * @self: a #MMBearerStats.
+ *
+ * Gets the speed of the uplink, in bits per second.
+ *
+ * Returns: a #guint64.
+ *
+ * Since: 1.20
+ */
+guint64
+mm_bearer_stats_get_uplink_speed (MMBearerStats *self)
+{
+ g_return_val_if_fail (MM_IS_BEARER_STATS (self), 0);
+
+ return self->priv->uplink_speed;
+}
+
+/**
+ * mm_bearer_stats_set_uplink_speed: (skip)
+ */
+void
+mm_bearer_stats_set_uplink_speed (MMBearerStats *self,
+ guint64 speed)
+{
+ g_return_if_fail (MM_IS_BEARER_STATS (self));
+
+ self->priv->uplink_speed = speed;
+}
+
+/*****************************************************************************/
+
+/**
+ * mm_bearer_stats_get_downlink_speed:
+ * @self: a #MMBearerStats.
+ *
+ * Gets the speed of the downlink, in bits per second.
+ *
+ * Returns: a #guint64.
+ *
+ * Since: 1.20
+ */
+guint64
+mm_bearer_stats_get_downlink_speed (MMBearerStats *self)
+{
+ g_return_val_if_fail (MM_IS_BEARER_STATS (self), 0);
+
+ return self->priv->downlink_speed;
+}
+
+/**
+ * mm_bearer_stats_set_downlink_speed: (skip)
+ */
+void
+mm_bearer_stats_set_downlink_speed (MMBearerStats *self,
+ guint64 speed)
+{
+ g_return_if_fail (MM_IS_BEARER_STATS (self));
+
+ self->priv->downlink_speed = speed;
+}
+
+/*****************************************************************************/
+
+/**
* mm_bearer_stats_get_dictionary: (skip)
*/
GVariant *
@@ -397,6 +466,14 @@ mm_bearer_stats_get_dictionary (MMBearerStats *self)
"{sv}",
PROPERTY_TOTAL_TX_BYTES,
g_variant_new_uint64 (self->priv->total_tx_bytes));
+ g_variant_builder_add (&builder,
+ "{sv}",
+ PROPERTY_UPLINK_SPEED,
+ g_variant_new_uint64 (self->priv->uplink_speed));
+ g_variant_builder_add (&builder,
+ "{sv}",
+ PROPERTY_DOWNLINK_SPEED,
+ g_variant_new_uint64 (self->priv->downlink_speed));
return g_variant_builder_end (&builder);
}
@@ -466,6 +543,14 @@ mm_bearer_stats_new_from_dictionary (GVariant *dictionary,
mm_bearer_stats_set_total_tx_bytes (
self,
g_variant_get_uint64 (value));
+ } else if (g_str_equal (key, PROPERTY_UPLINK_SPEED)) {
+ mm_bearer_stats_set_uplink_speed (
+ self,
+ g_variant_get_uint64 (value));
+ } else if (g_str_equal (key, PROPERTY_DOWNLINK_SPEED)) {
+ mm_bearer_stats_set_downlink_speed (
+ self,
+ g_variant_get_uint64 (value));
}
g_free (key);