ublox: if authentication not required, ignore +UAUTHREQ=0 errors

Just go on with the connection attempt.
This commit is contained in:
Aleksander Morgado
2017-08-22 11:19:32 +02:00
parent 0239e8769b
commit acda0d69f1

View File

@@ -65,6 +65,7 @@ typedef struct {
MMPortSerialAt *primary; MMPortSerialAt *primary;
MMPort *data; MMPort *data;
guint cid; guint cid;
gboolean auth_required;
/* For IPv4 settings */ /* For IPv4 settings */
MMBearerIpConfig *ip_config; MMBearerIpConfig *ip_config;
} CommonConnectContext; } CommonConnectContext;
@@ -368,14 +369,22 @@ uauthreq_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
const gchar *response; const gchar *response;
GError *error = NULL; GError *error = NULL;
response = mm_base_modem_at_command_finish (modem, res, &error); response = mm_base_modem_at_command_finish (modem, res, &error);
if (!response) { if (!response) {
g_task_return_error (task, error); CommonConnectContext *ctx;
g_object_unref (task);
return; ctx = (CommonConnectContext *) g_task_get_task_data (task);
/* If authentication required and the +UAUTHREQ failed, abort */
if (ctx->auth_required) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
/* Otherwise, ignore */
g_error_free (error);
} }
activate_3gpp (task); activate_3gpp (task);
@@ -396,7 +405,10 @@ authenticate_3gpp (GTask *task)
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 (ctx->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 (ctx->self)));
if (!user || !password || allowed_auth == MM_BEARER_ALLOWED_AUTH_NONE) { /* Flag whether authentication is required. If it isn't, we won't fail
* connection attempt if the +UAUTHREQ command fails */
ctx->auth_required = (user && password && allowed_auth != MM_BEARER_ALLOWED_AUTH_NONE);
if (!ctx->auth_required) {
mm_dbg ("Not using authentication"); mm_dbg ("Not using authentication");
cmd = g_strdup_printf ("+UAUTHREQ=%u,0", ctx->cid); cmd = g_strdup_printf ("+UAUTHREQ=%u,0", ctx->cid);
} else { } else {