iface-modem: send modem initialization commands during enable

This commit is contained in:
Aleksander Morgado
2011-11-25 14:59:53 +01:00
parent b0a1eccd54
commit b948c93e59
2 changed files with 44 additions and 0 deletions

View File

@@ -753,6 +753,7 @@ typedef enum {
ENABLING_STEP_FIRST, ENABLING_STEP_FIRST,
ENABLING_STEP_OPEN_PORT, ENABLING_STEP_OPEN_PORT,
ENABLING_STEP_FLASH_PORT, ENABLING_STEP_FLASH_PORT,
ENABLING_STEP_MODEM_INIT,
ENABLING_STEP_LAST ENABLING_STEP_LAST
} EnablingStep; } EnablingStep;
@@ -829,6 +830,29 @@ mm_iface_modem_enable_finish (MMIfaceModem *self,
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
} }
#undef VOID_REPLY_READY_FN
#define VOID_REPLY_READY_FN(NAME) \
static void \
NAME##_ready (MMIfaceModem *self, \
GAsyncResult *res, \
EnablingContext *ctx) \
{ \
GError *error = NULL; \
\
MM_IFACE_MODEM_GET_INTERFACE (self)->NAME##_finish (self, res, &error); \
if (error) { \
g_simple_async_result_take_error (ctx->result, error); \
enabling_context_complete_and_free (ctx); \
return; \
} \
\
/* Go on to next step */ \
ctx->step++; \
interface_enabling_step (ctx); \
}
VOID_REPLY_READY_FN (modem_init);
static void static void
interface_enabling_flash_done (MMSerialPort *port, interface_enabling_flash_done (MMSerialPort *port,
GError *error, GError *error,
@@ -878,6 +902,18 @@ interface_enabling_step (EnablingContext *ctx)
ctx); ctx);
return; return;
case ENABLING_STEP_MODEM_INIT:
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init_finish) {
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->modem_init (
ctx->self,
(GAsyncReadyCallback)modem_init_ready,
ctx);
return;
}
/* Fall down to next step */
ctx->step++;
case ENABLING_STEP_LAST: case ENABLING_STEP_LAST:
/* We are done without errors! */ /* We are done without errors! */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);

View File

@@ -182,6 +182,14 @@ struct _MMIfaceModem {
gboolean (*set_allowed_modes_finish) (MMIfaceModem *self, gboolean (*set_allowed_modes_finish) (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Asynchronous modem initialization operation */
void (*modem_init) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*modem_init_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
}; };
GType mm_iface_modem_get_type (void); GType mm_iface_modem_get_type (void);