aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-04-07 15:00:31 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-04-08 16:35:09 +0200
commitfe78612d6d546604b3a2fc0569f070060c0233f2 (patch)
tree1f1c2804f5ad3efe01a07ae43bfeb1f10924e23e
parent1cb39536e9bbbf22f08fe5f05b359f18d6152d10 (diff)
icera: port to use object logging
-rw-r--r--plugins/icera/mm-broadband-bearer-icera.c44
-rw-r--r--plugins/icera/mm-broadband-modem-icera.c45
2 files changed, 42 insertions, 47 deletions
diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c
index 567d12dc..48bcf49a 100644
--- a/plugins/icera/mm-broadband-bearer-icera.c
+++ b/plugins/icera/mm-broadband-bearer-icera.c
@@ -29,7 +29,7 @@
#include "mm-broadband-bearer-icera.h"
#include "mm-base-modem-at.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-modem-helpers.h"
#include "mm-error-helpers.h"
#include "mm-daemon-enums-types.h"
@@ -299,37 +299,39 @@ disconnect_ipdpact_ready (MMBaseModem *modem,
GAsyncResult *res,
MMBroadbandBearerIcera *self)
{
- GTask *task;
GError *error = NULL;
+ GTask *task;
/* Try to recover the disconnection task. If none found, it means the
* task was already completed and we have nothing else to do. */
- task = self->priv->disconnect_pending;
-
- /* Balance refcount with the extra ref we passed to command_full() */
- g_object_unref (self);
+ task = g_steal_pointer (&self->priv->disconnect_pending);
if (!task) {
- mm_dbg ("Disconnection context was finished already by an unsolicited message");
-
+ mm_obj_dbg (self, "disconnection context was finished already by an unsolicited message");
/* Run _finish() to finalize the async call, even if we don't care
- * the result */
+ * about the result */
mm_base_modem_at_command_full_finish (modem, res, NULL);
- return;
+ goto out;
}
mm_base_modem_at_command_full_finish (modem, res, &error);
if (error) {
- self->priv->disconnect_pending = NULL;
g_task_return_error (task, error);
g_object_unref (task);
- return;
+ goto out;
}
+ /* Track again */
+ self->priv->disconnect_pending = task;
+
/* Set a 60-second disconnection-failure timeout */
self->priv->disconnect_pending_id = g_timeout_add_seconds (60,
(GSourceFunc)disconnect_3gpp_timed_out_cb,
self);
+
+out:
+ /* Balance refcount with the extra ref we passed to command_full() */
+ g_object_unref (self);
}
static void
@@ -596,13 +598,12 @@ activate_ready (MMBaseModem *modem,
Dial3gppContext *ctx;
GError *error = NULL;
- task = self->priv->connect_pending;
- self->priv->connect_pending = NULL;
+ task = g_steal_pointer (&self->priv->connect_pending);
/* Try to recover the connection context. If none found, it means the
* context was already completed and we have nothing else to do. */
if (!task) {
- mm_dbg ("Connection context was finished already by an unsolicited message");
+ mm_obj_dbg (self, "connection context was finished already by an unsolicited message");
/* Run _finish() to finalize the async call, even if we don't care
* the result */
mm_base_modem_at_command_full_finish (modem, res, NULL);
@@ -672,7 +673,7 @@ authenticate_ready (MMBaseModem *modem,
* error ["a profile (CID) is currently active"] if a connect
* is attempted too soon after a disconnect. */
if (++ctx->authentication_retries < 3) {
- mm_dbg ("Authentication failed: '%s'; retrying...", error->message);
+ mm_obj_dbg (self, "authentication failed: %s; retrying...", error->message);
g_error_free (error);
g_timeout_add_seconds (1, (GSourceFunc)retry_authentication_cb, task);
return;
@@ -725,7 +726,7 @@ authenticate (GTask *task)
/* Both user and password are required; otherwise firmware returns an error */
if (!user || !password || allowed_auth == MM_BEARER_ALLOWED_AUTH_NONE) {
- mm_dbg ("Not using authentication");
+ mm_obj_dbg (self, "not using authentication");
command = g_strdup_printf ("%%IPDPCFG=%d,0,0,\"\",\"\"", ctx->cid);
} else {
gchar *quoted_user;
@@ -733,13 +734,13 @@ authenticate (GTask *task)
guint icera_auth;
if (allowed_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) {
- mm_dbg ("Using default (PAP) authentication method");
+ mm_obj_dbg (self, "using default (PAP) authentication method");
icera_auth = 1;
} else if (allowed_auth & MM_BEARER_ALLOWED_AUTH_PAP) {
- mm_dbg ("Using PAP authentication method");
+ mm_obj_dbg (self, "using PAP authentication method");
icera_auth = 1;
} else if (allowed_auth & MM_BEARER_ALLOWED_AUTH_CHAP) {
- mm_dbg ("Using CHAP authentication method");
+ mm_obj_dbg (self, "using CHAP authentication method");
icera_auth = 2;
} else {
gchar *str;
@@ -881,8 +882,7 @@ report_connection_status (MMBaseBearer *_self,
return;
}
- mm_dbg ("Received spontaneous %%IPDPACT (%s)",
- mm_bearer_connection_status_get_string (status));
+ mm_obj_dbg (self, "received spontaneous %%IPDPACT (%s)", mm_bearer_connection_status_get_string (status));
/* Received a random 'DISCONNECTED'...*/
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED ||
diff --git a/plugins/icera/mm-broadband-modem-icera.c b/plugins/icera/mm-broadband-modem-icera.c
index c57ffa75..b459cb57 100644
--- a/plugins/icera/mm-broadband-modem-icera.c
+++ b/plugins/icera/mm-broadband-modem-icera.c
@@ -25,7 +25,7 @@
#include "ModemManager.h"
#include "mm-serial-parsers.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-modem-helpers.h"
#include "mm-errors-types.h"
#include "mm-iface-modem.h"
@@ -71,38 +71,38 @@ struct _MMBroadbandModemIceraPrivate {
/* Load supported modes (Modem interface) */
static void
-add_supported_mode (GArray **combinations,
- guint mode)
+add_supported_mode (MMBroadbandModemIcera *self,
+ GArray **combinations,
+ guint mode)
{
MMModemModeCombination combination;
switch (mode) {
case 0:
- mm_dbg ("Modem supports 2G-only mode");
+ mm_obj_dbg (self, "2G-only mode supported");
combination.allowed = MM_MODEM_MODE_2G;
combination.preferred = MM_MODEM_MODE_NONE;
break;
case 1:
- mm_dbg ("Modem supports 3G-only mode");
+ mm_obj_dbg (self, "3G-only mode supported");
combination.allowed = MM_MODEM_MODE_3G;
combination.preferred = MM_MODEM_MODE_NONE;
break;
case 2:
- mm_dbg ("Modem supports 2G/3G mode with 2G preferred");
+ mm_obj_dbg (self, "2G/3G mode with 2G preferred supported");
combination.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
combination.preferred = MM_MODEM_MODE_2G;
break;
case 3:
- mm_dbg ("Modem supports 2G/3G mode with 3G preferred");
+ mm_obj_dbg (self, "2G/3G mode with 3G preferred supported");
combination.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
combination.preferred = MM_MODEM_MODE_3G;
break;
case 5:
- mm_dbg ("Modem supports 'any', but not explicitly listing it");
/* Any, no need to add it to the list */
return;
default:
- mm_warn ("Unsupported Icera mode found: %u", mode);
+ mm_obj_warn (self, "unsupported mode found in %%IPSYS=?: %u", mode);
return;
}
@@ -182,18 +182,18 @@ load_supported_modes_finish (MMIfaceModem *self,
guint j;
for (j = modefirst; j <= modelast; j++)
- add_supported_mode (&combinations, j);
+ add_supported_mode (MM_BROADBAND_MODEM_ICERA (self), &combinations, j);
} else
- mm_warn ("Couldn't parse mode interval (%s) in %%IPSYS=? response", split[i]);
+ mm_obj_warn (self, "couldn't parse mode interval in %%IPSYS=? response: %s", split[i]);
g_free (first);
} else {
guint mode;
/* Add single */
if (mm_get_uint_from_str (split[i], &mode))
- add_supported_mode (&combinations, mode);
+ add_supported_mode (MM_BROADBAND_MODEM_ICERA (self), &combinations, mode);
else
- mm_warn ("Couldn't parse mode (%s) in %%IPSYS=? response", split[i]);
+ mm_obj_warn (self, "couldn't parse mode in %%IPSYS=? response: %s", split[i]);
}
}
@@ -441,7 +441,7 @@ ipdpact_received (MMPortSerialAt *port,
ctx.status = MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED;
break;
default:
- mm_warn ("Unknown Icera connect status %d", status);
+ mm_obj_warn (self, "unknown %%IPDPACT connect status %d", status);
break;
}
@@ -614,10 +614,9 @@ nwstate_query_ready (MMBroadbandModemIcera *self,
GError *error = NULL;
mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
- if (error) {
- mm_dbg ("Couldn't query access technology: '%s'", error->message);
+ if (error)
g_task_return_error (task, error);
- } else {
+ else {
/*
* The unsolicited message handler will already have run and
* removed the NWSTATE response, so we use the result from there.
@@ -1022,7 +1021,6 @@ load_unlock_retries_ready (MMBaseModem *self,
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) {
- mm_dbg ("Couldn't query unlock retries: '%s'", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
@@ -1260,7 +1258,6 @@ load_supported_bands_get_current_bands_ready (MMIfaceModem *self,
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) {
- mm_dbg ("Couldn't query current bands: '%s'", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
@@ -1346,7 +1343,6 @@ load_current_bands_ready (MMIfaceModem *self,
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) {
- mm_dbg ("Couldn't query current bands: '%s'", error->message);
g_task_return_error (task, error);
} else {
/* Parse bands from Icera response into MM band numbers */
@@ -1413,7 +1409,6 @@ set_current_bands_next (MMIfaceModem *self,
GError *error = NULL;
if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error)) {
- mm_dbg ("Couldn't set current bands: '%s'", error->message);
g_task_return_error (task, error);
g_object_unref (task);
return;
@@ -1448,15 +1443,15 @@ set_one_band (MMIfaceModem *self,
/* Note that ffs() returning 2 corresponds to 1 << 1, not 1 << 2 */
band--;
- mm_dbg("1. enablebits %x disablebits %x band %d enable %d",
- ctx->enablebits, ctx->disablebits, band, enable);
+ mm_obj_dbg (self, "preparing %%IPBM command (1/2): enablebits %x, disablebits %x, band %d, enable %d",
+ ctx->enablebits, ctx->disablebits, band, enable);
if (enable)
ctx->enablebits &= ~(1 << band);
else
ctx->disablebits &= ~(1 << band);
- mm_dbg("2. enablebits %x disablebits %x",
- ctx->enablebits, ctx->disablebits);
+ mm_obj_dbg (self, "preparing %%IPBM command (2/2): enablebits %x, disablebits %x",
+ ctx->enablebits, ctx->disablebits);
command = g_strdup_printf ("%%IPBM=\"%s\",%d",
modem_bands[band].name,