altair-lte: refactor code for handling 'data' in DetailedConnectContext
This commit is contained in:

committed by
Aleksander Morgado

parent
cddc4af7bd
commit
dac652321b
@@ -65,7 +65,7 @@ detailed_connect_context_new (MMBroadbandBearer *self,
|
|||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
||||||
ctx->primary = g_object_ref (primary);
|
ctx->primary = g_object_ref (primary);
|
||||||
ctx->data = data;
|
ctx->data = g_object_ref (data);
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
* We don't currently support cancelling AT commands, so we'll just check
|
* We don't currently support cancelling AT commands, so we'll just check
|
||||||
* whether the operation is to be cancelled at each step. */
|
* whether the operation is to be cancelled at each step. */
|
||||||
@@ -83,8 +83,7 @@ detailed_connect_context_complete_and_free (DetailedConnectContext *ctx)
|
|||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
g_object_unref (ctx->result);
|
g_object_unref (ctx->result);
|
||||||
g_object_unref (ctx->cancellable);
|
g_object_unref (ctx->cancellable);
|
||||||
if (ctx->data)
|
g_object_unref (ctx->data);
|
||||||
g_object_unref (ctx->data);
|
|
||||||
g_object_unref (ctx->primary);
|
g_object_unref (ctx->primary);
|
||||||
g_object_unref (ctx->modem);
|
g_object_unref (ctx->modem);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
@@ -181,6 +180,7 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
gchar *command, *apn;
|
gchar *command, *apn;
|
||||||
MMBearerProperties *config;
|
MMBearerProperties *config;
|
||||||
MMModem3gppRegistrationState registration_state;
|
MMModem3gppRegistrationState registration_state;
|
||||||
|
MMPort *data;
|
||||||
|
|
||||||
/* There is a known firmware bug that can leave the modem unusable if a
|
/* There is a known firmware bug that can leave the modem unusable if a
|
||||||
* connect attempt is made when out of coverage. So, fail without trying.
|
* connect attempt is made when out of coverage. So, fail without trying.
|
||||||
@@ -198,27 +198,25 @@ connect_3gpp (MMBroadbandBearer *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = detailed_connect_context_new (
|
data = mm_base_modem_peek_best_data_port (MM_BASE_MODEM (modem), MM_PORT_TYPE_NET);
|
||||||
self,
|
if (!data) {
|
||||||
modem,
|
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||||
primary,
|
callback,
|
||||||
/* Get a 'net' data port */
|
user_data,
|
||||||
mm_base_modem_get_best_data_port (MM_BASE_MODEM (modem),
|
MM_CORE_ERROR,
|
||||||
MM_PORT_TYPE_NET),
|
MM_CORE_ERROR_CONNECTED,
|
||||||
cancellable,
|
"Couldn't connect: no available net port available");
|
||||||
callback,
|
|
||||||
user_data);
|
|
||||||
|
|
||||||
if (!ctx->data) {
|
|
||||||
g_simple_async_result_set_error (
|
|
||||||
ctx->result,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_CONNECTED,
|
|
||||||
"Couldn't connect: no available net port available");
|
|
||||||
detailed_connect_context_complete_and_free (ctx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx = detailed_connect_context_new (self,
|
||||||
|
modem,
|
||||||
|
primary,
|
||||||
|
data,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
user_data);
|
||||||
|
|
||||||
config = mm_bearer_peek_config (MM_BEARER (self));
|
config = mm_bearer_peek_config (MM_BEARER (self));
|
||||||
apn = mm_at_serial_port_quote_string (mm_bearer_properties_get_apn (config));
|
apn = mm_at_serial_port_quote_string (mm_bearer_properties_get_apn (config));
|
||||||
command = g_strdup_printf ("%%APNN=%s",apn);
|
command = g_strdup_printf ("%%APNN=%s",apn);
|
||||||
|
Reference in New Issue
Block a user