ublox: port to use object logging

This commit is contained in:
Aleksander Morgado
2020-04-08 07:53:06 +02:00
parent e04aa0ea5d
commit ccd0f6de5a
6 changed files with 300 additions and 301 deletions

View File

@@ -28,7 +28,7 @@
#include "mm-broadband-bearer-ublox.h" #include "mm-broadband-bearer-ublox.h"
#include "mm-base-modem-at.h" #include "mm-base-modem-at.h"
#include "mm-log.h" #include "mm-log-object.h"
#include "mm-ublox-enums-types.h" #include "mm-ublox-enums-types.h"
#include "mm-modem-helpers.h" #include "mm-modem-helpers.h"
#include "mm-modem-helpers-ublox.h" #include "mm-modem-helpers-ublox.h"
@@ -56,14 +56,12 @@ struct _MMBroadbandBearerUbloxPrivate {
/* Common connection context and task */ /* Common connection context and task */
typedef struct { typedef struct {
MMBroadbandBearerUblox *self;
MMBroadbandModem *modem; MMBroadbandModem *modem;
MMPortSerialAt *primary; MMPortSerialAt *primary;
MMPort *data; MMPort *data;
guint cid; guint cid;
gboolean auth_required; gboolean auth_required;
/* For IPv4 settings */ MMBearerIpConfig *ip_config; /* For IPv4 settings */
MMBearerIpConfig *ip_config;
} CommonConnectContext; } CommonConnectContext;
static void static void
@@ -73,7 +71,6 @@ common_connect_context_free (CommonConnectContext *ctx)
g_object_unref (ctx->ip_config); g_object_unref (ctx->ip_config);
if (ctx->data) if (ctx->data)
g_object_unref (ctx->data); g_object_unref (ctx->data);
g_object_unref (ctx->self);
g_object_unref (ctx->modem); g_object_unref (ctx->modem);
g_object_unref (ctx->primary); g_object_unref (ctx->primary);
g_slice_free (CommonConnectContext, ctx); g_slice_free (CommonConnectContext, ctx);
@@ -93,7 +90,6 @@ common_connect_task_new (MMBroadbandBearerUblox *self,
GTask *task; GTask *task;
ctx = g_slice_new0 (CommonConnectContext); ctx = g_slice_new0 (CommonConnectContext);
ctx->self = g_object_ref (self);
ctx->modem = g_object_ref (modem); ctx->modem = g_object_ref (modem);
ctx->primary = g_object_ref (primary); ctx->primary = g_object_ref (primary);
ctx->cid = cid; ctx->cid = cid;
@@ -152,7 +148,7 @@ complete_get_ip_config_3gpp (GTask *task)
{ {
CommonConnectContext *ctx; CommonConnectContext *ctx;
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
g_assert (mm_bearer_ip_config_get_method (ctx->ip_config) != MM_BEARER_IP_METHOD_UNKNOWN); g_assert (mm_bearer_ip_config_get_method (ctx->ip_config) != MM_BEARER_IP_METHOD_UNKNOWN);
g_task_return_pointer (task, g_task_return_pointer (task,
mm_bearer_connect_result_new (ctx->data, ctx->ip_config, NULL), mm_bearer_connect_result_new (ctx->data, ctx->ip_config, NULL),
@@ -165,6 +161,7 @@ cgcontrdp_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandBearerUblox *self;
const gchar *response; const gchar *response;
GError *error = NULL; GError *error = NULL;
CommonConnectContext *ctx; CommonConnectContext *ctx;
@@ -172,7 +169,8 @@ cgcontrdp_ready (MMBaseModem *modem,
gchar *subnet = NULL; gchar *subnet = NULL;
gchar *dns_addresses[3] = { NULL, NULL, NULL }; gchar *dns_addresses[3] = { NULL, NULL, NULL };
ctx = (CommonConnectContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
response = mm_base_modem_at_command_finish (modem, res, &error); response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response || !mm_3gpp_parse_cgcontrdp_response (response, if (!response || !mm_3gpp_parse_cgcontrdp_response (response,
@@ -190,14 +188,14 @@ cgcontrdp_ready (MMBaseModem *modem,
return; return;
} }
mm_dbg ("IPv4 address retrieved: %s", local_address); mm_obj_dbg (self, "IPv4 address retrieved: %s", local_address);
mm_bearer_ip_config_set_address (ctx->ip_config, local_address); mm_bearer_ip_config_set_address (ctx->ip_config, local_address);
mm_dbg ("IPv4 subnet retrieved: %s", subnet); mm_obj_dbg (self, "IPv4 subnet retrieved: %s", subnet);
mm_bearer_ip_config_set_prefix (ctx->ip_config, mm_netmask_to_cidr (subnet)); mm_bearer_ip_config_set_prefix (ctx->ip_config, mm_netmask_to_cidr (subnet));
if (dns_addresses[0]) if (dns_addresses[0])
mm_dbg ("Primary DNS retrieved: %s", dns_addresses[0]); mm_obj_dbg (self, "primary DNS retrieved: %s", dns_addresses[0]);
if (dns_addresses[1]) if (dns_addresses[1])
mm_dbg ("Secondary DNS retrieved: %s", dns_addresses[1]); mm_obj_dbg (self, "secondary DNS retrieved: %s", dns_addresses[1]);
mm_bearer_ip_config_set_dns (ctx->ip_config, (const gchar **) dns_addresses); mm_bearer_ip_config_set_dns (ctx->ip_config, (const gchar **) dns_addresses);
g_free (local_address); g_free (local_address);
@@ -205,7 +203,7 @@ cgcontrdp_ready (MMBaseModem *modem,
g_free (dns_addresses[0]); g_free (dns_addresses[0]);
g_free (dns_addresses[1]); g_free (dns_addresses[1]);
mm_dbg ("finished IP settings retrieval for PDP context #%u...", ctx->cid); mm_obj_dbg (self, "finished IP settings retrieval for PDP context #%u...", ctx->cid);
complete_get_ip_config_3gpp (task); complete_get_ip_config_3gpp (task);
} }
@@ -215,13 +213,15 @@ uipaddr_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandBearerUblox *self;
const gchar *response; const gchar *response;
gchar *cmd; gchar *cmd;
GError *error = NULL; GError *error = NULL;
CommonConnectContext *ctx; CommonConnectContext *ctx;
gchar *gw_ipv4_address = NULL; gchar *gw_ipv4_address = NULL;
ctx = (CommonConnectContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
response = mm_base_modem_at_command_finish (modem, res, &error); response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response || !mm_ublox_parse_uipaddr_response (response, if (!response || !mm_ublox_parse_uipaddr_response (response,
@@ -237,12 +237,12 @@ uipaddr_ready (MMBaseModem *modem,
return; return;
} }
mm_dbg ("IPv4 gateway address retrieved: %s", gw_ipv4_address); mm_obj_dbg (self, "IPv4 gateway address retrieved: %s", gw_ipv4_address);
mm_bearer_ip_config_set_gateway (ctx->ip_config, gw_ipv4_address); mm_bearer_ip_config_set_gateway (ctx->ip_config, gw_ipv4_address);
g_free (gw_ipv4_address); g_free (gw_ipv4_address);
cmd = g_strdup_printf ("+CGCONTRDP=%u", ctx->cid); cmd = g_strdup_printf ("+CGCONTRDP=%u", ctx->cid);
mm_dbg ("gathering IP and DNS information for PDP context #%u...", ctx->cid); mm_obj_dbg (self, "gathering IP and DNS information for PDP context #%u...", ctx->cid);
mm_base_modem_at_command (MM_BASE_MODEM (modem), mm_base_modem_at_command (MM_BASE_MODEM (modem),
cmd, cmd,
10, 10,
@@ -253,7 +253,7 @@ uipaddr_ready (MMBaseModem *modem,
} }
static void static void
get_ip_config_3gpp (MMBroadbandBearer *self, get_ip_config_3gpp (MMBroadbandBearer *_self,
MMBroadbandModem *modem, MMBroadbandModem *modem,
MMPortSerialAt *primary, MMPortSerialAt *primary,
MMPortSerialAt *secondary, MMPortSerialAt *secondary,
@@ -263,6 +263,7 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
MMBroadbandBearerUblox *self = MM_BROADBAND_BEARER_UBLOX (_self);
GTask *task; GTask *task;
CommonConnectContext *ctx; CommonConnectContext *ctx;
@@ -276,20 +277,20 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
user_data))) user_data)))
return; return;
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
ctx->ip_config = mm_bearer_ip_config_new (); ctx->ip_config = mm_bearer_ip_config_new ();
/* If we're in BRIDGE mode, we need to ask for static IP addressing details: /* If we're in BRIDGE mode, we need to ask for static IP addressing details:
* - AT+UIPADDR=[CID] will give us the default gateway address. * - AT+UIPADDR=[CID] will give us the default gateway address.
* - +CGCONTRDP?[CID] will give us the IP address, subnet and DNS addresses. * - +CGCONTRDP?[CID] will give us the IP address, subnet and DNS addresses.
*/ */
if (ctx->self->priv->mode == MM_UBLOX_NETWORKING_MODE_BRIDGE) { if (self->priv->mode == MM_UBLOX_NETWORKING_MODE_BRIDGE) {
gchar *cmd; gchar *cmd;
mm_bearer_ip_config_set_method (ctx->ip_config, MM_BEARER_IP_METHOD_STATIC); mm_bearer_ip_config_set_method (ctx->ip_config, MM_BEARER_IP_METHOD_STATIC);
cmd = g_strdup_printf ("+UIPADDR=%u", cid); cmd = g_strdup_printf ("+UIPADDR=%u", cid);
mm_dbg ("gathering gateway information for PDP context #%u...", cid); mm_obj_dbg (self, "gathering gateway information for PDP context #%u...", cid);
mm_base_modem_at_command (MM_BASE_MODEM (modem), mm_base_modem_at_command (MM_BASE_MODEM (modem),
cmd, cmd,
10, 10,
@@ -302,7 +303,7 @@ get_ip_config_3gpp (MMBroadbandBearer *self,
/* If we're in ROUTER networking mode, we just need to request DHCP on the /* If we're in ROUTER networking mode, we just need to request DHCP on the
* network interface. Early return with that result. */ * network interface. Early return with that result. */
if (ctx->self->priv->mode == MM_UBLOX_NETWORKING_MODE_ROUTER) { if (self->priv->mode == MM_UBLOX_NETWORKING_MODE_ROUTER) {
mm_bearer_ip_config_set_method (ctx->ip_config, MM_BEARER_IP_METHOD_DHCP); mm_bearer_ip_config_set_method (ctx->ip_config, MM_BEARER_IP_METHOD_DHCP);
complete_get_ip_config_3gpp (task); complete_get_ip_config_3gpp (task);
return; return;
@@ -332,7 +333,7 @@ cedata_activate_ready (MMBaseModem *modem,
response = mm_base_modem_at_command_finish (modem, res, &error); response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response) { if (!response) {
mm_warn ("ECM data connection attempt failed: %s", error->message); mm_obj_warn (self, "ECM data connection attempt failed: %s", error->message);
mm_base_bearer_report_connection_status (MM_BASE_BEARER (self), mm_base_bearer_report_connection_status (MM_BASE_BEARER (self),
MM_BEARER_CONNECTION_STATUS_DISCONNECTED); MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
g_error_free (error); g_error_free (error);
@@ -350,7 +351,7 @@ cgact_activate_ready (MMBaseModem *modem,
GError *error = NULL; GError *error = NULL;
CommonConnectContext *ctx; CommonConnectContext *ctx;
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
response = mm_base_modem_at_command_finish (modem, res, &error); response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response) if (!response)
@@ -363,32 +364,36 @@ cgact_activate_ready (MMBaseModem *modem,
static void static void
activate_3gpp (GTask *task) activate_3gpp (GTask *task)
{ {
MMBroadbandBearerUblox *self;
CommonConnectContext *ctx; CommonConnectContext *ctx;
gchar *cmd; g_autofree gchar *cmd = NULL;
ctx = (CommonConnectContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
if (ctx->self->priv->profile == MM_UBLOX_USB_PROFILE_ECM &&
ctx->self->priv->cedata == FEATURE_SUPPORTED) {
/* SARA-U2xx and LISA-U20x only expose one CDC-ECM interface. Hence, /* SARA-U2xx and LISA-U20x only expose one CDC-ECM interface. Hence,
the fixed 0 as the interface index here. When we see modems with * the fixed 0 as the interface index here. When we see modems with
multiple interfaces, this needs to be revisited. */ * multiple interfaces, this needs to be revisited. */
if (self->priv->profile == MM_UBLOX_USB_PROFILE_ECM && self->priv->cedata == FEATURE_SUPPORTED) {
cmd = g_strdup_printf ("+UCEDATA=%u,0", ctx->cid); cmd = g_strdup_printf ("+UCEDATA=%u,0", ctx->cid);
mm_dbg ("establishing ECM data connection for PDP context #%u...", ctx->cid); mm_obj_dbg (self, "establishing ECM data connection for PDP context #%u...", ctx->cid);
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem), mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
cmd, cmd,
180, 180,
FALSE, FALSE,
(GAsyncReadyCallback) cedata_activate_ready, (GAsyncReadyCallback) cedata_activate_ready,
g_object_ref (ctx->self)); g_object_ref (self));
/* We'll mark the task done here since the modem expects the DHCP /* We'll mark the task done here since the modem expects the DHCP
discover packet while +UCEDATA runs. If the command fails, we'll discover packet while +UCEDATA runs. If the command fails, we'll
mark the bearer disconnected later in the callback. */ mark the bearer disconnected later in the callback. */
g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref); g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref);
g_object_unref (task); g_object_unref (task);
} else { return;
}
cmd = g_strdup_printf ("+CGACT=1,%u", ctx->cid); cmd = g_strdup_printf ("+CGACT=1,%u", ctx->cid);
mm_dbg ("activating PDP context #%u...", ctx->cid); mm_obj_dbg (self, "activating PDP context #%u...", ctx->cid);
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem), mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
cmd, cmd,
120, 120,
@@ -396,26 +401,24 @@ activate_3gpp (GTask *task)
(GAsyncReadyCallback) cgact_activate_ready, (GAsyncReadyCallback) cgact_activate_ready,
task); task);
} }
g_free (cmd);
}
static void static void
test_cedata_ready (MMBaseModem *modem, test_cedata_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
CommonConnectContext *ctx; MMBroadbandBearerUblox *self;
const gchar *response; const gchar *response;
ctx = (CommonConnectContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
response = mm_base_modem_at_command_finish (modem, res, NULL); response = mm_base_modem_at_command_finish (modem, res, NULL);
if (response) if (response)
ctx->self->priv->cedata = FEATURE_SUPPORTED; self->priv->cedata = FEATURE_SUPPORTED;
else else
ctx->self->priv->cedata = FEATURE_UNSUPPORTED; self->priv->cedata = FEATURE_UNSUPPORTED;
mm_dbg ("u-blox: +UCEDATA command%s available", mm_obj_dbg (self, "u-blox: +UCEDATA command%s available",
(ctx->self->priv->cedata == FEATURE_SUPPORTED) ? "" : " not"); (self->priv->cedata == FEATURE_SUPPORTED) ? "" : " not");
activate_3gpp (task); activate_3gpp (task);
} }
@@ -423,19 +426,20 @@ test_cedata_ready (MMBaseModem *modem,
static void static void
test_cedata (GTask *task) test_cedata (GTask *task)
{ {
MMBroadbandBearerUblox *self;
CommonConnectContext *ctx; CommonConnectContext *ctx;
ctx = (CommonConnectContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
/* We don't need to test for +UCEDATA if we're not using CDC-ECM or if we /* We don't need to test for +UCEDATA if we're not using CDC-ECM or if we
have tested before. Instead, we jump right to the activation. */ have tested before. Instead, we jump right to the activation. */
if (ctx->self->priv->profile != MM_UBLOX_USB_PROFILE_ECM || if (self->priv->profile != MM_UBLOX_USB_PROFILE_ECM || self->priv->cedata != FEATURE_SUPPORT_UNKNOWN) {
ctx->self->priv->cedata != FEATURE_SUPPORT_UNKNOWN) {
activate_3gpp (task); activate_3gpp (task);
return; return;
} }
mm_dbg ("u-blox: checking availability of +UCEDATA command..."); mm_obj_dbg (self, "u-blox: checking availability of +UCEDATA command...");
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem), mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
"+UCEDATA=?", "+UCEDATA=?",
3, 3,
@@ -456,7 +460,7 @@ uauthreq_ready (MMBaseModem *modem,
if (!response) { if (!response) {
CommonConnectContext *ctx; CommonConnectContext *ctx;
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
/* If authentication required and the +UAUTHREQ failed, abort */ /* If authentication required and the +UAUTHREQ failed, abort */
if (ctx->auth_required) { if (ctx->auth_required) {
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -475,23 +479,23 @@ authenticate_3gpp (GTask *task)
{ {
MMBroadbandBearerUblox *self; MMBroadbandBearerUblox *self;
CommonConnectContext *ctx; CommonConnectContext *ctx;
gchar *cmd = NULL; g_autofree gchar *cmd = NULL;
MMBearerAllowedAuth allowed_auth; MMBearerAllowedAuth allowed_auth;
gint ublox_auth = -1; gint ublox_auth = -1;
self = g_task_get_source_object (task); self = g_task_get_source_object (task);
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
allowed_auth = mm_bearer_properties_get_allowed_auth (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self))); allowed_auth = mm_bearer_properties_get_allowed_auth (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
if (!ctx->auth_required) { if (!ctx->auth_required) {
mm_dbg ("Not using authentication"); mm_obj_dbg (self, "not using authentication");
ublox_auth = 0; ublox_auth = 0;
goto out; goto out;
} }
if (allowed_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN || allowed_auth == (MM_BEARER_ALLOWED_AUTH_PAP | MM_BEARER_ALLOWED_AUTH_CHAP)) { if (allowed_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN || allowed_auth == (MM_BEARER_ALLOWED_AUTH_PAP | MM_BEARER_ALLOWED_AUTH_CHAP)) {
mm_dbg ("Using automatic authentication method"); mm_obj_dbg (self, "using automatic authentication method");
if (self->priv->allowed_auths & MM_UBLOX_BEARER_ALLOWED_AUTH_AUTO) if (self->priv->allowed_auths & MM_UBLOX_BEARER_ALLOWED_AUTH_AUTO)
ublox_auth = 3; ublox_auth = 3;
else if (self->priv->allowed_auths & MM_UBLOX_BEARER_ALLOWED_AUTH_PAP) else if (self->priv->allowed_auths & MM_UBLOX_BEARER_ALLOWED_AUTH_PAP)
@@ -501,34 +505,33 @@ authenticate_3gpp (GTask *task)
else if (self->priv->allowed_auths & MM_UBLOX_BEARER_ALLOWED_AUTH_NONE) else if (self->priv->allowed_auths & MM_UBLOX_BEARER_ALLOWED_AUTH_NONE)
ublox_auth = 0; ublox_auth = 0;
} 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");
ublox_auth = 1; ublox_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");
ublox_auth = 2; ublox_auth = 2;
} }
out: out:
if (ublox_auth < 0) { if (ublox_auth < 0) {
gchar *str; g_autofree gchar *str = NULL;
str = mm_bearer_allowed_auth_build_string_from_mask (allowed_auth); str = mm_bearer_allowed_auth_build_string_from_mask (allowed_auth);
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Cannot use any of the specified authentication methods (%s)", str); "Cannot use any of the specified authentication methods (%s)", str);
g_object_unref (task); g_object_unref (task);
g_free (str);
return; return;
} }
if (ublox_auth > 0) { if (ublox_auth > 0) {
const gchar *user; const gchar *user;
const gchar *password; const gchar *password;
gchar *quoted_user; g_autofree gchar *quoted_user = NULL;
gchar *quoted_password; g_autofree gchar *quoted_password = NULL;
user = mm_bearer_properties_get_user (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self))); user = mm_bearer_properties_get_user (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
password = mm_bearer_properties_get_password (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self))); password = mm_bearer_properties_get_password (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
quoted_user = mm_port_serial_at_quote_string (user); quoted_user = mm_port_serial_at_quote_string (user);
quoted_password = mm_port_serial_at_quote_string (password); quoted_password = mm_port_serial_at_quote_string (password);
@@ -538,20 +541,16 @@ out:
ublox_auth, ublox_auth,
quoted_user, quoted_user,
quoted_password); quoted_password);
g_free (quoted_user);
g_free (quoted_password);
} else } else
cmd = g_strdup_printf ("+UAUTHREQ=%u,0,\"\",\"\"", ctx->cid); cmd = g_strdup_printf ("+UAUTHREQ=%u,0,\"\",\"\"", ctx->cid);
mm_dbg ("setting up authentication preferences in PDP context #%u...", ctx->cid); mm_obj_dbg (self, "setting up authentication preferences in PDP context #%u...", ctx->cid);
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem), mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
cmd, cmd,
10, 10,
FALSE, FALSE,
(GAsyncReadyCallback) uauthreq_ready, (GAsyncReadyCallback) uauthreq_ready,
task); task);
g_free (cmd);
} }
static void static void
@@ -569,12 +568,12 @@ uauthreq_test_ready (MMBaseModem *modem,
if (!response) if (!response)
goto out; goto out;
self->priv->allowed_auths = mm_ublox_parse_uauthreq_test (response, &error); self->priv->allowed_auths = mm_ublox_parse_uauthreq_test (response, self, &error);
out: out:
if (error) { if (error) {
CommonConnectContext *ctx; CommonConnectContext *ctx;
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
/* If authentication required and the +UAUTHREQ test failed, abort */ /* If authentication required and the +UAUTHREQ test failed, abort */
if (ctx->auth_required) { if (ctx->auth_required) {
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -601,11 +600,11 @@ check_supported_authentication_methods (GTask *task)
MMBearerAllowedAuth allowed_auth; MMBearerAllowedAuth allowed_auth;
self = g_task_get_source_object (task); self = g_task_get_source_object (task);
ctx = (CommonConnectContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
user = mm_bearer_properties_get_user (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self))); user = mm_bearer_properties_get_user (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
password = mm_bearer_properties_get_password (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self))); password = mm_bearer_properties_get_password (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
allowed_auth = mm_bearer_properties_get_allowed_auth (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self))); allowed_auth = mm_bearer_properties_get_allowed_auth (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
/* Flag whether authentication is required. If it isn't, we won't fail /* Flag whether authentication is required. If it isn't, we won't fail
* connection attempt if the +UAUTHREQ command fails */ * connection attempt if the +UAUTHREQ command fails */
@@ -617,7 +616,7 @@ check_supported_authentication_methods (GTask *task)
return; return;
} }
mm_dbg ("checking supported authentication methods..."); mm_obj_dbg (self, "checking supported authentication methods...");
mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem), mm_base_modem_at_command (MM_BASE_MODEM (ctx->modem),
"+UAUTHREQ=?", "+UAUTHREQ=?",
10, 10,
@@ -666,9 +665,12 @@ cgact_deactivate_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandBearerUblox *self;
const gchar *response; const gchar *response;
GError *error = NULL; GError *error = NULL;
self = g_task_get_source_object (task);
response = mm_base_modem_at_command_finish (modem, res, &error); response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response) { if (!response) {
/* TOBY-L4 and TOBY-L2 L2 don't allow to disconnect the last LTE bearer /* TOBY-L4 and TOBY-L2 L2 don't allow to disconnect the last LTE bearer
@@ -693,7 +695,7 @@ cgact_deactivate_ready (MMBaseModem *modem,
return; return;
} }
mm_dbg ("ignored error when disconnecting last LTE bearer: %s", error->message); mm_obj_dbg (self, "ignored error when disconnecting last LTE bearer: %s", error->message);
g_clear_error (&error); g_clear_error (&error);
} }
@@ -712,7 +714,7 @@ disconnect_3gpp (MMBroadbandBearer *self,
gpointer user_data) gpointer user_data)
{ {
GTask *task; GTask *task;
gchar *cmd; g_autofree gchar *cmd = NULL;
if (!(task = common_connect_task_new (MM_BROADBAND_BEARER_UBLOX (self), if (!(task = common_connect_task_new (MM_BROADBAND_BEARER_UBLOX (self),
MM_BROADBAND_MODEM (modem), MM_BROADBAND_MODEM (modem),
@@ -725,14 +727,13 @@ disconnect_3gpp (MMBroadbandBearer *self,
return; return;
cmd = g_strdup_printf ("+CGACT=0,%u", cid); cmd = g_strdup_printf ("+CGACT=0,%u", cid);
mm_dbg ("deactivating PDP context #%u...", cid); mm_obj_dbg (self, "deactivating PDP context #%u...", cid);
mm_base_modem_at_command (MM_BASE_MODEM (modem), mm_base_modem_at_command (MM_BASE_MODEM (modem),
cmd, cmd,
120, 120,
FALSE, FALSE,
(GAsyncReadyCallback) cgact_deactivate_ready, (GAsyncReadyCallback) cgact_deactivate_ready,
task); task);
g_free (cmd);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -22,7 +22,7 @@
#include <ctype.h> #include <ctype.h>
#include "ModemManager.h" #include "ModemManager.h"
#include "mm-log.h" #include "mm-log-object.h"
#include "mm-iface-modem.h" #include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h" #include "mm-iface-modem-3gpp.h"
#include "mm-iface-modem-voice.h" #include "mm-iface-modem-voice.h"
@@ -87,7 +87,7 @@ preload_support_config (MMBroadbandModemUblox *self)
model = mm_iface_modem_get_model (MM_IFACE_MODEM (self)); model = mm_iface_modem_get_model (MM_IFACE_MODEM (self));
if (!mm_ublox_get_support_config (model, &self->priv->support_config, &error)) { if (!mm_ublox_get_support_config (model, &self->priv->support_config, &error)) {
mm_warn ("loading support configuration failed: %s", error->message); mm_obj_warn (self, "loading support configuration failed: %s", error->message);
g_error_free (error); g_error_free (error);
/* default to NOT SUPPORTED if unknown model */ /* default to NOT SUPPORTED if unknown model */
@@ -95,14 +95,14 @@ preload_support_config (MMBroadbandModemUblox *self)
self->priv->support_config.uact = FEATURE_UNSUPPORTED; self->priv->support_config.uact = FEATURE_UNSUPPORTED;
self->priv->support_config.ubandsel = FEATURE_UNSUPPORTED; self->priv->support_config.ubandsel = FEATURE_UNSUPPORTED;
} else } else
mm_dbg ("support configuration found for '%s'", model); mm_obj_dbg (self, "support configuration found for '%s'", model);
switch (self->priv->support_config.method) { switch (self->priv->support_config.method) {
case SETTINGS_UPDATE_METHOD_CFUN: case SETTINGS_UPDATE_METHOD_CFUN:
mm_dbg (" band update requires low-power mode"); mm_obj_dbg (self, " band update requires low-power mode");
break; break;
case SETTINGS_UPDATE_METHOD_COPS: case SETTINGS_UPDATE_METHOD_COPS:
mm_dbg (" band update requires explicit unregistration"); mm_obj_dbg (self, " band update requires explicit unregistration");
break; break;
case SETTINGS_UPDATE_METHOD_UNKNOWN: case SETTINGS_UPDATE_METHOD_UNKNOWN:
/* not an error, this just means we don't need anything special */ /* not an error, this just means we don't need anything special */
@@ -113,10 +113,10 @@ preload_support_config (MMBroadbandModemUblox *self)
switch (self->priv->support_config.uact) { switch (self->priv->support_config.uact) {
case FEATURE_SUPPORTED: case FEATURE_SUPPORTED:
mm_dbg (" UACT based band configuration supported"); mm_obj_dbg (self, " UACT based band configuration supported");
break; break;
case FEATURE_UNSUPPORTED: case FEATURE_UNSUPPORTED:
mm_dbg (" UACT based band configuration unsupported"); mm_obj_dbg (self, " UACT based band configuration unsupported");
break; break;
case FEATURE_SUPPORT_UNKNOWN: case FEATURE_SUPPORT_UNKNOWN:
default: default:
@@ -125,10 +125,10 @@ preload_support_config (MMBroadbandModemUblox *self)
switch (self->priv->support_config.ubandsel) { switch (self->priv->support_config.ubandsel) {
case FEATURE_SUPPORTED: case FEATURE_SUPPORTED:
mm_dbg (" UBANDSEL based band configuration supported"); mm_obj_dbg (self, " UBANDSEL based band configuration supported");
break; break;
case FEATURE_UNSUPPORTED: case FEATURE_UNSUPPORTED:
mm_dbg (" UBANDSEL based band configuration unsupported"); mm_obj_dbg (self, " UBANDSEL based band configuration unsupported");
break; break;
case FEATURE_SUPPORT_UNKNOWN: case FEATURE_SUPPORT_UNKNOWN:
default: default:
@@ -182,7 +182,7 @@ load_supported_bands (MMIfaceModem *self,
model = mm_iface_modem_get_model (self); model = mm_iface_modem_get_model (self);
task = g_task_new (self, NULL, callback, user_data); task = g_task_new (self, NULL, callback, user_data);
bands = mm_ublox_get_supported_bands (model, &error); bands = mm_ublox_get_supported_bands (model, self, &error);
if (!bands) if (!bands)
g_task_return_error (task, error); g_task_return_error (task, error);
else else
@@ -246,7 +246,7 @@ ubandsel_load_current_bands_ready (MMBaseModem *self,
} }
model = mm_iface_modem_get_model (MM_IFACE_MODEM (self)); model = mm_iface_modem_get_model (MM_IFACE_MODEM (self));
out = mm_ublox_parse_ubandsel_response (response, model, &error); out = mm_ublox_parse_ubandsel_response (response, model, self, &error);
if (!out) { if (!out) {
g_task_return_error (task, error); g_task_return_error (task, error);
g_object_unref (task); g_object_unref (task);
@@ -311,7 +311,6 @@ typedef enum {
} SetCurrentModesBandsStep; } SetCurrentModesBandsStep;
typedef struct { typedef struct {
MMBroadbandModemUblox *self;
SetCurrentModesBandsStep step; SetCurrentModesBandsStep step;
gchar *command; gchar *command;
MMModemPowerState initial_state; MMModemPowerState initial_state;
@@ -323,19 +322,16 @@ set_current_modes_bands_context_free (SetCurrentModesBandsContext *ctx)
{ {
g_assert (!ctx->saved_error); g_assert (!ctx->saved_error);
g_free (ctx->command); g_free (ctx->command);
g_object_unref (ctx->self);
g_slice_free (SetCurrentModesBandsContext, ctx); g_slice_free (SetCurrentModesBandsContext, ctx);
} }
static void static void
set_current_modes_bands_context_new (GTask *task, set_current_modes_bands_context_new (GTask *task,
MMIfaceModem *self,
gchar *command) gchar *command)
{ {
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
ctx = g_slice_new0 (SetCurrentModesBandsContext); ctx = g_slice_new0 (SetCurrentModesBandsContext);
ctx->self = MM_BROADBAND_MODEM_UBLOX (g_object_ref (self));
ctx->command = command; ctx->command = command;
ctx->initial_state = MM_MODEM_POWER_STATE_UNKNOWN; ctx->initial_state = MM_MODEM_POWER_STATE_UNKNOWN;
ctx->step = SET_CURRENT_MODES_BANDS_STEP_FIRST; ctx->step = SET_CURRENT_MODES_BANDS_STEP_FIRST;
@@ -359,8 +355,7 @@ set_current_modes_bands_reregister_in_network_ready (MMIfaceModem3gpp *self,
{ {
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
ctx = (SetCurrentModesBandsContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
g_assert (ctx);
/* propagate the error if none already set */ /* propagate the error if none already set */
mm_iface_modem_3gpp_reregister_in_network_finish (self, res, ctx->saved_error ? NULL : &ctx->saved_error); mm_iface_modem_3gpp_reregister_in_network_finish (self, res, ctx->saved_error ? NULL : &ctx->saved_error);
@@ -377,8 +372,7 @@ set_current_modes_bands_after_command_ready (MMBaseModem *self,
{ {
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
ctx = (SetCurrentModesBandsContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
g_assert (ctx);
/* propagate the error if none already set */ /* propagate the error if none already set */
mm_base_modem_at_command_finish (self, res, ctx->saved_error ? NULL : &ctx->saved_error); mm_base_modem_at_command_finish (self, res, ctx->saved_error ? NULL : &ctx->saved_error);
@@ -395,8 +389,7 @@ set_current_modes_bands_command_ready (MMBaseModem *self,
{ {
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
ctx = (SetCurrentModesBandsContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
g_assert (ctx);
if (!mm_base_modem_at_command_finish (self, res, &ctx->saved_error)) if (!mm_base_modem_at_command_finish (self, res, &ctx->saved_error))
ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE; ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE;
@@ -413,8 +406,7 @@ set_current_modes_bands_before_command_ready (MMBaseModem *self,
{ {
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
ctx = (SetCurrentModesBandsContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
g_assert (ctx);
if (!mm_base_modem_at_command_finish (self, res, &ctx->saved_error)) if (!mm_base_modem_at_command_finish (self, res, &ctx->saved_error))
ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE; ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE;
@@ -425,18 +417,19 @@ set_current_modes_bands_before_command_ready (MMBaseModem *self,
} }
static void static void
set_current_modes_bands_current_power_ready (MMBaseModem *self, set_current_modes_bands_current_power_ready (MMBaseModem *_self,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemUblox *self = MM_BROADBAND_MODEM_UBLOX (_self);
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
const gchar *response; const gchar *response;
ctx = (SetCurrentModesBandsContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
g_assert (ctx);
g_assert (ctx->self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN);
response = mm_base_modem_at_command_finish (self, res, &ctx->saved_error); g_assert (self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN);
response = mm_base_modem_at_command_finish (_self, res, &ctx->saved_error);
if (!response || !mm_ublox_parse_cfun_response (response, &ctx->initial_state, &ctx->saved_error)) if (!response || !mm_ublox_parse_cfun_response (response, &ctx->initial_state, &ctx->saved_error))
ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE; ctx->step = SET_CURRENT_MODES_BANDS_STEP_RELEASE;
else else
@@ -448,10 +441,11 @@ set_current_modes_bands_current_power_ready (MMBaseModem *self,
static void static void
set_current_modes_bands_step (GTask *task) set_current_modes_bands_step (GTask *task)
{ {
MMBroadbandModemUblox *self;
SetCurrentModesBandsContext *ctx; SetCurrentModesBandsContext *ctx;
ctx = (SetCurrentModesBandsContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
g_assert (ctx); ctx = g_task_get_task_data (task);
switch (ctx->step) { switch (ctx->step) {
case SET_CURRENT_MODES_BANDS_STEP_FIRST: case SET_CURRENT_MODES_BANDS_STEP_FIRST:
@@ -459,8 +453,8 @@ set_current_modes_bands_step (GTask *task)
/* fall through */ /* fall through */
case SET_CURRENT_MODES_BANDS_STEP_ACQUIRE: case SET_CURRENT_MODES_BANDS_STEP_ACQUIRE:
mm_dbg ("acquiring power operation..."); mm_obj_dbg (self, "acquiring power operation...");
if (!acquire_power_operation (ctx->self, &ctx->saved_error)) { if (!acquire_power_operation (self, &ctx->saved_error)) {
ctx->step = SET_CURRENT_MODES_BANDS_STEP_LAST; ctx->step = SET_CURRENT_MODES_BANDS_STEP_LAST;
set_current_modes_bands_step (task); set_current_modes_bands_step (task);
return; return;
@@ -472,9 +466,9 @@ set_current_modes_bands_step (GTask *task)
/* If using CFUN, we check whether we're already in low-power mode. /* If using CFUN, we check whether we're already in low-power mode.
* And if we are, we just skip triggering low-power mode ourselves. * And if we are, we just skip triggering low-power mode ourselves.
*/ */
if (ctx->self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN) { if (self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN) {
mm_dbg ("checking current power operation..."); mm_obj_dbg (self, "checking current power operation...");
mm_base_modem_at_command (MM_BASE_MODEM (ctx->self), mm_base_modem_at_command (MM_BASE_MODEM (self),
"+CFUN?", "+CFUN?",
3, 3,
FALSE, FALSE,
@@ -487,10 +481,10 @@ set_current_modes_bands_step (GTask *task)
case SET_CURRENT_MODES_BANDS_STEP_BEFORE_COMMAND: case SET_CURRENT_MODES_BANDS_STEP_BEFORE_COMMAND:
/* If COPS required around the set command, run it unconditionally */ /* If COPS required around the set command, run it unconditionally */
if (ctx->self->priv->support_config.method == SETTINGS_UPDATE_METHOD_COPS) { if (self->priv->support_config.method == SETTINGS_UPDATE_METHOD_COPS) {
mm_dbg ("deregistering from the network for configuration change..."); mm_obj_dbg (self, "deregistering from the network for configuration change...");
mm_base_modem_at_command ( mm_base_modem_at_command (
MM_BASE_MODEM (ctx->self), MM_BASE_MODEM (self),
"+COPS=2", "+COPS=2",
10, 10,
FALSE, FALSE,
@@ -499,12 +493,12 @@ set_current_modes_bands_step (GTask *task)
return; return;
} }
/* If CFUN required, check initial state before triggering low-power mode ourselves */ /* If CFUN required, check initial state before triggering low-power mode ourselves */
else if (ctx->self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN) { else if (self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN) {
/* Do nothing if already in low-power mode */ /* Do nothing if already in low-power mode */
if (ctx->initial_state != MM_MODEM_POWER_STATE_LOW) { if (ctx->initial_state != MM_MODEM_POWER_STATE_LOW) {
mm_dbg ("powering down for configuration change..."); mm_obj_dbg (self, "powering down for configuration change...");
mm_base_modem_at_command ( mm_base_modem_at_command (
MM_BASE_MODEM (ctx->self), MM_BASE_MODEM (self),
"+CFUN=4", "+CFUN=4",
3, 3,
FALSE, FALSE,
@@ -518,9 +512,9 @@ set_current_modes_bands_step (GTask *task)
/* fall through */ /* fall through */
case SET_CURRENT_MODES_BANDS_STEP_COMMAND: case SET_CURRENT_MODES_BANDS_STEP_COMMAND:
mm_dbg ("updating configuration..."); mm_obj_dbg (self, "updating configuration...");
mm_base_modem_at_command ( mm_base_modem_at_command (
MM_BASE_MODEM (ctx->self), MM_BASE_MODEM (self),
ctx->command, ctx->command,
3, 3,
FALSE, FALSE,
@@ -530,20 +524,20 @@ set_current_modes_bands_step (GTask *task)
case SET_CURRENT_MODES_BANDS_STEP_AFTER_COMMAND: case SET_CURRENT_MODES_BANDS_STEP_AFTER_COMMAND:
/* If COPS required around the set command, run it unconditionally */ /* If COPS required around the set command, run it unconditionally */
if (ctx->self->priv->support_config.method == SETTINGS_UPDATE_METHOD_COPS) { if (self->priv->support_config.method == SETTINGS_UPDATE_METHOD_COPS) {
mm_iface_modem_3gpp_reregister_in_network (MM_IFACE_MODEM_3GPP (ctx->self), mm_iface_modem_3gpp_reregister_in_network (MM_IFACE_MODEM_3GPP (self),
(GAsyncReadyCallback) set_current_modes_bands_reregister_in_network_ready, (GAsyncReadyCallback) set_current_modes_bands_reregister_in_network_ready,
task); task);
return; return;
} }
/* If CFUN required, see if we need to recover power */ /* If CFUN required, see if we need to recover power */
else if (ctx->self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN) { else if (self->priv->support_config.method == SETTINGS_UPDATE_METHOD_CFUN) {
/* If we were in low-power mode before the change, do nothing, otherwise, /* If we were in low-power mode before the change, do nothing, otherwise,
* full power mode back */ * full power mode back */
if (ctx->initial_state != MM_MODEM_POWER_STATE_LOW) { if (ctx->initial_state != MM_MODEM_POWER_STATE_LOW) {
mm_dbg ("recovering power state after configuration change..."); mm_obj_dbg (self, "recovering power state after configuration change...");
mm_base_modem_at_command ( mm_base_modem_at_command (
MM_BASE_MODEM (ctx->self), MM_BASE_MODEM (self),
"+CFUN=1", "+CFUN=1",
3, 3,
FALSE, FALSE,
@@ -556,8 +550,8 @@ set_current_modes_bands_step (GTask *task)
/* fall through */ /* fall through */
case SET_CURRENT_MODES_BANDS_STEP_RELEASE: case SET_CURRENT_MODES_BANDS_STEP_RELEASE:
mm_dbg ("releasing power operation..."); mm_obj_dbg (self, "releasing power operation...");
release_power_operation (ctx->self); release_power_operation (self);
ctx->step++; ctx->step++;
/* fall through */ /* fall through */
@@ -602,7 +596,7 @@ set_current_modes (MMIfaceModem *self,
return; return;
} }
set_current_modes_bands_context_new (task, self, command); set_current_modes_bands_context_new (task, command);
set_current_modes_bands_step (task); set_current_modes_bands_step (task);
} }
@@ -636,7 +630,7 @@ set_current_bands (MMIfaceModem *_self,
return; return;
} }
set_current_modes_bands_context_new (task, _self, command); set_current_modes_bands_context_new (task, command);
set_current_modes_bands_step (task); set_current_modes_bands_step (task);
} }
@@ -656,7 +650,7 @@ load_current_modes_finish (MMIfaceModem *self,
if (!response) if (!response)
return FALSE; return FALSE;
return mm_ublox_parse_urat_read_response (response, allowed, preferred, error); return mm_ublox_parse_urat_read_response (response, self, allowed, preferred, error);
} }
static void static void
@@ -687,7 +681,7 @@ load_supported_modes_finish (MMIfaceModem *self,
if (!response) if (!response)
return FALSE; return FALSE;
if (!(combinations = mm_ublox_parse_urat_test_response (response, error))) if (!(combinations = mm_ublox_parse_urat_test_response (response, self, error)))
return FALSE; return FALSE;
if (!(combinations = mm_ublox_filter_supported_modes (mm_iface_modem_get_model (self), combinations, self, error))) if (!(combinations = mm_ublox_filter_supported_modes (mm_iface_modem_get_model (self), combinations, self, error)))
@@ -929,7 +923,7 @@ udtmfd_ready (MMBaseModem *self,
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
if (!mm_base_modem_at_command_full_finish (self, res, &error)) { if (!mm_base_modem_at_command_full_finish (self, res, &error)) {
mm_dbg ("Couldn't %s +UUDTMFD reporting: '%s'", mm_obj_dbg (self, "couldn't %s +UUDTMFD reporting: '%s'",
ctx->enable ? "enable" : "disable", ctx->enable ? "enable" : "disable",
error->message); error->message);
g_error_free (error); g_error_free (error);
@@ -950,7 +944,7 @@ ucallstat_ready (MMBaseModem *self,
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
if (!mm_base_modem_at_command_full_finish (self, res, &error)) { if (!mm_base_modem_at_command_full_finish (self, res, &error)) {
mm_dbg ("Couldn't %s +UCALLSTAT reporting: '%s'", mm_obj_dbg (self, "couldn't %s +UCALLSTAT reporting: '%s'",
ctx->enable ? "enable" : "disable", ctx->enable ? "enable" : "disable",
error->message); error->message);
g_error_free (error); g_error_free (error);
@@ -966,7 +960,7 @@ voice_unsolicited_events_context_step (GTask *task)
MMBroadbandModemUblox *self; MMBroadbandModemUblox *self;
VoiceUnsolicitedEventsContext *ctx; VoiceUnsolicitedEventsContext *ctx;
self = MM_BROADBAND_MODEM_UBLOX (g_task_get_source_object (task)); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
switch (ctx->step) { switch (ctx->step) {
@@ -976,8 +970,8 @@ voice_unsolicited_events_context_step (GTask *task)
case VOICE_UNSOLICITED_EVENTS_STEP_UCALLSTAT_PRIMARY: case VOICE_UNSOLICITED_EVENTS_STEP_UCALLSTAT_PRIMARY:
if (ctx->primary) { if (ctx->primary) {
mm_dbg ("%s extended call status reporting in primary port...", mm_obj_dbg (self, "%s extended call status reporting in primary port...",
ctx->enable ? "Enabling" : "Disabling"); ctx->enable ? "enabling" : "disabling");
mm_base_modem_at_command_full (MM_BASE_MODEM (self), mm_base_modem_at_command_full (MM_BASE_MODEM (self),
ctx->primary, ctx->primary,
ctx->ucallstat_command, ctx->ucallstat_command,
@@ -994,8 +988,8 @@ voice_unsolicited_events_context_step (GTask *task)
case VOICE_UNSOLICITED_EVENTS_STEP_UCALLSTAT_SECONDARY: case VOICE_UNSOLICITED_EVENTS_STEP_UCALLSTAT_SECONDARY:
if (ctx->secondary) { if (ctx->secondary) {
mm_dbg ("%s extended call status reporting in secondary port...", mm_obj_dbg (self, "%s extended call status reporting in secondary port...",
ctx->enable ? "Enabling" : "Disabling"); ctx->enable ? "enabling" : "disabling");
mm_base_modem_at_command_full (MM_BASE_MODEM (self), mm_base_modem_at_command_full (MM_BASE_MODEM (self),
ctx->secondary, ctx->secondary,
ctx->ucallstat_command, ctx->ucallstat_command,
@@ -1012,8 +1006,8 @@ voice_unsolicited_events_context_step (GTask *task)
case VOICE_UNSOLICITED_EVENTS_STEP_UDTMFD_PRIMARY: case VOICE_UNSOLICITED_EVENTS_STEP_UDTMFD_PRIMARY:
if ((self->priv->udtmfd_support == FEATURE_SUPPORTED) && (ctx->primary)) { if ((self->priv->udtmfd_support == FEATURE_SUPPORTED) && (ctx->primary)) {
mm_dbg ("%s DTMF detection and reporting in primary port...", mm_obj_dbg (self, "%s DTMF detection and reporting in primary port...",
ctx->enable ? "Enabling" : "Disabling"); ctx->enable ? "enabling" : "disabling");
mm_base_modem_at_command_full (MM_BASE_MODEM (self), mm_base_modem_at_command_full (MM_BASE_MODEM (self),
ctx->primary, ctx->primary,
ctx->udtmfd_command, ctx->udtmfd_command,
@@ -1030,8 +1024,8 @@ voice_unsolicited_events_context_step (GTask *task)
case VOICE_UNSOLICITED_EVENTS_STEP_UDTMFD_SECONDARY: case VOICE_UNSOLICITED_EVENTS_STEP_UDTMFD_SECONDARY:
if ((self->priv->udtmfd_support == FEATURE_SUPPORTED) && (ctx->secondary)) { if ((self->priv->udtmfd_support == FEATURE_SUPPORTED) && (ctx->secondary)) {
mm_dbg ("%s DTMF detection and reporting in secondary port...", mm_obj_dbg (self, "%s DTMF detection and reporting in secondary port...",
ctx->enable ? "Enabling" : "Disabling"); ctx->enable ? "enabling" : "disabling");
mm_base_modem_at_command_full (MM_BASE_MODEM (self), mm_base_modem_at_command_full (MM_BASE_MODEM (self),
ctx->secondary, ctx->secondary,
ctx->udtmfd_command, ctx->udtmfd_command,
@@ -1103,7 +1097,7 @@ voice_enable_unsolicited_events_ready (MMBroadbandModemUblox *self,
GError *error = NULL; GError *error = NULL;
if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error)) { if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error)) {
mm_warn ("Couldn't enable u-blox-specific voice unsolicited events: %s", error->message); mm_obj_warn (self, "Couldn't enable u-blox-specific voice unsolicited events: %s", error->message);
g_error_free (error); g_error_free (error);
} }
@@ -1182,7 +1176,7 @@ voice_disable_unsolicited_events_ready (MMBroadbandModemUblox *self,
GError *error = NULL; GError *error = NULL;
if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error)) { if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error)) {
mm_warn ("Couldn't disable u-blox-specific voice unsolicited events: %s", error->message); mm_obj_warn (self, "Couldn't disable u-blox-specific voice unsolicited events: %s", error->message);
g_error_free (error); g_error_free (error);
} }
@@ -1230,14 +1224,14 @@ ucallstat_received (MMPortSerialAt *port,
guint aux; guint aux;
if (!mm_get_uint_from_match_info (match_info, 1, &aux)) { if (!mm_get_uint_from_match_info (match_info, 1, &aux)) {
mm_warn ("couldn't parse call index from +UCALLSTAT"); mm_obj_warn (self, "couldn't parse call index from +UCALLSTAT");
return; return;
} }
call_info.index = aux; call_info.index = aux;
if (!mm_get_uint_from_match_info (match_info, 2, &aux) || if (!mm_get_uint_from_match_info (match_info, 2, &aux) ||
(aux >= G_N_ELEMENTS (ublox_call_state))) { (aux >= G_N_ELEMENTS (ublox_call_state))) {
mm_warn ("couldn't parse call state from +UCALLSTAT"); mm_obj_warn (self, "couldn't parse call state from +UCALLSTAT");
return; return;
} }
call_info.state = ublox_call_state[aux]; call_info.state = ublox_call_state[aux];
@@ -1269,13 +1263,12 @@ udtmfd_received (MMPortSerialAt *port,
GMatchInfo *match_info, GMatchInfo *match_info,
MMBroadbandModemUblox *self) MMBroadbandModemUblox *self)
{ {
gchar *dtmf; g_autofree gchar *dtmf = NULL;
dtmf = g_match_info_fetch (match_info, 1); dtmf = g_match_info_fetch (match_info, 1);
mm_dbg ("received DTMF: %s", dtmf); mm_obj_dbg (self, "received DTMF: %s", dtmf);
/* call index unknown */ /* call index unknown */
mm_iface_modem_voice_received_dtmf (MM_IFACE_MODEM_VOICE (self), 0, dtmf); mm_iface_modem_voice_received_dtmf (MM_IFACE_MODEM_VOICE (self), 0, dtmf);
g_free (dtmf);
} }
static void static void
@@ -1333,7 +1326,7 @@ parent_voice_cleanup_unsolicited_events_ready (MMIfaceModemVoice *self,
GError *error = NULL; GError *error = NULL;
if (!iface_modem_voice_parent->cleanup_unsolicited_events_finish (self, res, &error)) { if (!iface_modem_voice_parent->cleanup_unsolicited_events_finish (self, res, &error)) {
mm_warn ("Couldn't cleanup parent voice unsolicited events: %s", error->message); mm_obj_warn (self, "Couldn't cleanup parent voice unsolicited events: %s", error->message);
g_error_free (error); g_error_free (error);
} }
@@ -1379,7 +1372,7 @@ parent_voice_setup_unsolicited_events_ready (MMIfaceModemVoice *self,
GError *error = NULL; GError *error = NULL;
if (!iface_modem_voice_parent->setup_unsolicited_events_finish (self, res, &error)) { if (!iface_modem_voice_parent->setup_unsolicited_events_finish (self, res, &error)) {
mm_warn ("Couldn't setup parent voice unsolicited events: %s", error->message); mm_obj_warn (self, "Couldn't setup parent voice unsolicited events: %s", error->message);
g_error_free (error); g_error_free (error);
} }
@@ -1497,7 +1490,6 @@ typedef enum {
} CreateBearerStep; } CreateBearerStep;
typedef struct { typedef struct {
MMBroadbandModemUblox *self;
CreateBearerStep step; CreateBearerStep step;
MMBearerProperties *properties; MMBearerProperties *properties;
MMBaseBearer *bearer; MMBaseBearer *bearer;
@@ -1507,10 +1499,8 @@ typedef struct {
static void static void
create_bearer_context_free (CreateBearerContext *ctx) create_bearer_context_free (CreateBearerContext *ctx)
{ {
if (ctx->bearer) g_clear_object (&ctx->bearer);
g_object_unref (ctx->bearer);
g_object_unref (ctx->properties); g_object_unref (ctx->properties);
g_object_unref (ctx->self);
g_slice_free (CreateBearerContext, ctx); g_slice_free (CreateBearerContext, ctx);
} }
@@ -1529,10 +1519,12 @@ broadband_bearer_new_ready (GObject *source,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemUblox *self;
CreateBearerContext *ctx; CreateBearerContext *ctx;
GError *error = NULL; GError *error = NULL;
ctx = (CreateBearerContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
g_assert (!ctx->bearer); g_assert (!ctx->bearer);
ctx->bearer = mm_broadband_bearer_new_finish (res, &error); ctx->bearer = mm_broadband_bearer_new_finish (res, &error);
@@ -1542,7 +1534,7 @@ broadband_bearer_new_ready (GObject *source,
return; return;
} }
mm_dbg ("u-blox: new generic broadband bearer created at DBus path '%s'", mm_base_bearer_get_path (ctx->bearer)); mm_obj_dbg (self, "new generic broadband bearer created at DBus path '%s'", mm_base_bearer_get_path (ctx->bearer));
ctx->step++; ctx->step++;
create_bearer_step (task); create_bearer_step (task);
} }
@@ -1552,10 +1544,12 @@ broadband_bearer_ublox_new_ready (GObject *source,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemUblox *self;
CreateBearerContext *ctx; CreateBearerContext *ctx;
GError *error = NULL; GError *error = NULL;
ctx = (CreateBearerContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
g_assert (!ctx->bearer); g_assert (!ctx->bearer);
ctx->bearer = mm_broadband_bearer_ublox_new_finish (res, &error); ctx->bearer = mm_broadband_bearer_ublox_new_finish (res, &error);
@@ -1565,74 +1559,76 @@ broadband_bearer_ublox_new_ready (GObject *source,
return; return;
} }
mm_dbg ("u-blox: new u-blox broadband bearer created at DBus path '%s'", mm_base_bearer_get_path (ctx->bearer)); mm_obj_dbg (self, "new u-blox broadband bearer created at DBus path '%s'", mm_base_bearer_get_path (ctx->bearer));
ctx->step++; ctx->step++;
create_bearer_step (task); create_bearer_step (task);
} }
static void static void
mode_check_ready (MMBaseModem *self, mode_check_ready (MMBaseModem *_self,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemUblox *self = MM_BROADBAND_MODEM_UBLOX (_self);
const gchar *response; const gchar *response;
GError *error = NULL; GError *error = NULL;
CreateBearerContext *ctx; CreateBearerContext *ctx;
ctx = (CreateBearerContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
response = mm_base_modem_at_command_finish (self, res, &error); response = mm_base_modem_at_command_finish (_self, res, &error);
if (!response) { if (!response) {
mm_dbg ("u-blox: couldn't load current networking mode: %s", error->message); mm_obj_dbg (self, "couldn't load current networking mode: %s", error->message);
g_error_free (error); g_error_free (error);
} else if (!mm_ublox_parse_ubmconf_response (response, &ctx->self->priv->mode, &error)) { } else if (!mm_ublox_parse_ubmconf_response (response, &self->priv->mode, &error)) {
mm_dbg ("u-blox: couldn't parse current networking mode response '%s': %s", response, error->message); mm_obj_dbg (self, "couldn't parse current networking mode response '%s': %s", response, error->message);
g_error_free (error); g_error_free (error);
} else { } else {
g_assert (ctx->self->priv->mode != MM_UBLOX_NETWORKING_MODE_UNKNOWN); g_assert (self->priv->mode != MM_UBLOX_NETWORKING_MODE_UNKNOWN);
mm_dbg ("u-blox: networking mode loaded: %s", mm_ublox_networking_mode_get_string (ctx->self->priv->mode)); mm_obj_dbg (self, "networking mode loaded: %s", mm_ublox_networking_mode_get_string (self->priv->mode));
} }
/* If checking networking mode isn't supported, we'll fallback to /* If checking networking mode isn't supported, we'll fallback to
* assume the device is in router mode, which is the mode asking for * assume the device is in router mode, which is the mode asking for
* less connection setup rules from our side (just request DHCP). * less connection setup rules from our side (just request DHCP).
*/ */
if (ctx->self->priv->mode == MM_UBLOX_NETWORKING_MODE_UNKNOWN && ctx->has_net) { if (self->priv->mode == MM_UBLOX_NETWORKING_MODE_UNKNOWN && ctx->has_net) {
mm_dbg ("u-blox: fallback to default networking mode: router"); mm_obj_dbg (self, "fallback to default networking mode: router");
ctx->self->priv->mode = MM_UBLOX_NETWORKING_MODE_ROUTER; self->priv->mode = MM_UBLOX_NETWORKING_MODE_ROUTER;
} }
ctx->self->priv->mode_checked = TRUE; self->priv->mode_checked = TRUE;
ctx->step++; ctx->step++;
create_bearer_step (task); create_bearer_step (task);
} }
static void static void
profile_check_ready (MMBaseModem *self, profile_check_ready (MMBaseModem *_self,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemUblox *self = MM_BROADBAND_MODEM_UBLOX (_self);
const gchar *response; const gchar *response;
GError *error = NULL; GError *error = NULL;
CreateBearerContext *ctx; CreateBearerContext *ctx;
ctx = (CreateBearerContext *) g_task_get_task_data (task); ctx = g_task_get_task_data (task);
response = mm_base_modem_at_command_finish (self, res, &error); response = mm_base_modem_at_command_finish (_self, res, &error);
if (!response) { if (!response) {
mm_dbg ("u-blox: couldn't load current usb profile: %s", error->message); mm_obj_dbg (self, "couldn't load current usb profile: %s", error->message);
g_error_free (error); g_error_free (error);
} else if (!mm_ublox_parse_uusbconf_response (response, &ctx->self->priv->profile, &error)) { } else if (!mm_ublox_parse_uusbconf_response (response, &self->priv->profile, &error)) {
mm_dbg ("u-blox: couldn't parse current usb profile response '%s': %s", response, error->message); mm_obj_dbg (self, "couldn't parse current usb profile response '%s': %s", response, error->message);
g_error_free (error); g_error_free (error);
} else { } else {
g_assert (ctx->self->priv->profile != MM_UBLOX_USB_PROFILE_UNKNOWN); g_assert (self->priv->profile != MM_UBLOX_USB_PROFILE_UNKNOWN);
mm_dbg ("u-blox: usb profile loaded: %s", mm_ublox_usb_profile_get_string (ctx->self->priv->profile)); mm_obj_dbg (self, "usb profile loaded: %s", mm_ublox_usb_profile_get_string (self->priv->profile));
} }
/* Assume the operation has been performed, even if it may have failed */ /* Assume the operation has been performed, even if it may have failed */
ctx->self->priv->profile_checked = TRUE; self->priv->profile_checked = TRUE;
ctx->step++; ctx->step++;
create_bearer_step (task); create_bearer_step (task);
@@ -1641,19 +1637,22 @@ profile_check_ready (MMBaseModem *self,
static void static void
create_bearer_step (GTask *task) create_bearer_step (GTask *task)
{ {
MMBroadbandModemUblox *self;
CreateBearerContext *ctx; CreateBearerContext *ctx;
ctx = (CreateBearerContext *) g_task_get_task_data (task); self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
switch (ctx->step) { switch (ctx->step) {
case CREATE_BEARER_STEP_FIRST: case CREATE_BEARER_STEP_FIRST:
ctx->step++; ctx->step++;
/* fall through */ /* fall through */
case CREATE_BEARER_STEP_CHECK_PROFILE: case CREATE_BEARER_STEP_CHECK_PROFILE:
if (!ctx->self->priv->profile_checked) { if (!self->priv->profile_checked) {
mm_dbg ("u-blox: checking current USB profile..."); mm_obj_dbg (self, "checking current USB profile...");
mm_base_modem_at_command ( mm_base_modem_at_command (
MM_BASE_MODEM (ctx->self), MM_BASE_MODEM (self),
"+UUSBCONF?", "+UUSBCONF?",
3, 3,
FALSE, FALSE,
@@ -1665,10 +1664,10 @@ create_bearer_step (GTask *task)
/* fall through */ /* fall through */
case CREATE_BEARER_STEP_CHECK_MODE: case CREATE_BEARER_STEP_CHECK_MODE:
if (!ctx->self->priv->mode_checked) { if (!self->priv->mode_checked) {
mm_dbg ("u-blox: checking current networking mode..."); mm_obj_dbg (self, "checking current networking mode...");
mm_base_modem_at_command ( mm_base_modem_at_command (
MM_BASE_MODEM (ctx->self), MM_BASE_MODEM (self),
"+UBMCONF?", "+UBMCONF?",
3, 3,
FALSE, FALSE,
@@ -1682,16 +1681,16 @@ create_bearer_step (GTask *task)
case CREATE_BEARER_STEP_CREATE_BEARER: case CREATE_BEARER_STEP_CREATE_BEARER:
/* If we have a net interface, we'll create a u-blox bearer, unless for /* If we have a net interface, we'll create a u-blox bearer, unless for
* any reason we have the back-compatible profile selected. */ * any reason we have the back-compatible profile selected. */
if ((ctx->self->priv->profile != MM_UBLOX_USB_PROFILE_BACK_COMPATIBLE) && ctx->has_net) { if ((self->priv->profile != MM_UBLOX_USB_PROFILE_BACK_COMPATIBLE) && ctx->has_net) {
/* whenever there is a net port, we should have loaded a valid networking mode */ /* whenever there is a net port, we should have loaded a valid networking mode */
g_assert (ctx->self->priv->mode != MM_UBLOX_NETWORKING_MODE_UNKNOWN); g_assert (self->priv->mode != MM_UBLOX_NETWORKING_MODE_UNKNOWN);
mm_dbg ("u-blox: creating u-blox broadband bearer (%s profile, %s mode)...", mm_obj_dbg (self, "creating u-blox broadband bearer (%s profile, %s mode)...",
mm_ublox_usb_profile_get_string (ctx->self->priv->profile), mm_ublox_usb_profile_get_string (self->priv->profile),
mm_ublox_networking_mode_get_string (ctx->self->priv->mode)); mm_ublox_networking_mode_get_string (self->priv->mode));
mm_broadband_bearer_ublox_new ( mm_broadband_bearer_ublox_new (
MM_BROADBAND_MODEM (ctx->self), MM_BROADBAND_MODEM (self),
ctx->self->priv->profile, self->priv->profile,
ctx->self->priv->mode, self->priv->mode,
ctx->properties, ctx->properties,
NULL, /* cancellable */ NULL, /* cancellable */
(GAsyncReadyCallback) broadband_bearer_ublox_new_ready, (GAsyncReadyCallback) broadband_bearer_ublox_new_ready,
@@ -1701,8 +1700,8 @@ create_bearer_step (GTask *task)
/* If usb profile is back-compatible already, or if there is no NET port /* If usb profile is back-compatible already, or if there is no NET port
* available, create default generic bearer */ * available, create default generic bearer */
mm_dbg ("u-blox: creating generic broadband bearer..."); mm_obj_dbg (self, "creating generic broadband bearer...");
mm_broadband_bearer_new (MM_BROADBAND_MODEM (ctx->self), mm_broadband_bearer_new (MM_BROADBAND_MODEM (self),
ctx->properties, ctx->properties,
NULL, /* cancellable */ NULL, /* cancellable */
(GAsyncReadyCallback) broadband_bearer_new_ready, (GAsyncReadyCallback) broadband_bearer_new_ready,
@@ -1733,7 +1732,6 @@ modem_create_bearer (MMIfaceModem *self,
ctx = g_slice_new0 (CreateBearerContext); ctx = g_slice_new0 (CreateBearerContext);
ctx->step = CREATE_BEARER_STEP_FIRST; ctx->step = CREATE_BEARER_STEP_FIRST;
ctx->self = g_object_ref (self);
ctx->properties = g_object_ref (properties); ctx->properties = g_object_ref (properties);
/* Flag whether this modem has exposed a network interface */ /* Flag whether this modem has exposed a network interface */

View File

@@ -365,6 +365,7 @@ static const MMModemMode ublox_combinations[] = {
GArray * GArray *
mm_ublox_parse_urat_test_response (const gchar *response, mm_ublox_parse_urat_test_response (const gchar *response,
gpointer log_object,
GError **error) GError **error)
{ {
GArray *combinations = NULL; GArray *combinations = NULL;
@@ -415,7 +416,7 @@ mm_ublox_parse_urat_test_response (const gchar *response,
selected_value = g_array_index (selected, guint, i); selected_value = g_array_index (selected, guint, i);
if (selected_value >= G_N_ELEMENTS (ublox_combinations)) { if (selected_value >= G_N_ELEMENTS (ublox_combinations)) {
mm_warn ("Unexpected AcT value: %u", selected_value); mm_obj_warn (log_object, "unexpected AcT value: %u", selected_value);
continue; continue;
} }
@@ -435,12 +436,12 @@ mm_ublox_parse_urat_test_response (const gchar *response,
preferred_value = g_array_index (preferred, guint, j); preferred_value = g_array_index (preferred, guint, j);
if (preferred_value >= G_N_ELEMENTS (ublox_combinations)) { if (preferred_value >= G_N_ELEMENTS (ublox_combinations)) {
mm_warn ("Unexpected AcT preferred value: %u", preferred_value); mm_obj_warn (log_object, "unexpected AcT preferred value: %u", preferred_value);
continue; continue;
} }
combination.preferred = ublox_combinations[preferred_value]; combination.preferred = ublox_combinations[preferred_value];
if (mm_count_bits_set (combination.preferred) != 1) { if (mm_count_bits_set (combination.preferred) != 1) {
mm_warn ("AcT preferred value should be a single AcT: %u", preferred_value); mm_obj_warn (log_object, "AcT preferred value should be a single AcT: %u", preferred_value);
continue; continue;
} }
if (!(combination.allowed & combination.preferred)) if (!(combination.allowed & combination.preferred))
@@ -1023,6 +1024,7 @@ mm_ublox_filter_supported_modes (const gchar *model,
GArray * GArray *
mm_ublox_get_supported_bands (const gchar *model, mm_ublox_get_supported_bands (const gchar *model,
gpointer log_object,
GError **error) GError **error)
{ {
MMModemMode mode; MMModemMode mode;
@@ -1034,13 +1036,13 @@ mm_ublox_get_supported_bands (const gchar *model,
for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) { for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) {
if (g_str_has_prefix (model, band_configuration[i].model)) { if (g_str_has_prefix (model, band_configuration[i].model)) {
mm_dbg("Found Model (Supported Bands): %s", band_configuration[i].model); mm_obj_dbg (log_object, "known supported bands found for model: %s", band_configuration[i].model);
break; break;
} }
} }
if (i == G_N_ELEMENTS (band_configuration)) { if (i == G_N_ELEMENTS (band_configuration)) {
mm_warn ("Unknown model name given: %s", model); mm_obj_warn (log_object, "unknown model name given when looking for supported bands: %s", model);
return NULL; return NULL;
} }
@@ -1175,19 +1177,22 @@ static void
append_bands (GArray *bands, append_bands (GArray *bands,
guint ubandsel_value, guint ubandsel_value,
MMModemMode mode, MMModemMode mode,
const gchar *model) const gchar *model,
gpointer log_object)
{ {
guint i, j, k, x; guint i, j, k, x;
MMModemBand band; MMModemBand band;
/* Find Modem Model Index in band_configuration */ /* Find Modem Model Index in band_configuration */
for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) { for (i = 0; i < G_N_ELEMENTS (band_configuration); i++) {
if (g_str_has_prefix (model, band_configuration[i].model)) if (g_str_has_prefix (model, band_configuration[i].model)) {
mm_obj_dbg (log_object, "known bands found for model: %s", band_configuration[i].model);
break; break;
} }
}
if (i == G_N_ELEMENTS (band_configuration)) { if (i == G_N_ELEMENTS (band_configuration)) {
mm_warn ("Unknown Modem Model given: %s", model); mm_obj_warn (log_object, "unknown model name given when looking for bands: %s", model);
return; return;
} }
@@ -1242,6 +1247,7 @@ append_bands (GArray *bands,
GArray * GArray *
mm_ublox_parse_ubandsel_response (const gchar *response, mm_ublox_parse_ubandsel_response (const gchar *response,
const gchar *model, const gchar *model,
gpointer log_object,
GError **error) GError **error)
{ {
GArray *array_values = NULL; GArray *array_values = NULL;
@@ -1270,7 +1276,7 @@ mm_ublox_parse_ubandsel_response (const gchar *response,
mode = supported_modes_per_model (model); mode = supported_modes_per_model (model);
array = g_array_new (FALSE, FALSE, sizeof (MMModemBand)); array = g_array_new (FALSE, FALSE, sizeof (MMModemBand));
for (i = 0; i < array_values->len; i++) for (i = 0; i < array_values->len; i++)
append_bands (array, g_array_index (array_values, guint, i), mode, model); append_bands (array, g_array_index (array_values, guint, i), mode, model, log_object);
if (!array->len) { if (!array->len) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
@@ -1591,7 +1597,8 @@ mm_ublox_parse_uact_response (const gchar *response,
static GArray * static GArray *
parse_bands_from_string (const gchar *str, parse_bands_from_string (const gchar *str,
const gchar *group) const gchar *group,
gpointer log_object)
{ {
GArray *bands = NULL; GArray *bands = NULL;
GError *inner_error = NULL; GError *inner_error = NULL;
@@ -1603,12 +1610,12 @@ parse_bands_from_string (const gchar *str,
bands = uact_num_array_to_band_array (nums); bands = uact_num_array_to_band_array (nums);
tmpstr = mm_common_build_bands_string ((MMModemBand *)(bands->data), bands->len); tmpstr = mm_common_build_bands_string ((MMModemBand *)(bands->data), bands->len);
mm_dbg ("modem reports support for %s bands: %s", group, tmpstr); mm_obj_dbg (log_object, "modem reports support for %s bands: %s", group, tmpstr);
g_free (tmpstr); g_free (tmpstr);
g_array_unref (nums); g_array_unref (nums);
} else if (inner_error) { } else if (inner_error) {
mm_warn ("couldn't parse list of supported %s bands: %s", group, inner_error->message); mm_obj_warn (log_object, "couldn't parse list of supported %s bands: %s", group, inner_error->message);
g_clear_error (&inner_error); g_clear_error (&inner_error);
} }
@@ -1617,6 +1624,7 @@ parse_bands_from_string (const gchar *str,
gboolean gboolean
mm_ublox_parse_uact_test (const gchar *response, mm_ublox_parse_uact_test (const gchar *response,
gpointer log_object,
GArray **bands2g_out, GArray **bands2g_out,
GArray **bands3g_out, GArray **bands3g_out,
GArray **bands4g_out, GArray **bands4g_out,
@@ -1669,9 +1677,9 @@ mm_ublox_parse_uact_test (const gchar *response,
goto out; goto out;
} }
bands2g = parse_bands_from_string (bands2g_str, "2G"); bands2g = parse_bands_from_string (bands2g_str, "2G", log_object);
bands3g = parse_bands_from_string (bands3g_str, "3G"); bands3g = parse_bands_from_string (bands3g_str, "3G", log_object);
bands4g = parse_bands_from_string (bands4g_str, "4G"); bands4g = parse_bands_from_string (bands4g_str, "4G", log_object);
if (!bands2g->len && !bands3g->len && !bands4g->len) { if (!bands2g->len && !bands3g->len && !bands4g->len) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
@@ -1745,6 +1753,7 @@ mm_ublox_build_uact_set_command (GArray *bands,
gboolean gboolean
mm_ublox_parse_urat_read_response (const gchar *response, mm_ublox_parse_urat_read_response (const gchar *response,
gpointer log_object,
MMModemMode *out_allowed, MMModemMode *out_allowed,
MMModemMode *out_preferred, MMModemMode *out_preferred,
GError **error) GError **error)
@@ -1783,7 +1792,7 @@ mm_ublox_parse_urat_read_response (const gchar *response,
} }
allowed = ublox_combinations[value]; allowed = ublox_combinations[value];
allowed_str = mm_modem_mode_build_string_from_mask (allowed); allowed_str = mm_modem_mode_build_string_from_mask (allowed);
mm_dbg ("current allowed modes retrieved: %s", allowed_str); mm_obj_dbg (log_object, "current allowed modes retrieved: %s", allowed_str);
/* Preferred item is optional */ /* Preferred item is optional */
if (mm_get_uint_from_match_info (match_info, 2, &value)) { if (mm_get_uint_from_match_info (match_info, 2, &value)) {
@@ -1794,7 +1803,7 @@ mm_ublox_parse_urat_read_response (const gchar *response,
} }
preferred = ublox_combinations[value]; preferred = ublox_combinations[value];
preferred_str = mm_modem_mode_build_string_from_mask (preferred); preferred_str = mm_modem_mode_build_string_from_mask (preferred);
mm_dbg ("current preferred modes retrieved: %s", preferred_str); mm_obj_dbg (log_object, "current preferred modes retrieved: %s", preferred_str);
if (mm_count_bits_set (preferred) != 1) { if (mm_count_bits_set (preferred) != 1) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"AcT preferred value should be a single AcT: %s", preferred_str); "AcT preferred value should be a single AcT: %s", preferred_str);
@@ -1884,6 +1893,7 @@ mm_ublox_build_urat_set_command (MMModemMode allowed,
MMUbloxBearerAllowedAuth MMUbloxBearerAllowedAuth
mm_ublox_parse_uauthreq_test (const char *response, mm_ublox_parse_uauthreq_test (const char *response,
gpointer log_object,
GError **error) GError **error)
{ {
MMUbloxBearerAllowedAuth mask = MM_UBLOX_BEARER_ALLOWED_AUTH_UNKNOWN; MMUbloxBearerAllowedAuth mask = MM_UBLOX_BEARER_ALLOWED_AUTH_UNKNOWN;
@@ -1931,7 +1941,7 @@ mm_ublox_parse_uauthreq_test (const char *response,
mask |= MM_UBLOX_BEARER_ALLOWED_AUTH_AUTO; mask |= MM_UBLOX_BEARER_ALLOWED_AUTH_AUTO;
break; break;
default: default:
mm_warn ("Unexpected +UAUTHREQ value: %u", val); mm_obj_warn (log_object, "unexpected +UAUTHREQ value: %u", val);
break; break;
} }
} }

View File

@@ -101,6 +101,7 @@ gboolean mm_ublox_parse_cfun_response (const gchar *response,
/* URAT=? response parser */ /* URAT=? response parser */
GArray *mm_ublox_parse_urat_test_response (const gchar *response, GArray *mm_ublox_parse_urat_test_response (const gchar *response,
gpointer log_object,
GError **error); GError **error);
/*****************************************************************************/ /*****************************************************************************/
@@ -122,6 +123,7 @@ GArray *mm_ublox_filter_supported_modes (const gchar *model,
/* Model-based supported bands loading */ /* Model-based supported bands loading */
GArray *mm_ublox_get_supported_bands (const gchar *model, GArray *mm_ublox_get_supported_bands (const gchar *model,
gpointer log_object,
GError **error); GError **error);
/*****************************************************************************/ /*****************************************************************************/
@@ -129,6 +131,7 @@ GArray *mm_ublox_get_supported_bands (const gchar *model,
GArray *mm_ublox_parse_ubandsel_response (const gchar *response, GArray *mm_ublox_parse_ubandsel_response (const gchar *response,
const gchar *model, const gchar *model,
gpointer log_object,
GError **error); GError **error);
/*****************************************************************************/ /*****************************************************************************/
@@ -148,6 +151,7 @@ GArray *mm_ublox_parse_uact_response (const gchar *response,
/* UACT=? test parser */ /* UACT=? test parser */
gboolean mm_ublox_parse_uact_test (const gchar *response, gboolean mm_ublox_parse_uact_test (const gchar *response,
gpointer log_object,
GArray **bands_2g, GArray **bands_2g,
GArray **bands_3g, GArray **bands_3g,
GArray **bands_4g, GArray **bands_4g,
@@ -168,6 +172,7 @@ MMModemMode mm_ublox_get_modem_mode_any (const GArray *combinations);
/* URAT? response parser */ /* URAT? response parser */
gboolean mm_ublox_parse_urat_read_response (const gchar *response, gboolean mm_ublox_parse_urat_read_response (const gchar *response,
gpointer log_object,
MMModemMode *out_allowed, MMModemMode *out_allowed,
MMModemMode *out_preferred, MMModemMode *out_preferred,
GError **error); GError **error);
@@ -191,6 +196,7 @@ typedef enum { /*< underscore_name=mm_ublox_bearer_allowed_auth >*/
} MMUbloxBearerAllowedAuth; } MMUbloxBearerAllowedAuth;
MMUbloxBearerAllowedAuth mm_ublox_parse_uauthreq_test (const char *response, MMUbloxBearerAllowedAuth mm_ublox_parse_uauthreq_test (const char *response,
gpointer log_object,
GError **error); GError **error);
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -19,7 +19,7 @@
#define _LIBMM_INSIDE_MM #define _LIBMM_INSIDE_MM
#include <libmm-glib.h> #include <libmm-glib.h>
#include "mm-log.h" #include "mm-log-object.h"
#include "mm-serial-parsers.h" #include "mm-serial-parsers.h"
#include "mm-broadband-modem-ublox.h" #include "mm-broadband-modem-ublox.h"
#include "mm-plugin-ublox.h" #include "mm-plugin-ublox.h"
@@ -88,9 +88,7 @@ ready_timeout (GTask *task)
mm_port_serial_at_add_unsolicited_msg_handler (ctx->port, ctx->ready_regex, mm_port_serial_at_add_unsolicited_msg_handler (ctx->port, ctx->ready_regex,
NULL, NULL, NULL); NULL, NULL, NULL);
mm_dbg ("(%s/%s) timed out waiting for READY unsolicited message", mm_obj_dbg (probe, "timed out waiting for READY unsolicited message");
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe));
/* not an error really, we didn't probe anything yet, that's all */ /* not an error really, we didn't probe anything yet, that's all */
g_task_return_boolean (task, TRUE); g_task_return_boolean (task, TRUE);
@@ -113,9 +111,7 @@ ready_received (MMPortSerialAt *port,
g_source_remove (ctx->timeout_id); g_source_remove (ctx->timeout_id);
ctx->timeout_id = 0; ctx->timeout_id = 0;
mm_dbg ("(%s/%s) READY received: port is AT", mm_obj_dbg (probe, "received READY: port is AT");
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe));
/* Flag as an AT port right away */ /* Flag as an AT port right away */
mm_port_probe_set_result_at (probe, TRUE); mm_port_probe_set_result_at (probe, TRUE);
@@ -133,9 +129,7 @@ wait_for_ready (GTask *task)
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
probe = g_task_get_source_object (task); probe = g_task_get_source_object (task);
mm_dbg ("(%s/%s) waiting for READY unsolicited message...", mm_obj_dbg (probe, "waiting for READY unsolicited message...");
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe));
/* Configure a regex on the TTY, so that we stop the custom init /* Configure a regex on the TTY, so that we stop the custom init
* as soon as +READY URC is received */ * as soon as +READY URC is received */
@@ -145,10 +139,7 @@ wait_for_ready (GTask *task)
task, task,
NULL); NULL);
mm_dbg ("(%s/%s) waiting %d seconds for init timeout", mm_obj_dbg (probe, "waiting %d seconds for init timeout", ctx->wait_timeout_secs);
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe),
ctx->wait_timeout_secs);
/* Otherwise, let the custom init timeout in some seconds. */ /* Otherwise, let the custom init timeout in some seconds. */
ctx->timeout_id = g_timeout_add_seconds (ctx->wait_timeout_secs, (GSourceFunc) ready_timeout, task); ctx->timeout_id = g_timeout_add_seconds (ctx->wait_timeout_secs, (GSourceFunc) ready_timeout, task);
@@ -160,7 +151,7 @@ quick_at_ready (MMPortSerialAt *port,
GTask *task) GTask *task)
{ {
MMPortProbe *probe; MMPortProbe *probe;
GError *error = NULL; g_autoptr(GError) error = NULL;
probe = g_task_get_source_object (task); probe = g_task_get_source_object (task);
@@ -169,28 +160,21 @@ quick_at_ready (MMPortSerialAt *port,
/* On a timeout error, wait for READY URC */ /* On a timeout error, wait for READY URC */
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) { if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
wait_for_ready (task); wait_for_ready (task);
goto out; return;
} }
/* On an unknown error, make it fatal */ /* On an unknown error, make it fatal */
if (!mm_serial_parser_v1_is_known_error (error)) { if (!mm_serial_parser_v1_is_known_error (error)) {
mm_warn ("(%s/%s) custom port initialization logic failed: %s", mm_obj_warn (probe, "custom port initialization logic failed: %s", error->message);
mm_port_probe_get_port_subsys (probe), goto out;
mm_port_probe_get_port_name (probe),
error->message);
goto out_complete;
} }
} }
mm_dbg ("(%s/%s) port is AT", mm_obj_dbg (probe, "port is AT");
mm_port_probe_get_port_subsys (probe),
mm_port_probe_get_port_name (probe));
mm_port_probe_set_result_at (probe, TRUE); mm_port_probe_set_result_at (probe, TRUE);
out_complete: out:
g_task_return_boolean (task, TRUE); g_task_return_boolean (task, TRUE);
g_object_unref (task); g_object_unref (task);
out:
g_clear_error (&error);
} }
static void static void

View File

@@ -290,7 +290,7 @@ compare_combinations (const gchar *response,
GError *error = NULL; GError *error = NULL;
guint i; guint i;
combinations = mm_ublox_parse_urat_test_response (response, &error); combinations = mm_ublox_parse_urat_test_response (response, NULL, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (combinations); g_assert (combinations);
@@ -461,7 +461,7 @@ test_urat_read_response (void)
GError *error = NULL; GError *error = NULL;
gboolean success; gboolean success;
success = mm_ublox_parse_urat_read_response (urat_tests[i].response, success = mm_ublox_parse_urat_read_response (urat_tests[i].response, NULL,
&allowed, &preferred, &error); &allowed, &preferred, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (success); g_assert (success);
@@ -498,7 +498,7 @@ common_validate_ubandsel_response (const gchar *str,
GError *error = NULL; GError *error = NULL;
GArray *bands; GArray *bands;
bands = mm_ublox_parse_ubandsel_response (str, model, &error); bands = mm_ublox_parse_ubandsel_response (str, model, NULL, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (bands); g_assert (bands);
@@ -701,7 +701,7 @@ common_validate_uact_test (const gchar *str,
GArray *bands_3g = NULL; GArray *bands_3g = NULL;
GArray *bands_4g = NULL; GArray *bands_4g = NULL;
result = mm_ublox_parse_uact_test (str, &bands_2g, &bands_3g, &bands_4g, &error); result = mm_ublox_parse_uact_test (str, NULL, &bands_2g, &bands_3g, &bands_4g, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (result); g_assert (result);
@@ -858,7 +858,7 @@ common_validate_uauthreq_test (const gchar *str,
GError *error = NULL; GError *error = NULL;
MMUbloxBearerAllowedAuth allowed_auths; MMUbloxBearerAllowedAuth allowed_auths;
allowed_auths = mm_ublox_parse_uauthreq_test (str, &error); allowed_auths = mm_ublox_parse_uauthreq_test (str, NULL, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert_cmpuint (allowed_auths, ==, expected_allowed_auths); g_assert_cmpuint (allowed_auths, ==, expected_allowed_auths);
} }