libmm-glib,mmcli: add support for the new signal 'SetupThresholds()' API
Includes updates by Aleksander Morgado to fix mostly coding style issues.
This commit is contained in:

committed by
Aleksander Morgado

parent
9537261651
commit
925f0bae11
@@ -47,14 +47,19 @@ static Context *ctx;
|
||||
/* Options */
|
||||
static gboolean get_flag;
|
||||
static gchar *setup_str;
|
||||
static gchar *setup_thresholds_str;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{ "signal-setup", 0, 0, G_OPTION_ARG_STRING, &setup_str,
|
||||
"Setup extended signal information retrieval",
|
||||
"Setup signal quality information polling, in seconds",
|
||||
"[Rate]"
|
||||
},
|
||||
{ "signal-setup-thresholds", 0, 0, G_OPTION_ARG_STRING, &setup_thresholds_str,
|
||||
"Setup signal quality information thresholds (allowed keys: rssi-threshold, error-rate-threshold)",
|
||||
"[\"key=value,...\"]"
|
||||
},
|
||||
{ "signal-get", 0, 0, G_OPTION_ARG_NONE, &get_flag,
|
||||
"Get all extended signal quality information",
|
||||
"Get all signal quality information",
|
||||
NULL
|
||||
},
|
||||
{ NULL }
|
||||
@@ -85,6 +90,7 @@ mmcli_modem_signal_options_enabled (void)
|
||||
return !!n_actions;
|
||||
|
||||
n_actions = (!!setup_str +
|
||||
!!setup_thresholds_str +
|
||||
get_flag);
|
||||
|
||||
if (n_actions > 1) {
|
||||
@@ -139,6 +145,8 @@ print_signal_info (void)
|
||||
MMSignal *signal;
|
||||
gdouble value;
|
||||
gchar *refresh_rate;
|
||||
gchar *rssi_threshold;
|
||||
gchar *error_rate_threshold;
|
||||
gchar *cdma1x_rssi = NULL;
|
||||
gchar *cdma1x_ecio = NULL;
|
||||
gchar *cdma1x_error_rate = NULL;
|
||||
@@ -163,7 +171,9 @@ print_signal_info (void)
|
||||
gchar *nr5g_snr = NULL;
|
||||
gchar *nr5g_error_rate = NULL;
|
||||
|
||||
refresh_rate = g_strdup_printf ("%u", mm_modem_signal_get_rate (ctx->modem_signal));
|
||||
refresh_rate = g_strdup_printf ("%u", mm_modem_signal_get_rate (ctx->modem_signal));
|
||||
rssi_threshold = g_strdup_printf ("%u", mm_modem_signal_get_rssi_threshold (ctx->modem_signal));
|
||||
error_rate_threshold = g_strdup_printf ("%s", mm_modem_signal_get_error_rate_threshold (ctx->modem_signal) ? "yes" : "no");
|
||||
|
||||
signal = mm_modem_signal_peek_cdma (ctx->modem_signal);
|
||||
if (signal) {
|
||||
@@ -235,33 +245,126 @@ print_signal_info (void)
|
||||
nr5g_error_rate = g_strdup_printf ("%.2lf", value);
|
||||
}
|
||||
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_REFRESH_RATE, refresh_rate, "seconds");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_CDMA1X_RSSI, cdma1x_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_CDMA1X_ECIO, cdma1x_ecio, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_CDMA1X_ERROR_RATE, cdma1x_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_RSSI, evdo_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_ECIO, evdo_ecio, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_SINR, evdo_sinr, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_IO, evdo_io, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_ERROR_RATE, evdo_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_GSM_RSSI, gsm_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_GSM_ERROR_RATE, gsm_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_RSSI, umts_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_RSCP, umts_rscp, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_ECIO, umts_ecio, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_ERROR_RATE, umts_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_RSSI, lte_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_RSRQ, lte_rsrq, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_RSRP, lte_rsrp, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_SNR, lte_snr, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_ERROR_RATE, lte_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_RSRQ, nr5g_rsrq, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_RSRP, nr5g_rsrp, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_SNR, nr5g_snr, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_ERROR_RATE, nr5g_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_REFRESH_RATE, refresh_rate, "seconds");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_RSSI_THRESHOLD, rssi_threshold, "dBm");
|
||||
mmcli_output_string_take (MMC_F_SIGNAL_ERROR_RATE_THRESHOLD, error_rate_threshold);
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_CDMA1X_RSSI, cdma1x_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_CDMA1X_ECIO, cdma1x_ecio, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_CDMA1X_ERROR_RATE, cdma1x_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_RSSI, evdo_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_ECIO, evdo_ecio, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_SINR, evdo_sinr, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_IO, evdo_io, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_EVDO_ERROR_RATE, evdo_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_GSM_RSSI, gsm_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_GSM_ERROR_RATE, gsm_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_RSSI, umts_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_RSCP, umts_rscp, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_ECIO, umts_ecio, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_UMTS_ERROR_RATE, umts_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_RSSI, lte_rssi, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_RSRQ, lte_rsrq, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_RSRP, lte_rsrp, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_SNR, lte_snr, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_LTE_ERROR_RATE, lte_error_rate, "%%");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_RSRQ, nr5g_rsrq, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_RSRP, nr5g_rsrp, "dBm");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_SNR, nr5g_snr, "dB");
|
||||
mmcli_output_string_take_typed (MMC_F_SIGNAL_5G_ERROR_RATE, nr5g_error_rate, "%%");
|
||||
mmcli_output_dump ();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
guint rssi_threshold;
|
||||
gboolean rssi_set;
|
||||
gboolean error_rate_threshold;
|
||||
gboolean error_rate_set;
|
||||
GError *error;
|
||||
} ParseKeyValueContext;
|
||||
|
||||
static gboolean
|
||||
key_value_foreach (const gchar *key,
|
||||
const gchar *value,
|
||||
ParseKeyValueContext *parse_ctx)
|
||||
{
|
||||
if (g_str_equal (key, "rssi-threshold")) {
|
||||
if (!mm_get_uint_from_str (value, &parse_ctx->rssi_threshold)) {
|
||||
g_set_error (&parse_ctx->error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
|
||||
"invalid RSSI threshold value given: %s", value);
|
||||
return FALSE;
|
||||
}
|
||||
parse_ctx->rssi_set = TRUE;
|
||||
} else if (g_str_equal (key, "error-rate-threshold")) {
|
||||
parse_ctx->error_rate_threshold = mm_common_get_boolean_from_string (value, &parse_ctx->error);
|
||||
if (parse_ctx->error)
|
||||
return FALSE;
|
||||
parse_ctx->error_rate_set = TRUE;
|
||||
} else {
|
||||
g_set_error (&parse_ctx->error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Invalid properties string, unsupported key '%s'", key);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
setup_thresholds_build_input (const gchar *str)
|
||||
{
|
||||
ParseKeyValueContext parse_ctx = { 0 };
|
||||
GVariantBuilder builder;
|
||||
|
||||
mm_common_parse_key_value_string (setup_thresholds_str,
|
||||
&parse_ctx.error,
|
||||
(MMParseKeyValueForeachFn)key_value_foreach,
|
||||
&parse_ctx);
|
||||
/* If error, destroy the object */
|
||||
if (parse_ctx.error) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
|
||||
if (parse_ctx.rssi_set)
|
||||
g_variant_builder_add (&builder,
|
||||
"{sv}",
|
||||
"rssi-threshold",
|
||||
g_variant_new_uint32 (parse_ctx.rssi_threshold));
|
||||
|
||||
if (parse_ctx.error_rate_set)
|
||||
g_variant_builder_add (&builder,
|
||||
"{sv}",
|
||||
"error-rate-threshold",
|
||||
g_variant_new_boolean (parse_ctx.error_rate_threshold));
|
||||
|
||||
return g_variant_ref_sink (g_variant_builder_end (&builder));
|
||||
}
|
||||
|
||||
static void
|
||||
setup_thresholds_process_reply (gboolean result,
|
||||
const GError *error)
|
||||
{
|
||||
if (!result) {
|
||||
g_printerr ("error: couldn't setup signal quality information thresholds: '%s'\n",
|
||||
error ? error->message : "unknown error");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_print ("Successfully setup signal quality information thresholds\n");
|
||||
}
|
||||
|
||||
static void
|
||||
setup_thresholds_ready (MMModemSignal *modem,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
gboolean res;
|
||||
GError *error = NULL;
|
||||
|
||||
res = mm_modem_signal_setup_thresholds_finish (modem, result, &error);
|
||||
setup_thresholds_process_reply (res, error);
|
||||
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
setup_process_reply (gboolean result,
|
||||
const GError *error)
|
||||
@@ -322,6 +425,25 @@ get_modem_ready (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to setup threshold? */
|
||||
if (setup_thresholds_str) {
|
||||
g_autoptr(GVariant) dictionary = NULL;
|
||||
|
||||
dictionary = setup_thresholds_build_input (setup_thresholds_str);
|
||||
if (!dictionary) {
|
||||
g_printerr ("error: failed to parse input threshold setup settings: '%s'", setup_thresholds_str);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_debug ("Asynchronously setting up threshold values...");
|
||||
mm_modem_signal_setup_thresholds (ctx->modem_signal,
|
||||
dictionary,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)setup_thresholds_ready,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
|
||||
@@ -368,7 +490,7 @@ mmcli_modem_signal_run_synchronous (GDBusConnection *connection)
|
||||
|
||||
/* Request to set rate? */
|
||||
if (setup_str) {
|
||||
guint rate;
|
||||
guint rate;
|
||||
gboolean result;
|
||||
|
||||
if (!mm_get_uint_from_str (setup_str, &rate)) {
|
||||
@@ -385,6 +507,25 @@ mmcli_modem_signal_run_synchronous (GDBusConnection *connection)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to setup threshold? */
|
||||
if (setup_thresholds_str) {
|
||||
g_autoptr(GVariant) dictionary = NULL;
|
||||
gboolean result;
|
||||
|
||||
dictionary = setup_thresholds_build_input (setup_thresholds_str);
|
||||
if (!dictionary) {
|
||||
g_printerr ("error: failed to parse input threshold setup settings: '%s'", setup_thresholds_str);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_debug ("Asynchronously setting up threshold values...");
|
||||
result = mm_modem_signal_setup_thresholds_sync (ctx->modem_signal,
|
||||
dictionary,
|
||||
NULL,
|
||||
&error);
|
||||
setup_thresholds_process_reply (result, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
|
@@ -162,6 +162,8 @@ static FieldInfo field_infos[] = {
|
||||
[MMC_F_MESSAGING_SUPPORTED_STORAGES] = { "modem.messaging.supported-storages", "supported storages", MMC_S_MODEM_MESSAGING, },
|
||||
[MMC_F_MESSAGING_DEFAULT_STORAGES] = { "modem.messaging.default-storages", "default storages", MMC_S_MODEM_MESSAGING, },
|
||||
[MMC_F_SIGNAL_REFRESH_RATE] = { "modem.signal.refresh.rate", "refresh rate", MMC_S_MODEM_SIGNAL, },
|
||||
[MMC_F_SIGNAL_RSSI_THRESHOLD] = { "modem.signal.threshold.rssi", "rssi threshold", MMC_S_MODEM_SIGNAL, },
|
||||
[MMC_F_SIGNAL_ERROR_RATE_THRESHOLD] = { "modem.signal.threshold.error-rate", "error rate threshold", MMC_S_MODEM_SIGNAL, },
|
||||
[MMC_F_SIGNAL_CDMA1X_RSSI] = { "modem.signal.cdma1x.rssi", "rssi", MMC_S_MODEM_SIGNAL_CDMA1X, },
|
||||
[MMC_F_SIGNAL_CDMA1X_ECIO] = { "modem.signal.cdma1x.ecio", "ecio", MMC_S_MODEM_SIGNAL_CDMA1X, },
|
||||
[MMC_F_SIGNAL_CDMA1X_ERROR_RATE] = { "modem.signal.cdma1x.error-rate", "error rate", MMC_S_MODEM_SIGNAL_CDMA1X, },
|
||||
|
@@ -173,6 +173,8 @@ typedef enum {
|
||||
MMC_F_MESSAGING_DEFAULT_STORAGES,
|
||||
/* Signal section */
|
||||
MMC_F_SIGNAL_REFRESH_RATE,
|
||||
MMC_F_SIGNAL_RSSI_THRESHOLD,
|
||||
MMC_F_SIGNAL_ERROR_RATE_THRESHOLD,
|
||||
MMC_F_SIGNAL_CDMA1X_RSSI,
|
||||
MMC_F_SIGNAL_CDMA1X_ECIO,
|
||||
MMC_F_SIGNAL_CDMA1X_ERROR_RATE,
|
||||
|
@@ -987,6 +987,8 @@ MMModemSignal
|
||||
mm_modem_signal_get_path
|
||||
mm_modem_signal_dup_path
|
||||
mm_modem_signal_get_rate
|
||||
mm_modem_signal_get_rssi_threshold
|
||||
mm_modem_signal_get_error_rate_threshold
|
||||
mm_modem_signal_peek_cdma
|
||||
mm_modem_signal_get_cdma
|
||||
mm_modem_signal_peek_evdo
|
||||
@@ -1003,6 +1005,9 @@ mm_modem_signal_get_nr5g
|
||||
mm_modem_signal_setup
|
||||
mm_modem_signal_setup_finish
|
||||
mm_modem_signal_setup_sync
|
||||
mm_modem_signal_setup_thresholds
|
||||
mm_modem_signal_setup_thresholds_finish
|
||||
mm_modem_signal_setup_thresholds_sync
|
||||
<SUBSECTION Standard>
|
||||
MMModemSignalPrivate
|
||||
MMModemSignalClass
|
||||
|
@@ -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);
|
||||
|
||||
@@ -186,6 +190,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.
|
||||
@@ -206,6 +297,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.
|
||||
|
@@ -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);
|
||||
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 (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_get_cdma (MMModemSignal *self);
|
||||
MMSignal *mm_modem_signal_peek_cdma (MMModemSignal *self);
|
||||
|
||||
MMSignal *mm_modem_signal_get_evdo (MMModemSignal *self);
|
||||
|
Reference in New Issue
Block a user