icera: port to use object logging

This commit is contained in:
Aleksander Morgado
2020-04-07 15:00:31 +02:00
parent 1cb39536e9
commit fe78612d6d
2 changed files with 42 additions and 47 deletions

View File

@@ -29,7 +29,7 @@
#include "mm-broadband-bearer-icera.h" #include "mm-broadband-bearer-icera.h"
#include "mm-base-modem-at.h" #include "mm-base-modem-at.h"
#include "mm-log.h" #include "mm-log-object.h"
#include "mm-modem-helpers.h" #include "mm-modem-helpers.h"
#include "mm-error-helpers.h" #include "mm-error-helpers.h"
#include "mm-daemon-enums-types.h" #include "mm-daemon-enums-types.h"
@@ -299,37 +299,39 @@ disconnect_ipdpact_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
MMBroadbandBearerIcera *self) MMBroadbandBearerIcera *self)
{ {
GTask *task;
GError *error = NULL; GError *error = NULL;
GTask *task;
/* Try to recover the disconnection task. If none found, it means the /* Try to recover the disconnection task. If none found, it means the
* task was already completed and we have nothing else to do. */ * task was already completed and we have nothing else to do. */
task = self->priv->disconnect_pending; task = g_steal_pointer (&self->priv->disconnect_pending);
/* Balance refcount with the extra ref we passed to command_full() */
g_object_unref (self);
if (!task) { 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 /* 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); mm_base_modem_at_command_full_finish (modem, res, NULL);
return; goto out;
} }
mm_base_modem_at_command_full_finish (modem, res, &error); mm_base_modem_at_command_full_finish (modem, res, &error);
if (error) { if (error) {
self->priv->disconnect_pending = NULL;
g_task_return_error (task, error); g_task_return_error (task, error);
g_object_unref (task); g_object_unref (task);
return; goto out;
} }
/* Track again */
self->priv->disconnect_pending = task;
/* Set a 60-second disconnection-failure timeout */ /* Set a 60-second disconnection-failure timeout */
self->priv->disconnect_pending_id = g_timeout_add_seconds (60, self->priv->disconnect_pending_id = g_timeout_add_seconds (60,
(GSourceFunc)disconnect_3gpp_timed_out_cb, (GSourceFunc)disconnect_3gpp_timed_out_cb,
self); self);
out:
/* Balance refcount with the extra ref we passed to command_full() */
g_object_unref (self);
} }
static void static void
@@ -596,13 +598,12 @@ activate_ready (MMBaseModem *modem,
Dial3gppContext *ctx; Dial3gppContext *ctx;
GError *error = NULL; GError *error = NULL;
task = self->priv->connect_pending; task = g_steal_pointer (&self->priv->connect_pending);
self->priv->connect_pending = NULL;
/* Try to recover the connection context. If none found, it means the /* Try to recover the connection context. If none found, it means the
* context was already completed and we have nothing else to do. */ * context was already completed and we have nothing else to do. */
if (!task) { 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 /* Run _finish() to finalize the async call, even if we don't care
* the result */ * the result */
mm_base_modem_at_command_full_finish (modem, res, NULL); 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 * error ["a profile (CID) is currently active"] if a connect
* is attempted too soon after a disconnect. */ * is attempted too soon after a disconnect. */
if (++ctx->authentication_retries < 3) { 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_error_free (error);
g_timeout_add_seconds (1, (GSourceFunc)retry_authentication_cb, task); g_timeout_add_seconds (1, (GSourceFunc)retry_authentication_cb, task);
return; return;
@@ -725,7 +726,7 @@ authenticate (GTask *task)
/* Both user and password are required; otherwise firmware returns an error */ /* Both user and password are required; otherwise firmware returns an error */
if (!user || !password || allowed_auth == MM_BEARER_ALLOWED_AUTH_NONE) { 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); command = g_strdup_printf ("%%IPDPCFG=%d,0,0,\"\",\"\"", ctx->cid);
} else { } else {
gchar *quoted_user; gchar *quoted_user;
@@ -733,13 +734,13 @@ authenticate (GTask *task)
guint icera_auth; guint icera_auth;
if (allowed_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) { 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; icera_auth = 1;
} else if (allowed_auth & MM_BEARER_ALLOWED_AUTH_PAP) { } 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; icera_auth = 1;
} else if (allowed_auth & MM_BEARER_ALLOWED_AUTH_CHAP) { } 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; icera_auth = 2;
} else { } else {
gchar *str; gchar *str;
@@ -881,8 +882,7 @@ report_connection_status (MMBaseBearer *_self,
return; return;
} }
mm_dbg ("Received spontaneous %%IPDPACT (%s)", mm_obj_dbg (self, "received spontaneous %%IPDPACT (%s)", mm_bearer_connection_status_get_string (status));
mm_bearer_connection_status_get_string (status));
/* Received a random 'DISCONNECTED'...*/ /* Received a random 'DISCONNECTED'...*/
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED || if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED ||

View File

@@ -25,7 +25,7 @@
#include "ModemManager.h" #include "ModemManager.h"
#include "mm-serial-parsers.h" #include "mm-serial-parsers.h"
#include "mm-log.h" #include "mm-log-object.h"
#include "mm-modem-helpers.h" #include "mm-modem-helpers.h"
#include "mm-errors-types.h" #include "mm-errors-types.h"
#include "mm-iface-modem.h" #include "mm-iface-modem.h"
@@ -71,38 +71,38 @@ struct _MMBroadbandModemIceraPrivate {
/* Load supported modes (Modem interface) */ /* Load supported modes (Modem interface) */
static void static void
add_supported_mode (GArray **combinations, add_supported_mode (MMBroadbandModemIcera *self,
GArray **combinations,
guint mode) guint mode)
{ {
MMModemModeCombination combination; MMModemModeCombination combination;
switch (mode) { switch (mode) {
case 0: case 0:
mm_dbg ("Modem supports 2G-only mode"); mm_obj_dbg (self, "2G-only mode supported");
combination.allowed = MM_MODEM_MODE_2G; combination.allowed = MM_MODEM_MODE_2G;
combination.preferred = MM_MODEM_MODE_NONE; combination.preferred = MM_MODEM_MODE_NONE;
break; break;
case 1: case 1:
mm_dbg ("Modem supports 3G-only mode"); mm_obj_dbg (self, "3G-only mode supported");
combination.allowed = MM_MODEM_MODE_3G; combination.allowed = MM_MODEM_MODE_3G;
combination.preferred = MM_MODEM_MODE_NONE; combination.preferred = MM_MODEM_MODE_NONE;
break; break;
case 2: 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.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
combination.preferred = MM_MODEM_MODE_2G; combination.preferred = MM_MODEM_MODE_2G;
break; break;
case 3: 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.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
combination.preferred = MM_MODEM_MODE_3G; combination.preferred = MM_MODEM_MODE_3G;
break; break;
case 5: case 5:
mm_dbg ("Modem supports 'any', but not explicitly listing it");
/* Any, no need to add it to the list */ /* Any, no need to add it to the list */
return; return;
default: default:
mm_warn ("Unsupported Icera mode found: %u", mode); mm_obj_warn (self, "unsupported mode found in %%IPSYS=?: %u", mode);
return; return;
} }
@@ -182,18 +182,18 @@ load_supported_modes_finish (MMIfaceModem *self,
guint j; guint j;
for (j = modefirst; j <= modelast; j++) for (j = modefirst; j <= modelast; j++)
add_supported_mode (&combinations, j); add_supported_mode (MM_BROADBAND_MODEM_ICERA (self), &combinations, j);
} else } 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); g_free (first);
} else { } else {
guint mode; guint mode;
/* Add single */ /* Add single */
if (mm_get_uint_from_str (split[i], &mode)) 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 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; ctx.status = MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED;
break; break;
default: default:
mm_warn ("Unknown Icera connect status %d", status); mm_obj_warn (self, "unknown %%IPDPACT connect status %d", status);
break; break;
} }
@@ -614,10 +614,9 @@ nwstate_query_ready (MMBroadbandModemIcera *self,
GError *error = NULL; GError *error = NULL;
mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (error) { if (error)
mm_dbg ("Couldn't query access technology: '%s'", error->message);
g_task_return_error (task, error); g_task_return_error (task, error);
} else { else {
/* /*
* The unsolicited message handler will already have run and * The unsolicited message handler will already have run and
* removed the NWSTATE response, so we use the result from there. * 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); response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) { if (!response) {
mm_dbg ("Couldn't query unlock retries: '%s'", error->message);
g_task_return_error (task, error); g_task_return_error (task, error);
g_object_unref (task); g_object_unref (task);
return; 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); response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) { if (!response) {
mm_dbg ("Couldn't query current bands: '%s'", error->message);
g_task_return_error (task, error); g_task_return_error (task, error);
g_object_unref (task); g_object_unref (task);
return; return;
@@ -1346,7 +1343,6 @@ load_current_bands_ready (MMIfaceModem *self,
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) { if (!response) {
mm_dbg ("Couldn't query current bands: '%s'", error->message);
g_task_return_error (task, error); g_task_return_error (task, error);
} else { } else {
/* Parse bands from Icera response into MM band numbers */ /* Parse bands from Icera response into MM band numbers */
@@ -1413,7 +1409,6 @@ set_current_bands_next (MMIfaceModem *self,
GError *error = NULL; GError *error = NULL;
if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error)) { 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_task_return_error (task, error);
g_object_unref (task); g_object_unref (task);
return; return;
@@ -1448,14 +1443,14 @@ set_one_band (MMIfaceModem *self,
/* Note that ffs() returning 2 corresponds to 1 << 1, not 1 << 2 */ /* Note that ffs() returning 2 corresponds to 1 << 1, not 1 << 2 */
band--; band--;
mm_dbg("1. enablebits %x disablebits %x band %d enable %d", mm_obj_dbg (self, "preparing %%IPBM command (1/2): enablebits %x, disablebits %x, band %d, enable %d",
ctx->enablebits, ctx->disablebits, band, enable); ctx->enablebits, ctx->disablebits, band, enable);
if (enable) if (enable)
ctx->enablebits &= ~(1 << band); ctx->enablebits &= ~(1 << band);
else else
ctx->disablebits &= ~(1 << band); ctx->disablebits &= ~(1 << band);
mm_dbg("2. enablebits %x disablebits %x", mm_obj_dbg (self, "preparing %%IPBM command (2/2): enablebits %x, disablebits %x",
ctx->enablebits, ctx->disablebits); ctx->enablebits, ctx->disablebits);
command = g_strdup_printf ("%%IPBM=\"%s\",%d", command = g_strdup_printf ("%%IPBM=\"%s\",%d",