Permalink
Browse files

mtk: Resume registration when needed

Arale produces REGISTRATION_SUSPENDED events that need to be answered
with a RESUME_REGISTRATION command to resume registration. These events
are generated jointly with PLMN_CHANGED events and are probably used
to stop registration and let rild client check if the modem has a valid
FW for the operator's technology. This kind of behaviour will be
supported in future commits.
  • Loading branch information...
1 parent fb4db57 commit 2c83eb87980b08435b072ab4209030c192ad354d @alfonsosanchezbeato alfonsosanchezbeato committed Jan 16, 2015
Showing with 38 additions and 0 deletions.
  1. +38 −0 plugins/mtk.c
View
@@ -69,6 +69,7 @@
#include "drivers/mtkmodem/mtkutil.h"
#include "drivers/mtkmodem/mtkrequest.h"
#include "drivers/mtkmodem/mtkreply.h"
+#include "drivers/mtkmodem/mtkunsol.h"
#include "drivers/mtkmodem/mtksettings.h"
#define MAX_SIM_STATUS_RETRIES 15
@@ -306,6 +307,40 @@ static void mtk_radio_state_changed(struct ril_msg *message, gpointer user_data)
}
}
+static void reg_suspended_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct mtk_data *md = ofono_modem_get_data(modem);
+
+ if (message->error != RIL_E_SUCCESS) {
+ ofono_error("%s: RIL error %s", __func__,
+ ril_error_to_string(message->error));
+ return;
+ }
+
+ g_ril_print_response_no_args(md->ril, message);
+}
+
+static void reg_suspended(struct ril_msg *message, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct mtk_data *md = ofono_modem_get_data(modem);
+ struct parcel rilp;
+ int session_id;
+
+ session_id = g_mtk_unsol_parse_registration_suspended(md->ril, message);
+ if (session_id < 0) {
+ ofono_error("%s: parse error", __func__);
+ return;
+ }
+
+ g_mtk_request_resume_registration(md->ril, session_id, &rilp);
+
+ if (g_ril_send(md->ril, MTK_RIL_REQUEST_RESUME_REGISTRATION, &rilp,
+ reg_suspended_cb, modem, NULL) == 0)
+ ofono_error("%s: failure sending request", __func__);
+}
+
static void sim_removed(struct ril_msg *message, gpointer user_data)
{
struct ofono_modem *modem = (struct ofono_modem *) user_data;
@@ -1231,6 +1266,9 @@ static int create_gril(struct ofono_modem *modem)
RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
radio_state_changed, sock);
+ g_ril_register(sock->ril, MTK_RIL_UNSOL_RESPONSE_REGISTRATION_SUSPENDED,
+ reg_suspended, modem);
+
/* sock_num is negative to avoid confusion with physical slots */
g_ril_set_slot(sock->ril, sock_num);

0 comments on commit 2c83eb8

Please sign in to comment.