From 6c9a7c54506e57238056d13bcba130c1aaff7840 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 9 Aug 2012 11:48:10 +0200 Subject: [PATCH] nokia: implement custom supported modes loading Nokia handsets report incorrect modes in AT+WS46?, so just fully skip that. --- plugins/nokia/mm-broadband-modem-nokia.c | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/plugins/nokia/mm-broadband-modem-nokia.c b/plugins/nokia/mm-broadband-modem-nokia.c index d0071bc3..c2a67d9c 100644 --- a/plugins/nokia/mm-broadband-modem-nokia.c +++ b/plugins/nokia/mm-broadband-modem-nokia.c @@ -63,6 +63,45 @@ create_sim (MMIfaceModem *self, user_data); } +/*****************************************************************************/ +/* Load supported modes (Modem interface) */ + +static MMModemMode +modem_load_supported_modes_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) +{ + return (MMModemMode)GPOINTER_TO_UINT (g_simple_async_result_get_op_res_gpointer ( + G_SIMPLE_ASYNC_RESULT (res))); +} + +static void +modem_load_supported_modes (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + MMModemMode mode; + + /* Nokia phones don't seem to like AT+WS46?, they just report 2G even if + * 3G is supported, so we'll just assume they actually do 3G. */ + mode = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G); + + /* Then, if the modem has LTE caps, it does 4G */ + if (mm_iface_modem_is_3gpp_lte (MM_IFACE_MODEM (self))) + mode |= MM_MODEM_MODE_4G; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + modem_load_supported_modes); + g_simple_async_result_set_op_res_gpointer (result, + GUINT_TO_POINTER (mode), + NULL); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); +} + /*****************************************************************************/ /* Modem initialization (Modem interface) */ @@ -165,6 +204,9 @@ iface_modem_init (MMIfaceModem *iface) iface->modem_power_up_finish = NULL; iface->modem_power_down = NULL; iface->modem_power_down_finish = NULL; + + iface->load_supported_modes = modem_load_supported_modes; + iface->load_supported_modes_finish = modem_load_supported_modes_finish; } static void