Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/8] telit: notify sim inserted when sim ready
@ 2012-08-13 13:16 Christopher Vogl
  2012-08-13 13:23 ` Denis Kenzior
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Vogl @ 2012-08-13 13:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4312 bytes --]

Use AT#QSS=2 instead of AT#QSS=1 to get an URC when the SIM is not only
inserted but ready to be used.

Remove sim_inserted_source and sim_inserted_timeout_cb which are not
needed anymore as a consequence.
By the way the 1 second timeout was an ugly hack.

Don't query current SIM status in cfun_enable_cb() as the SIM is
disabled due to prior AT+CFUN=4.

Remove telit_qss_cb() which was used as a callback for querying the
current SIM status.
---
 plugins/telit.c |   44 ++++++++++----------------------------------
 1 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/plugins/telit.c b/plugins/telit.c
index 6ae7249..853fd44 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -68,7 +68,6 @@ struct telit_data {
 	GAtChat *chat;
 	GAtChat *aux;
 	struct ofono_sim *sim;
-	guint sim_inserted_source;
 	struct ofono_modem *sap_modem;
 	GIOChannel *bt_io;
 	GIOChannel *hw_io;
@@ -211,20 +210,6 @@ static GAtChat *open_device(struct ofono_modem *modem,
 	return chat;
 }
 
-static gboolean sim_inserted_timeout_cb(gpointer user_data)
-{
-	struct ofono_modem *modem = user_data;
-	struct telit_data *data = ofono_modem_get_data(modem);
-
-	DBG("%p", modem);
-
-	data->sim_inserted_source = 0;
-
-	ofono_sim_inserted_notify(data->sim, TRUE);
-
-	return FALSE;
-}
-
 static void switch_sim_state_status(struct ofono_modem *modem, int status)
 {
 	struct telit_data *data = ofono_modem_get_data(modem);
@@ -238,16 +223,13 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)
 		break;
 	case 1:
 		DBG("SIM inserted");
-		/* We need to sleep a bit */
-		data->sim_inserted_source = g_timeout_add_seconds(1,
-							sim_inserted_timeout_cb,
-							modem);
 		break;
 	case 2:
 		DBG("SIM inserted and PIN unlocked");
 		break;
 	case 3:
 		DBG("SIM inserted and ready");
+		ofono_sim_inserted_notify(data->sim, TRUE);
 		break;
 	}
 }
@@ -270,6 +252,13 @@ static void telit_qss_notify(GAtResult *result, gpointer user_data)
 	switch_sim_state_status(modem, status);
 }
 
+/*
+ * This function was used as a callback for querying the current SIM status
+ * with 'AT#QSS?'. As this was done in cfun_enable_cb(), in a state where the
+ * SIM is disabled because of 'AT+CFUN=4', the querying was removed.
+ * As soon as the modem is set online with 'AT+CFUN=1' (SIM is enabled again),
+ * we will start receiving QSS notifications - which makes querying the SIM
+ * status redundant.
 static void telit_qss_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
@@ -288,6 +277,7 @@ static void telit_qss_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	switch_sim_state_status(modem, status);
 }
+*/
 
 static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
@@ -308,15 +298,11 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	ofono_modem_set_powered(m, TRUE);
 
 	/* Enable sim state notification */
-	g_at_chat_send(data->chat, "AT#QSS=1", none_prefix, NULL, NULL, NULL);
+	g_at_chat_send(data->chat, "AT#QSS=2", none_prefix, NULL, NULL, NULL);
 
 	/* Follow sim state */
 	g_at_chat_register(data->chat, "#QSS:", telit_qss_notify,
 				FALSE, modem, NULL);
-
-	/* Query current sim state */
-	g_at_chat_send(data->chat, "AT#QSS?", qss_prefix,
-				telit_qss_cb, modem, NULL);
 }
 
 static int telit_enable(struct ofono_modem *modem)
@@ -397,9 +383,6 @@ static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	g_at_chat_unref(data->chat);
 	data->chat = NULL;
 
-	if (data->sim_inserted_source > 0)
-		g_source_remove(data->sim_inserted_source);
-
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
 
@@ -650,18 +633,11 @@ static int telit_probe(struct ofono_modem *modem)
 
 static void telit_remove(struct ofono_modem *modem)
 {
-	struct telit_data *data = ofono_modem_get_data(modem);
-
 	DBG("%p", modem);
 
 	bluetooth_sap_client_unregister(modem);
 
 	ofono_modem_set_data(modem, NULL);
-
-	if (data->sim_inserted_source > 0)
-		g_source_remove(data->sim_inserted_source);
-
-	g_free(data);
 }
 
 static struct ofono_modem_driver telit_driver = {
-- 
1.7.7.6


--
Scanned by MailScanner.


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-08-30 14:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-13 13:16 [PATCH 1/8] telit: notify sim inserted when sim ready Christopher Vogl
2012-08-13 13:23 ` Denis Kenzior
2012-08-20 14:34   ` Christopher Vogl
2012-08-20 14:50     ` Denis Kenzior
2012-08-20 15:20       ` Christopher Vogl
2012-08-20 15:42         ` Denis Kenzior
2012-08-22 14:24           ` [PATCH] sim: return from CPIN when SIM unlocked for telit Christopher Vogl
2012-08-22 14:24             ` [PATCH] telit: sim status notification without polling Christopher Vogl
2012-08-23 14:21               ` Denis Kenzior
2012-08-23 16:00                 ` Christopher Vogl
2012-08-23 17:37                   ` Denis Kenzior
2012-08-24 10:26                     ` Christopher Vogl
2012-08-28 15:19                     ` Christopher Vogl
2012-08-28 14:53                       ` Denis Kenzior
2012-08-29 15:01                         ` [PATCH] telit: enable extended sim status notification Christopher Vogl
2012-08-30 14:46                           ` Denis Kenzior
2012-08-22 23:44             ` [PATCH] sim: return from CPIN when SIM unlocked for telit Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox