aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib
diff options
context:
space:
mode:
authorSom_SP <somashekhar.puttagangaiah@intel.com>2021-10-20 22:02:06 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-10-20 22:09:18 +0200
commit925f0bae11c0b49a464237c5c98921ffd68157e2 (patch)
treef447a01ad00786c06ed16468f416aca000573b57 /libmm-glib
parent9537261651a4f44fb0d0817bb902b225abb5e5a5 (diff)
libmm-glib,mmcli: add support for the new signal 'SetupThresholds()' API
Includes updates by Aleksander Morgado to fix mostly coding style issues.
Diffstat (limited to 'libmm-glib')
-rw-r--r--libmm-glib/mm-modem-signal.c163
-rw-r--r--libmm-glib/mm-modem-signal.h53
2 files changed, 182 insertions, 34 deletions
diff --git a/libmm-glib/mm-modem-signal.c b/libmm-glib/mm-modem-signal.c
index 4a7574e8..b864c8ff 100644
--- a/libmm-glib/mm-modem-signal.c
+++ b/libmm-glib/mm-modem-signal.c
@@ -19,6 +19,8 @@
*
* Copyright (C) 2012 Google, Inc.
* Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com>
+ * Copyright (C) 2013-2021 Aleksander Morgado <aleksander@aleksander.es>
+ * Copyright (C) 2021 Intel Corporation
*/
#include <gio/gio.h>
@@ -116,8 +118,8 @@ mm_modem_signal_dup_path (MMModemSignal *self)
*/
gboolean
mm_modem_signal_setup_finish (MMModemSignal *self,
- GAsyncResult *res,
- GError **error)
+ GAsyncResult *res,
+ GError **error)
{
g_return_val_if_fail (MM_IS_MODEM_SIGNAL (self), FALSE);
@@ -127,13 +129,14 @@ mm_modem_signal_setup_finish (MMModemSignal *self,
/**
* mm_modem_signal_setup:
* @self: A #MMModemSignal.
- * @rate: Rate to use when refreshing signal values.
+ * @rate: Refresh rate to set, in seconds. Use 0 to disable periodic polling.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or
* %NULL.
* @user_data: User data to pass to @callback.
*
- * Asynchronously setups the extended signal quality retrieval.
+ * Asynchronously enables or disables the extended signal quality information
+ * retrieval via periodic polling.
*
* When the operation is finished, @callback will be invoked in the
* <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
@@ -146,11 +149,11 @@ mm_modem_signal_setup_finish (MMModemSignal *self,
* Since: 1.2
*/
void
-mm_modem_signal_setup (MMModemSignal *self,
- guint rate,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+mm_modem_signal_setup (MMModemSignal *self,
+ guint rate,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
g_return_if_fail (MM_IS_MODEM_SIGNAL (self));
@@ -160,11 +163,12 @@ mm_modem_signal_setup (MMModemSignal *self,
/**
* mm_modem_signal_setup_sync:
* @self: A #MMModemSignal.
- * @rate: Rate to use when refreshing signal values.
+ * @rate: Refresh rate to set, in seconds. Use 0 to disable periodic polling.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
- * Synchronously setups the extended signal quality retrieval.
+ * Synchronously enables or disables the extended signal quality information
+ * retrieval via periodic polling.
*
* The calling thread is blocked until a reply is received. See
* mm_modem_signal_setup() for the asynchronous version of this method.
@@ -174,10 +178,10 @@ mm_modem_signal_setup (MMModemSignal *self,
* Since: 1.2
*/
gboolean
-mm_modem_signal_setup_sync (MMModemSignal *self,
- guint rate,
- GCancellable *cancellable,
- GError **error)
+mm_modem_signal_setup_sync (MMModemSignal *self,
+ guint rate,
+ GCancellable *cancellable,
+ GError **error)
{
g_return_val_if_fail (MM_IS_MODEM_SIGNAL (self), FALSE);
@@ -187,6 +191,93 @@ mm_modem_signal_setup_sync (MMModemSignal *self,
/*****************************************************************************/
/**
+ * mm_modem_signal_setup_thresholds_finish:
+ * @self: A #MMModemSignal.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
+ * mm_modem_signal_setup_thresholds().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with mm_modem_signal_setup_thresholds().
+ *
+ * Returns: %TRUE if the setup was successful, %FALSE if @error is set.
+ *
+ * Since: 1.20
+ */
+gboolean
+mm_modem_signal_setup_thresholds_finish (MMModemSignal *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ g_return_val_if_fail (MM_IS_MODEM_SIGNAL (self), FALSE);
+
+ return mm_gdbus_modem_signal_call_setup_thresholds_finish (MM_GDBUS_MODEM_SIGNAL (self), res, error);
+}
+
+/**
+ * mm_modem_signal_setup_thresholds:
+ * @self: A #MMModemSignal.
+ * @settings: Threshold values to set.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or
+ * %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously setups thresholds so that the device itself decides when to report the
+ * extended signal quality information updates.
+ *
+ * When the operation is finished, @callback will be invoked in the
+ * <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
+ * of the thread you are calling this method from. You can then call
+ * mm_modem_signal_setup_thresholds_finish() to get the result of the operation.
+ *
+ * See mm_modem_signal_setup_thresholds_sync() for the synchronous, blocking version of
+ * this method.
+ *
+ * Since: 1.20
+ */
+void
+mm_modem_signal_setup_thresholds (MMModemSignal *self,
+ GVariant *settings,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (MM_IS_MODEM_SIGNAL (self));
+
+ mm_gdbus_modem_signal_call_setup_thresholds (MM_GDBUS_MODEM_SIGNAL (self), settings, cancellable, callback, user_data);
+}
+
+/**
+ * mm_modem_signal_setup_thresholds_sync:
+ * @self: A #MMModemSignal.
+ * @settings: Threshold values to set.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously setups thresholds so that the device itself decides when to report the
+ * extended signal quality information updates.
+ *
+ * The calling thread is blocked until a reply is received. See
+ * mm_modem_signal_setup_thresholds() for the asynchronous version of this method.
+ *
+ * Returns: %TRUE if the setup was successful, %FALSE if @error is set.
+ *
+ * Since: 1.20
+ */
+gboolean
+mm_modem_signal_setup_thresholds_sync (MMModemSignal *self,
+ GVariant *settings,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_return_val_if_fail (MM_IS_MODEM_SIGNAL (self), FALSE);
+
+ return mm_gdbus_modem_signal_call_setup_thresholds_sync (MM_GDBUS_MODEM_SIGNAL (self), settings, cancellable, error);
+}
+
+/*****************************************************************************/
+
+/**
* mm_modem_signal_get_rate:
* @self: A #MMModemSignal.
*
@@ -207,6 +298,48 @@ mm_modem_signal_get_rate (MMModemSignal *self)
/*****************************************************************************/
/**
+ * mm_modem_signal_get_rssi_threshold:
+ * @self: A #MMModemSignal.
+ *
+ * Gets the currently configured RSSI threshold, in dBm.
+ *
+ * A value of 0 indicates the threshold is disabled.
+ *
+ * Returns: the RSSI threshold.
+ *
+ * Since: 1.20
+ */
+guint
+mm_modem_signal_get_rssi_threshold (MMModemSignal *self)
+{
+ g_return_val_if_fail (MM_IS_MODEM_SIGNAL (self), 0);
+
+ return mm_gdbus_modem_signal_get_rssi_threshold (MM_GDBUS_MODEM_SIGNAL (self));
+}
+
+/*****************************************************************************/
+
+/**
+ * mm_modem_signal_get_error_rate_threshold:
+ * @self: A #MMModemSignal.
+ *
+ * Gets whether the error rate threshold is enabled or not.
+ *
+ * Returns: %TRUE if the error rate threshold is enabled, %FALSE otherwise.
+ *
+ * Since: 1.20
+ */
+gboolean
+mm_modem_signal_get_error_rate_threshold (MMModemSignal *self)
+{
+ g_return_val_if_fail (MM_IS_MODEM_SIGNAL (self), FALSE);
+
+ return mm_gdbus_modem_signal_get_error_rate_threshold (MM_GDBUS_MODEM_SIGNAL (self));
+}
+
+/*****************************************************************************/
+
+/**
* mm_modem_signal_get_cdma:
* @self: A #MMModem.
*
diff --git a/libmm-glib/mm-modem-signal.h b/libmm-glib/mm-modem-signal.h
index 5c0cb6aa..8c859a96 100644
--- a/libmm-glib/mm-modem-signal.h
+++ b/libmm-glib/mm-modem-signal.h
@@ -17,7 +17,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2013 Aleksander Morgado <aleksander@gnu.org>
+ * Copyright (C) 2013-2021 Aleksander Morgado <aleksander@aleksander.es>
+ * Copyright (C) 2021 Intel Corporation
*/
#ifndef _MM_MODEM_SIGNAL_H_
@@ -65,24 +66,38 @@ struct _MMModemSignalClass {
GType mm_modem_signal_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMModemSignal, g_object_unref)
-const gchar *mm_modem_signal_get_path (MMModemSignal *self);
-gchar *mm_modem_signal_dup_path (MMModemSignal *self);
-guint mm_modem_signal_get_rate (MMModemSignal *self);
-
-void mm_modem_signal_setup (MMModemSignal *self,
- guint rate,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean mm_modem_signal_setup_finish (MMModemSignal *self,
- GAsyncResult *res,
- GError **error);
-gboolean mm_modem_signal_setup_sync (MMModemSignal *self,
- guint rate,
- GCancellable *cancellable,
- GError **error);
-
-MMSignal *mm_modem_signal_get_cdma (MMModemSignal *self);
+const gchar *mm_modem_signal_get_path (MMModemSignal *self);
+gchar *mm_modem_signal_dup_path (MMModemSignal *self);
+guint mm_modem_signal_get_rate (MMModemSignal *self);
+guint mm_modem_signal_get_rssi_threshold (MMModemSignal *self);
+gboolean mm_modem_signal_get_error_rate_threshold (MMModemSignal *self);
+
+void mm_modem_signal_setup (MMModemSignal *self,
+ guint rate,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mm_modem_signal_setup_finish (MMModemSignal *self,
+ GAsyncResult *res,
+ GError **error);
+gboolean mm_modem_signal_setup_sync (MMModemSignal *self,
+ guint rate,
+ GCancellable *cancellable,
+ GError **error);
+void mm_modem_signal_setup_thresholds (MMModemSignal *self,
+ GVariant *settings,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mm_modem_signal_setup_thresholds_finish (MMModemSignal *self,
+ GAsyncResult *res,
+ GError **error);
+gboolean mm_modem_signal_setup_thresholds_sync (MMModemSignal *self,
+ GVariant *settings,
+ GCancellable *cancellable,
+ GError **error);
+
+MMSignal *mm_modem_signal_get_cdma (MMModemSignal *self);
MMSignal *mm_modem_signal_peek_cdma (MMModemSignal *self);
MMSignal *mm_modem_signal_get_evdo (MMModemSignal *self);