broadband-modem-mbim: implement 3GPP registration request

This commit is contained in:
Aleksander Morgado
2013-04-17 15:19:41 +02:00
parent c7f3d33b3e
commit 854c371c8a
3 changed files with 154 additions and 0 deletions
+91
View File
@@ -1893,6 +1893,95 @@ modem_3gpp_run_registration_checks (MMIfaceModem3gpp *self,
/*****************************************************************************/
static gboolean
modem_3gpp_register_in_network_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
static void
register_state_set_ready (MbimDevice *device,
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
MbimMessage *response;
GError *error = NULL;
MbimNwError nw_error;
response = mbim_device_command_finish (device, res, &error);
if (response &&
mbim_message_command_done_get_result (response, &error) &&
mbim_message_register_state_response_parse (
response,
&nw_error,
NULL, /* &register_state */
NULL, /* register_mode */
NULL, /* available_data_classes */
NULL, /* current_cellular_class */
NULL, /* provider_id */
NULL, /* provider_name */
NULL, /* roaming_text */
NULL, /* registration_flag */
NULL)) {
if (nw_error)
error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error);
}
if (error)
g_simple_async_result_take_error (simple, error);
else
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
if (response)
mbim_message_unref (response);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
static void
modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
const gchar *operator_id,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
MbimDevice *device;
MbimMessage *message;
if (!peek_device (self, &device, callback, user_data))
return;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
modem_3gpp_run_registration_checks);
if (operator_id && operator_id[0])
message = (mbim_message_register_state_set_new (
operator_id,
MBIM_REGISTER_ACTION_MANUAL,
0, /* data_class, none preferred */
NULL));
else
message = (mbim_message_register_state_set_new (
"",
MBIM_REGISTER_ACTION_AUTOMATIC,
0, /* data_class, none preferred */
NULL));
mbim_device_command (device,
message,
60,
NULL,
(GAsyncReadyCallback)register_state_set_ready,
result);
mbim_message_unref (message);
}
/*****************************************************************************/
MMBroadbandModemMbim *
mm_broadband_modem_mbim_new (const gchar *device,
const gchar **drivers,
@@ -2019,6 +2108,8 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
iface->load_operator_name_finish = modem_3gpp_load_operator_name_finish;
iface->run_registration_checks = modem_3gpp_run_registration_checks;
iface->run_registration_checks_finish = modem_3gpp_run_registration_checks_finish;
iface->register_in_network = modem_3gpp_register_in_network;
iface->register_in_network_finish = modem_3gpp_register_in_network_finish;
/* Unneeded things */
iface->enable_unsolicited_registration_events = NULL;
+61
View File
@@ -15,6 +15,7 @@
#include "mm-modem-helpers-mbim.h"
#include "mm-enums-types.h"
#include "mm-errors-types.h"
#include "mm-log.h"
/*****************************************************************************/
@@ -82,3 +83,63 @@ mm_modem_3gpp_registration_state_from_mbim_register_state (MbimRegisterState sta
return MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN;
}
}
GError *
mm_mobile_equipment_error_from_mbim_nw_error (MbimNwError nw_error)
{
switch (nw_error) {
case MBIM_NW_ERROR_IMSI_UNKNOWN_IN_HLR:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_IMSI_UNKNOWN_IN_HLR,
"IMSI unknown in HLR");
case MBIM_NW_ERROR_IMSI_UNKNOWN_IN_VLR:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_IMSI_UNKNOWN_IN_VLR,
"IMSI unknown in VLR");
case MBIM_NW_ERROR_ILLEGAL_ME:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_ILLEGAL_ME,
"Illegal ME");
case MBIM_NW_ERROR_GPRS_NOT_ALLOWED:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_NOT_ALLOWED,
"GPRS not allowed");
case MBIM_NW_ERROR_GPRS_AND_NON_GPRS_NOT_ALLOWED:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_NOT_ALLOWED,
"GPRS and non-GPRS not allowed");
case MBIM_NW_ERROR_PLMN_NOT_ALLOWED:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_PLMN_NOT_ALLOWED,
"PLMN not allowed");
case MBIM_NW_ERROR_LOCATION_AREA_NOT_ALLOWED:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_LOCATION_NOT_ALLOWED,
"Location area not allowed");
case MBIM_NW_ERROR_ROAMING_NOT_ALLOWED_IN_LOCATION_AREA:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_ROAMING_NOT_ALLOWED,
"Roaming not allowed in location area");
case MBIM_NW_ERROR_GPRS_NOT_ALLOWED_IN_PLMN:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_NOT_ALLOWED,
"GPRS not allowed in PLMN");
case MBIM_NW_ERROR_NO_CELLS_IN_LOCATION_AREA:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_NO_CELLS_IN_LOCATION_AREA,
"No cells in location area");
case MBIM_NW_ERROR_NETWORK_FAILURE:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_NETWORK_FAILURE,
"Network failure");
case MBIM_NW_ERROR_CONGESTION:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_CONGESTION,
"Congestion");
default:
return g_error_new (MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_GPRS_UNKNOWN,
"Unknown error (%u)",
nw_error);
}
}
+2
View File
@@ -28,4 +28,6 @@ MMModemLock mm_modem_lock_from_mbim_pin_type (MbimPinType pin_type);
MMModem3gppRegistrationState mm_modem_3gpp_registration_state_from_mbim_register_state (MbimRegisterState state);
GError *mm_mobile_equipment_error_from_mbim_nw_error (MbimNwError nw_error);
#endif /* MM_MODEM_HELPERS_MBIM_H */