mbm: implement custom 3GPP disconnection sequence
This commit is contained in:
@@ -447,6 +447,86 @@ dial_3gpp (MMBroadbandBearer *self,
|
||||
user_data));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 3GPP disconnect */
|
||||
|
||||
typedef struct {
|
||||
MMBroadbandBearerMbm *self;
|
||||
MMBaseModem *modem;
|
||||
MMAtSerialPort *primary;
|
||||
GSimpleAsyncResult *result;
|
||||
} DisconnectContext;
|
||||
|
||||
static void
|
||||
disconnect_context_complete_and_free (DisconnectContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete (ctx->result);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->modem);
|
||||
g_free (ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
disconnect_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_enap_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
DisconnectContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
/* Ignore errors for now */
|
||||
mm_base_modem_at_command_full_finish (MM_BASE_MODEM (modem), res, &error);
|
||||
if (error) {
|
||||
mm_dbg ("Disconnection failed (not fatal): %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
disconnect_context_complete_and_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_3gpp (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMAtSerialPort *primary,
|
||||
MMAtSerialPort *secondary,
|
||||
MMPort *data,
|
||||
guint cid,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
DisconnectContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
ctx = g_new0 (DisconnectContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->modem = MM_BASE_MODEM (g_object_ref (modem));
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
disconnect_3gpp);
|
||||
|
||||
mm_base_modem_at_command_full (MM_BASE_MODEM (modem),
|
||||
primary,
|
||||
"*ENAP=0",
|
||||
3,
|
||||
FALSE,
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback)disconnect_enap_ready,
|
||||
ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBearer *
|
||||
@@ -507,4 +587,6 @@ mm_broadband_bearer_mbm_class_init (MMBroadbandBearerMbmClass *klass)
|
||||
|
||||
broadband_bearer_class->dial_3gpp = dial_3gpp;
|
||||
broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
|
||||
broadband_bearer_class->disconnect_3gpp = disconnect_3gpp;
|
||||
broadband_bearer_class->disconnect_3gpp_finish = disconnect_3gpp_finish;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user