Skip to contentSkip to conversation

sim-poll: Count timeout from the moment STATUS is sent to modem.

PATCH Superseded Andrzej Zaborowski 1 participant 1 message Apr 29, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 sim-poll: Count timeout from the moment STATUS is sent to modem.

---
 drivers/atmodem/sim-poll.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
drivers/atmodem/sim-poll.c +12 -5
index f1a83e3..6dd7d60 100644
@@ -199,20 +199,27 @@ static void at_csim_status_cb(gboolean ok, GAtResult *result,
 	sim_fetch_command(spd, response[len - 1]);
 }
 
-static gboolean sim_status_poll(gpointer user_data)
+static void at_csim_status_sent_cb(guint command_id, gpointer user_data)
 {
 	struct sim_poll_data *spd = user_data;
 
-	spd->poll_timeout = 0;
-
 	/* The SIM must respond in a given time frame which is of at
 	 * least 5 seconds in TS 11.11.  */
 	spd->status_timeout = g_timeout_add_seconds(5,
 			sim_status_timeout, spd);
+}
+
+static gboolean sim_status_poll(gpointer user_data)
+{
+	struct sim_poll_data *spd = user_data;
+
+	spd->poll_timeout = 0;
+	spd->status_timeout = -1;
 
 	/* Send STATUS */
-	spd->status_cmd = g_at_chat_send(spd->chat, "AT+CSIM=8,A0F200C0",
-			csim_prefix, at_csim_status_cb, spd, NULL);
+	spd->status_cmd = g_at_chat_send_with_callback(spd->chat,
+			"AT+CSIM=8,A0F200C0", csim_prefix,
+			at_csim_status_sent_cb, at_csim_status_cb, spd, NULL);
 	if (spd->status_cmd == 0)
 		at_csim_status_cb(FALSE, NULL, spd);
 
Signature · 1 line
1.6.1